<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39627 >

2007/8/30 Marko Lindqvist <cazf...@gmail.com>:
> On 30/08/2007, Pepeto _ <pepet...@hotmail.fr> wrote:
>> >
>> > On 29/08/07, Michael Kaufman <kauf...@physics.wisc.edu> wrote:
>> > >
>> > > The last time I checked, not doing a client reset on player switch
>> caused
>> > > bad things to happen, but I can't be more specific than that.
>>
>>  there should be a game_free() game_init()
>
>  Problem with game_free() + game_init() are is-info packets. Delta
> code needs changes so that we can force sending those packets again.

 Delta code is already updated. Attached patch makes game_free() +
game_init() reset at client side and server side is forced to send
tile info packets after that.

 Even though protocol doesn't change, new client will fail to work
with old server (as it makes the reset, but server will not serve tile
infos again) so I bumped capability string.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2009-05-03 18:59:38.000000000 +0300
+++ freeciv/client/packhand.c	2009-05-04 14:52:00.000000000 +0300
@@ -2492,9 +2492,9 @@
    * the nation selection dialog if it is open. */
   popdown_races_dialog();
 
-  ruleset_data_free();
-
+  game_free();
   ruleset_cache_init();
+  game_init();
 
   game.control = *packet;
 
diff -Nurd -X.diff_ignore freeciv/common/effects.c freeciv/common/effects.c
--- freeciv/common/effects.c	2009-04-29 20:40:43.000000000 +0300
+++ freeciv/common/effects.c	2009-05-04 14:52:36.000000000 +0300
@@ -338,7 +338,7 @@
 }
 
 /**************************************************************************
-  Initialize the ruleset cache.  The ruleset cache should be emtpy
+  Initialize the ruleset cache.  The ruleset cache should be empty
   before this is done (so if it's previously been initialized, it needs
   to be freed (see ruleset_cache_free) before it can be reused).
 **************************************************************************/
diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c
--- freeciv/server/citytools.c	2009-03-19 18:05:44.000000000 +0200
+++ freeciv/server/citytools.c	2009-05-04 14:36:41.000000000 +0300
@@ -2126,7 +2126,7 @@
 			   int city_x, int city_y)
 {
   tile_set_worked(ptile, NULL);
-  send_tile_info(NULL, ptile, FALSE);
+  send_tile_info(NULL, ptile, FALSE, FALSE);
   pcity->city_map[city_x][city_y] = C_TILE_EMPTY;
   pcity->server.synced = FALSE;
 }
@@ -2140,7 +2140,7 @@
 			    int city_x, int city_y)
 {
   tile_set_worked(ptile, pcity);
-  send_tile_info(NULL, ptile, FALSE);
+  send_tile_info(NULL, ptile, FALSE, FALSE);
   pcity->city_map[city_x][city_y] = C_TILE_WORKER;
   pcity->server.synced = FALSE;
 }
@@ -2158,7 +2158,7 @@
    && !is_free_worked(pwork, ptile)
    && !city_can_work_tile(pwork, ptile)) {
     tile_set_worked(ptile, NULL);
-    send_tile_info(NULL, ptile, FALSE);
+    send_tile_info(NULL, ptile, FALSE, FALSE);
 
     pwork->specialists[DEFAULT_SPECIALIST]++; /* keep city sanity */
     pwork->server.synced = FALSE;
diff -Nurd -X.diff_ignore freeciv/server/connecthand.c freeciv/server/connecthand.c
--- freeciv/server/connecthand.c	2008-12-15 21:55:50.000000000 +0200
+++ freeciv/server/connecthand.c	2009-05-04 14:37:20.000000000 +0300
@@ -120,7 +120,7 @@
       /* Player and other info is only updated when the game is running.
        * See the comment in lost_connection_to_client(). */
       send_packet_freeze_hint(pconn);
-      send_all_info(dest);
+      send_all_info(dest, TRUE);
       send_diplomatic_meetings(pconn);
       send_packet_thaw_hint(pconn);
       dsend_packet_start_phase(pconn, game.info.phase);
diff -Nurd -X.diff_ignore freeciv/server/edithand.c freeciv/server/edithand.c
--- freeciv/server/edithand.c	2009-01-27 12:17:08.000000000 +0200
+++ freeciv/server/edithand.c	2009-05-04 14:38:31.000000000 +0300
@@ -104,7 +104,7 @@
   hash_delete_all_entries(unfixed_tile_table);
 
   assign_continent_numbers();
-  send_all_known_tiles(NULL);
+  send_all_known_tiles(NULL, FALSE);
 }
 
 /****************************************************************************
@@ -377,7 +377,7 @@
   /* Send the new state to all affected. */
   if (changed) {
     update_tile_knowledge(ptile);
-    send_tile_info(NULL, ptile, FALSE);
+    send_tile_info(NULL, ptile, FALSE, FALSE);
   }
 }
 
