Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#9942) planned unit movement
Home

[Freeciv-Dev] (PR#9942) planned unit movement

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: lakatoszoltan@xxxxxxxxxx
Subject: [Freeciv-Dev] (PR#9942) planned unit movement
From: "Guest" <rt-guest@xxxxxxxxxxx>
Date: Sat, 2 Oct 2004 14:33:44 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9942 >

 
Server option seems ready. (But I haven't made too much tests yet) 
 
As I see, I should change my basis to 1.14.2 
 
>We should instead remove packet_move_unit entirely.  When the client  
>wants to move a unit it should just send an orders packet. 
 
Do you really suggest to remove that pretty packet conversion? 
 
 
Zoli 
 
 
 
diff -r -u freeciv-1.14.1/common/game.c freeciv-1.14.1-mod/common/game.c
--- freeciv-1.14.1/common/game.c        2003-12-02 19:56:58.000000000 +0100
+++ freeciv-1.14.1-mod/common/game.c    2004-10-03 17:32:18.000000000 +0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -664,6 +664,7 @@
   game.max_players  = GAME_DEFAULT_MAX_PLAYERS;
   game.aifill      = GAME_DEFAULT_AIFILL;
   game.nplayers=0;
+  game.movement_model = GAME_DEFAULT_MOVEMENT_MODEL;
   game.researchcost = GAME_DEFAULT_RESEARCHCOST;
   game.diplcost    = GAME_DEFAULT_DIPLCOST;
   game.diplchance  = GAME_DEFAULT_DIPLCHANCE;
diff -r -u freeciv-1.14.1/common/game.h freeciv-1.14.1-mod/common/game.h
--- freeciv-1.14.1/common/game.h        2003-12-02 19:56:58.000000000 +0100
+++ freeciv-1.14.1-mod/common/game.h    2004-10-03 17:57:57.000000000 +0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -74,6 +74,7 @@
   int end_year;
   int year;
   int turn;
+  int movement_model; /* unit and player step order */
   int researchcost; /* Multiplier on cost of new research */
   int diplcost, freecost, conquercost;
   int diplchance;
@@ -191,7 +192,7 @@
     int tech_cost_style;
     int tech_leakage;
 
-    /* 
+    /*
      * Advances given to all players at game start.
      */
     int global_init_techs[MAX_NUM_TECH_LIST];
@@ -455,4 +456,10 @@
 
 #define GAME_START_YEAR -4000
 
+#define GAME_DEFAULT_MOVEMENT_MODEL 1
+#define GAME_MIN_MOVEMENT_MODEL 1
+#define GAME_MAX_MOVEMENT_MODEL 2
+
+
+
 #endif  /* FC__GAME_H */
diff -r -u freeciv-1.14.1/server/savegame.c freeciv-1.14.1-mod/server/savegame.c
--- freeciv-1.14.1/server/savegame.c    2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/savegame.c        2004-10-03 17:37:45.000000000 
+0200
@@ -1834,11 +1834,11 @@
 
     game.fogofwar = secfile_lookup_bool_default(file, FALSE, "game.fogofwar");
     game.fogofwar_old = game.fogofwar;
-  
+
     game.civilwarsize =
       secfile_lookup_int_default(file, GAME_DEFAULT_CIVILWARSIZE,
                                 "game.civilwarsize");
-  
+
     if(has_capability("diplchance_percent", savefile_options)) {
       game.diplchance = secfile_lookup_int_default(file, game.diplchance,
                                                   "game.diplchance");
@@ -1853,7 +1853,10 @@
        game.diplchance = 100 - (10 * (game.diplchance - 1));
       }
     }
-    game.aqueductloss = secfile_lookup_int_default(file, game.aqueductloss,
+    
+        game.movement_model = secfile_lookup_int_default(file, 
game.movement_model,
+                                                  "game.movement_model");
+        game.aqueductloss = secfile_lookup_int_default(file, game.aqueductloss,
                                                   "game.aqueductloss");
     game.killcitizen = secfile_lookup_int_default(file, game.killcitizen,
                                                  "game.killcitizen");
@@ -1867,7 +1870,7 @@
                                                    "game.barbarians");
     game.onsetbarbarian = secfile_lookup_int_default(file, game.onsetbarbarian,
                                                     "game.onsetbarbs");
-    game.nbarbarians = 0; /* counted in player_load for compatibility with 
+    game.nbarbarians = 0; /* counted in player_load for compatibility with
                             1.10.0 */
     game.occupychance = secfile_lookup_int_default(file, game.occupychance,
                                                   "game.occupychance");
@@ -1875,7 +1878,7 @@
                                               "game.randseed");
     game.allowed_city_names =
        secfile_lookup_int_default(file, game.allowed_city_names,
-                                  "game.allowed_city_names"); 
+                                  "game.allowed_city_names");
 
     if(game.civstyle == 1) {
       string = "civ1";
@@ -2151,11 +2154,12 @@
   secfile_insert_int(file, game.timeoutint, "game.timeoutint");
   secfile_insert_int(file, game.timeoutintinc, "game.timeoutintinc");
   secfile_insert_int(file, game.timeoutinc, "game.timeoutinc");
-  secfile_insert_int(file, game.timeoutincmult, "game.timeoutincmult"); 
-  secfile_insert_int(file, game.timeoutcounter, "game.timeoutcounter"); 
+  secfile_insert_int(file, game.timeoutincmult, "game.timeoutincmult");
+  secfile_insert_int(file, game.timeoutcounter, "game.timeoutcounter");
   secfile_insert_int(file, game.end_year, "game.end_year");
   secfile_insert_int(file, game.year, "game.year");
   secfile_insert_int(file, game.turn, "game.turn");
+  secfile_insert_int(file, game.movement_model, "game.movement_model");
   secfile_insert_int(file, game.researchcost, "game.researchcost");
   secfile_insert_int(file, game.min_players, "game.min_players");
   secfile_insert_int(file, game.max_players, "game.max_players");
diff -r -u freeciv-1.14.1/server/srv_main.c freeciv-1.14.1-mod/server/srv_main.c
--- freeciv-1.14.1/server/srv_main.c    2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/srv_main.c        2004-10-03 19:09:29.000000000 
+0200
@@ -763,8 +763,11 @@
     break;
 
   case PACKET_MOVE_UNIT:
-    handle_move_unit(pplayer, (struct packet_move_unit *)packet);
-    break;
+    if (game.movement_model == 2)
+      handle_move_unit_as_goto_route(pplayer, (struct packet_move_unit 
*)packet);
+        else
+          handle_move_unit(pplayer, (struct packet_move_unit *)packet);
+        break;
  
   case PACKET_CHAT_MSG:
     handle_chat_msg(pconn, (struct packet_generic_message *)packet);
diff -r -u freeciv-1.14.1/server/stdinhand.c 
freeciv-1.14.1-mod/server/stdinhand.c
--- freeciv-1.14.1/server/stdinhand.c   2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/stdinhand.c       2004-10-03 17:50:33.000000000 
+0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -252,7 +252,7 @@
   GEN_BOOL("separatepoles", map.separatepoles, SSET_MAP_GEN, SSET_TO_CLIENT,
           N_("Whether the poles are separate continents"),
           N_("0 = continents may attach to poles; 1 = poles will "
-             "be separate"), NULL, 
+             "be separate"), NULL,
           MAP_DEFAULT_SEPARATE_POLES)
 
   GEN_INT("landmass", map.landpercent, SSET_MAP_GEN, SSET_TO_CLIENT,
@@ -278,7 +278,7 @@
          MAP_MIN_FORESTS, MAP_MAX_FORESTS, MAP_DEFAULT_FORESTS)
 
   GEN_INT("swamps", map.swampsize, SSET_MAP_GEN, SSET_TO_CLIENT,
-         N_("Amount of swamp squares"), "", NULL, 
+         N_("Amount of swamp squares"), "", NULL,
          MAP_MIN_SWAMPS, MAP_MAX_SWAMPS, MAP_DEFAULT_SWAMPS)
     
   GEN_INT("deserts", map.deserts, SSET_MAP_GEN, SSET_TO_CLIENT,
@@ -325,7 +325,7 @@
             "players or AI's) before the game can start."), NULL,
          GAME_MIN_MIN_PLAYERS, GAME_MAX_MIN_PLAYERS,
          GAME_DEFAULT_MIN_PLAYERS)