@@ -1132,7 +1132,7 @@
       map_clear_known(ptile, pplayer);
     }
 
-    send_tile_info(NULL, ptile, TRUE);
+    send_tile_info(NULL, ptile, TRUE, FALSE);
   } square_iterate_end;
   conn_list_do_unbuffer(game.est_connections);
 }
@@ -1230,7 +1230,7 @@
   map_set_startpos(ptile, pnation);
 
   if (old != pnation) {
-    send_tile_info(NULL, ptile, FALSE);
+    send_tile_info(NULL, ptile, FALSE, FALSE);
   }
 }
 
diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c
--- freeciv/server/maphand.c	2009-03-08 13:54:37.000000000 +0200
+++ freeciv/server/maphand.c	2009-05-04 14:44:49.000000000 +0300
@@ -294,7 +294,7 @@
   calculations, so it will be correct before this, for each connection
   during this, and at end.
 **************************************************************************/
-void send_all_known_tiles(struct conn_list *dest)
+void send_all_known_tiles(struct conn_list *dest, bool force)
 {
   int tiles_sent;
 
@@ -315,7 +315,7 @@
       conn_list_do_buffer(dest);
     }
 
-    send_tile_info(dest, ptile, FALSE);
+    send_tile_info(dest, ptile, FALSE, force);
   } whole_map_iterate_end;
 
   conn_list_do_unbuffer(dest);
@@ -342,7 +342,7 @@
   update_tile_knowledge().
 **************************************************************************/
 void send_tile_info(struct conn_list *dest, struct tile *ptile,
-                    bool send_unknown)
+                    bool send_unknown, bool force)
 {
   struct packet_tile_info info;
   const struct nation_type *pnation;
@@ -399,7 +399,7 @@
       } tile_special_type_iterate_end;
       info.bases = ptile->bases;
 
-      send_packet_tile_info(pconn, FALSE, &info);
+      send_packet_tile_info(pconn, force, &info);
     } else if (pplayer && map_is_known(ptile, pplayer)
 	       && map_get_seen(ptile, pplayer, V_MAIN) == 0) {
       struct player_tile *plrtile = map_get_player_tile(ptile, pplayer);
@@ -426,7 +426,7 @@
       } tile_special_type_iterate_end;
       info.bases = plrtile->bases;
 
-      send_packet_tile_info(pconn, FALSE, &info);
+      send_packet_tile_info(pconn, force, &info);
     } else if (send_unknown) {
       info.known = TILE_UNKNOWN;
       info.continent = 0;
@@ -441,7 +441,7 @@
       } tile_special_type_iterate_end;
       BV_CLR_ALL(info.bases);
 
-      send_packet_tile_info(pconn, FALSE, &info);
+      send_packet_tile_info(pconn, force, &info);
     }
   }
   conn_list_iterate_end;
@@ -476,7 +476,7 @@
      * continent number before it can handle following packets
      */
     update_player_tile_knowledge(pplayer, ptile);
-    send_tile_info(pplayer->connections, ptile, FALSE);
+    send_tile_info(pplayer->connections, ptile, FALSE, FALSE);
     /* NOTE: because the V_INVIS case doesn't fall into this if statement,
      * changes to V_INVIS fogging won't send a new info packet to the client
      * and the client's tile_seen[V_INVIS] bitfield may end up being out
@@ -547,7 +547,7 @@
 
   if (vlayer == V_MAIN) {
     update_player_tile_last_seen(pplayer, ptile);
-    send_tile_info(pplayer->connections, ptile, FALSE);
+    send_tile_info(pplayer->connections, ptile, FALSE, FALSE);
   }
 }
 
@@ -654,7 +654,7 @@
 	update_player_tile_knowledge(pplayer, ptile);
 	update_player_tile_last_seen(pplayer, ptile);
 
-	send_tile_info(pplayer->connections, ptile, FALSE);
+	send_tile_info(pplayer->connections, ptile, FALSE, FALSE);
 
 	/* remove old cities that exist no more */
 	reality_check_city(pplayer, ptile);
@@ -1001,7 +1001,7 @@
   players_iterate(pplayer) {
     if (map_is_known_and_seen(ptile, pplayer, V_MAIN)) {
       if (update_player_tile_knowledge(pplayer, ptile)) {
-        send_tile_info(pplayer->connections, ptile, FALSE);
+        send_tile_info(pplayer->connections, ptile, FALSE, FALSE);
       }
     }
   } players_iterate_end;
@@ -1011,7 +1011,7 @@
     struct player *pplayer = pconn->playing;
 
     if (NULL == pplayer && pconn->observer) {
-      send_tile_info(pconn->self, ptile, FALSE);
+      send_tile_info(pconn->self, ptile, FALSE, FALSE);
     }
   } conn_list_iterate_end;
 }
@@ -1054,7 +1054,7 @@
       dest_tile->resource = from_tile->resource;
       dest_tile->bases    = from_tile->bases;
       dest_tile->last_updated = from_tile->last_updated;
-      send_tile_info(pdest->connections, ptile, FALSE);
+      send_tile_info(pdest->connections, ptile, FALSE, FALSE);
 
       /* update and send city knowledge */
       /* remove outdated cities */
@@ -1429,7 +1429,7 @@
 
   fix_tile_on_terrain_change(ptile, TRUE);
   assign_continent_numbers();
-  send_all_known_tiles(NULL);
+  send_all_known_tiles(NULL, FALSE);
 }
 
 /*************************************************************************
@@ -1532,7 +1532,7 @@
     }
 
     if (!city_map_update_tile_frozen(ptile)) {
-      send_tile_info(NULL, ptile, FALSE);
+      send_tile_info(NULL, ptile, FALSE, FALSE);
     }
   }
 }
diff -Nurd -X.diff_ignore freeciv/server/maphand.h freeciv/server/maphand.h
--- freeciv/server/maphand.h	2009-02-15 21:55:37.000000000 +0200
+++ freeciv/server/maphand.h	2009-05-04 14:35:44.000000000 +0300
@@ -50,11 +50,11 @@
 void give_seamap_from_player_to_player(struct player *pfrom, struct player *pdest);
 void give_citymap_from_player_to_player(struct city *pcity,
 					struct player *pfrom, struct player *pdest);
-void send_all_known_tiles(struct conn_list *dest);
+void send_all_known_tiles(struct conn_list *dest, bool force);
 
 bool send_tile_suppression(bool now);
 void send_tile_info(struct conn_list *dest, struct tile *ptile,
-                    bool send_unknown);
+                    bool send_unknown, bool force);
 
 void send_map_info(struct conn_list *dest);
 
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c	2009-05-03 18:59:38.000000000 +0300
+++ freeciv/server/srv_main.c	2009-05-04 14:45:35.000000000 +0300
@@ -362,7 +362,7 @@
   Send all information for when game starts or client reconnects.
   Ruleset information should have been sent before this.
 **************************************************************************/
-void send_all_info(struct conn_list *dest)
+void send_all_info(struct conn_list *dest, bool force)
 {
   conn_list_iterate(dest, pconn) {
       send_attribute_block(pconn->playing, pconn);
@@ -374,7 +374,7 @@
   send_player_info_c(NULL, dest);
   send_conn_info(game.est_connections, dest);
   send_spaceship_info(NULL, dest);
-  send_all_known_tiles(dest);
+  send_all_known_tiles(dest, force);
   send_all_known_cities(dest);
   send_all_known_units(dest);
   send_player_turn_notifications(dest);
@@ -2246,7 +2246,7 @@
   }
 
   lsend_packet_freeze_hint(game.est_connections);
-  send_all_info(game.est_connections);
+  send_all_info(game.est_connections, FALSE);
   lsend_packet_thaw_hint(game.est_connections);
   
   if (game.info.is_new_game) {
diff -Nurd -X.diff_ignore freeciv/server/srv_main.h freeciv/server/srv_main.h
--- freeciv/server/srv_main.h	2009-04-29 20:40:45.000000000 +0300
+++ freeciv/server/srv_main.h	2009-05-04 14:33:35.000000000 +0300
@@ -97,7 +97,7 @@
 void save_game(char *orig_filename, const char *save_reason);
 void pick_random_player_name(const struct nation_type *pnation,
 			     char *newname);
-void send_all_info(struct conn_list *dest);
+void send_all_info(struct conn_list *dest, bool force);
 
 void identity_number_release(int id);
 void identity_number_reserve(int id);
diff -Nurd -X.diff_ignore freeciv/server/stdinhand.c freeciv/server/stdinhand.c
--- freeciv/server/stdinhand.c	2009-01-29 13:44:59.000000000 +0200
+++ freeciv/server/stdinhand.c	2009-05-04 14:46:36.000000000 +0300
@@ -2900,7 +2900,7 @@
 
   if (S_S_RUNNING == server_state()) {
     send_packet_freeze_hint(pconn);
-    send_all_info(pconn->self);
+    send_all_info(pconn->self, TRUE);
     send_diplomatic_meetings(pconn);
     send_packet_thaw_hint(pconn);
     dsend_packet_start_phase(pconn, game.info.phase);
@@ -3136,7 +3136,7 @@
 
   if (S_S_RUNNING == server_state()) {
     send_packet_freeze_hint(pconn);
-    send_all_info(pconn->self);
+    send_all_info(pconn->self, TRUE);
     send_diplomatic_meetings(pconn);
     send_packet_thaw_hint(pconn);
     dsend_packet_start_phase(pconn, game.info.phase);
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in	2009-05-03 18:59:38.000000000 +0300
+++ freeciv/version.in	2009-05-04 14:56:00.000000000 +0300
@@ -23,5 +23,5 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel.2009.May.01"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel.2009.May.04"
 NETWORK_CAPSTRING_OPTIONAL=""
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to