-  
+
   GEN_INT("maxplayers", game.max_players, SSET_PLAYERS, SSET_TO_CLIENT,
          N_("Maximum number of players"),
           N_("The maximal number of human and AI players who can be in "
@@ -340,18 +340,18 @@
          N_("If there are fewer than this many players when the "
             "game starts, extra AI players will be created to "
             "increase the total number of players to the value of "
-            "this option."), NULL, 
+            "this option."), NULL,
          GAME_MIN_AIFILL, GAME_MAX_AIFILL, GAME_DEFAULT_AIFILL)
 
 /* Game initialization parameters (only affect the first start of the game,
  * and not reloads).  Can not be changed after first start of game.
  */
   GEN_INT("settlers", game.settlers, SSET_GAME_INIT, SSET_TO_CLIENT,
-         N_("Number of initial settlers per player"), "", NULL, 
+         N_("Number of initial settlers per player"), "", NULL,
          GAME_MIN_SETTLERS, GAME_MAX_SETTLERS, GAME_DEFAULT_SETTLERS)
 
   GEN_INT("explorer", game.explorer, SSET_GAME_INIT, SSET_TO_CLIENT,
-         N_("Number of initial explorers per player"), "", NULL, 
+         N_("Number of initial explorers per player"), "", NULL,
          GAME_MIN_EXPLORER, GAME_MAX_EXPLORER, GAME_DEFAULT_EXPLORER)
 
   GEN_INT("dispersion", game.dispersion, SSET_GAME_INIT, SSET_TO_CLIENT,
@@ -368,11 +368,19 @@
          N_("Number of initial advances per player"), "", NULL,
          GAME_MIN_TECHLEVEL, GAME_MAX_TECHLEVEL, GAME_DEFAULT_TECHLEVEL)
 
+GEN_INT("movementmodel", game.movement_model, SSET_RULES, SSET_TO_CLIENT,
+         N_("Unit movement model used"),
+         N_("1 = standard, all player steps real time\n"
+            "2 = planned, players can make goto planes,\n"
+                 "and units step only at the end of turn"), NULL,
+         GAME_MIN_MOVEMENT_MODEL, GAME_MAX_MOVEMENT_MODEL,
+         GAME_DEFAULT_MOVEMENT_MODEL)
+
   GEN_INT("researchcost", game.researchcost, SSET_RULES, SSET_TO_CLIENT,
          N_("Points required to gain a new advance"),
          N_("This affects how quickly players can research new "
             "technology."), NULL,
-         GAME_MIN_RESEARCHCOST, GAME_MAX_RESEARCHCOST, 
+         GAME_MIN_RESEARCHCOST, GAME_MAX_RESEARCHCOST,
          GAME_DEFAULT_RESEARCHCOST)
 
   GEN_INT("techpenalty", game.techpenalty, SSET_RULES, SSET_TO_CLIENT,
@@ -407,7 +415,7 @@
             "diplcost or conquercost: specifically, from huts or from the "
             "Great Library), you lose research points equal to this "
             "percentage of the cost to research a new advance.  You can "
-            "end up with negative research points if this is non-zero."), 
+            "end up with negative research points if this is non-zero."),
          NULL, 
          GAME_MIN_FREECOST, GAME_MAX_FREECOST, GAME_DEFAULT_FREECOST)
 
diff -r -u freeciv-1.14.1/server/unithand.c freeciv-1.14.1-mod/server/unithand.c
--- freeciv-1.14.1/server/unithand.c    2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/unithand.c        2004-10-03 19:05:01.000000000 
+0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -716,7 +716,7 @@
     punit->moves_left = 0;
   pwinner = (punit->hp > 0) ? punit : pdefender;
   plooser = (pdefender->hp > 0) ? punit : pdefender;
-    
+
   combat.attacker_unit_id=punit->id;
   combat.defender_unit_id=pdefender->id;
   combat.attacker_hp=punit->hp / game.firepower_factor;
@@ -1314,7 +1314,7 @@
 /**************************************************************************
 Explode nuclear at a tile without enemy units
 **************************************************************************/
-void handle_unit_nuke(struct player *pplayer, 
+void handle_unit_nuke(struct player *pplayer,
                      struct packet_unit_request *req)
 {
   struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id);
@@ -1328,11 +1328,11 @@
 /**************************************************************************
 ...
 **************************************************************************/
-void handle_unit_paradrop_to(struct player *pplayer, 
+void handle_unit_paradrop_to(struct player *pplayer,
                             struct packet_unit_request *req)
 {
   struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id);
-  
+
   if (!punit) {
     return;
   }
@@ -1414,6 +1414,10 @@
   if (!check_route(pplayer, packet))
     return;
 
+  if (game.movement_model == 2 ) {
+    punit->moves_left = 0;
+  }
+  
   handle_unit_activity_request(punit, ACTIVITY_GOTO);
   handle_route(pplayer, packet);
 }
@@ -1434,3 +1438,37 @@
   handle_unit_activity_request(punit, ACTIVITY_PATROL);
   handle_route(pplayer, packet);
 }
+
+/**************************************************************************
+Creates a packet_goto_route according to packet_move_unit
+**************************************************************************/
+struct packet_goto_route *create_packet_goto_route(struct packet_move_unit 
*pmove)
+{
+  int num_valid = 1;
+  struct packet_goto_route *packet;
+
+  packet = fc_malloc(sizeof(struct packet_goto_route));
+  packet->unit_id = pmove->unid;
+  packet->pos = fc_malloc((num_valid+1) * sizeof(struct map_position));
+  packet->length = num_valid + 1;
+  packet->first_index = 0;
+  packet->last_index = num_valid;
+
+  packet->pos[0].x = pmove->x;
+  packet->pos[0].y = pmove->y;
+
+  return packet;
+}
+
+/**************************************************************************
+Treats unit move as GOTO
+**************************************************************************/
+void handle_move_unit_as_goto_route(struct player *pplayer, struct 
packet_move_unit *pmove)
+{
+  struct packet_goto_route *packet = create_packet_goto_route(pmove);
+
+  handle_goto_route(pplayer,packet);
+
+  free(packet);
+}
+
diff -r -u freeciv-1.14.1/server/unithand.h freeciv-1.14.1-mod/server/unithand.h
--- freeciv-1.14.1/server/unithand.h    2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/unithand.h        2004-09-25 20:47:49.000000000 
+0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -67,4 +67,6 @@
 void handle_goto_route(struct player *pplayer, struct packet_goto_route 
*packet);
 void handle_patrol_route(struct player *pplayer, struct packet_goto_route 
*packet);
 
+void handle_move_unit_as_goto_route(struct player *pplayer, struct 
packet_move_unit *pmove);
+
 #endif  /* FC__UNITHAND_H */
diff -r -u freeciv-1.14.1/server/unittools.c 
freeciv-1.14.1-mod/server/unittools.c
--- freeciv-1.14.1/server/unittools.c   2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/unittools.c       2004-10-03 19:04:43.000000000 
+0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -366,7 +366,7 @@
       if (punit->fuel < unit_type(punit)->fuel) { 
         if (!best_unit) 
           best_unit=punit;
-        else 
+        else
           best_unit=choose_more_important_refuel_target(best_unit, punit);
       }
     }
@@ -1002,7 +1002,15 @@
        punit->ai.passenger != 0 || !pplayer->ai.control)) {
 /* autosettlers otherwise waste time; idling them breaks assignment */
 /* Stalling infantry on GOTO so I can see where they're GOing TO. -- Syela */
-      (void) do_unit_goto(punit, GOTO_MOVE_ANY, TRUE);
+        if (do_unit_goto(punit, GOTO_MOVE_ANY, TRUE) == GR_DIED) {
+                   return;
+        }
+                 
+                 if (game.movement_model == 2) {
+/* Restore unit flash and show movepoints in client --Zoli */
+          unit_restore_movepoints(pplayer, punit);
+          send_unit_info(NULL, punit);
+        }
     }
     return;
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9942) planned unit movement, Guest <=