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

On 14/09/2007, Marko Lindqvist  wrote:
>
>  Seems that trunk already had proper player->nation zeroing before
> S2_1 bugfix was ported.

 ...and that one also avoided some problems S2_1 version does not.
Attached patch versions remove new fix, and ports old one to S2_1.

 To be committed tomorrow.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-09-14 15:13:54.000000000 +0300
+++ freeciv/client/packhand.c	2007-09-23 01:54:00.000000000 +0300
@@ -2218,18 +2218,15 @@
   nations_alloc(game.control.nation_count);
   city_styles_alloc(game.control.styles_count);
 
-  /* We are in inconsistent state. Players point to nations,
-   * which do not point to players. Fix */
+  /* After nation ruleset free/alloc, nation->player pointers are NULL.
+   * We have to initialize player->nation too, to keep state consistent.
+   * In case of /taking player, number of players has been reseted, so
+   * we can't use players_iterate() here, but have to go through all
+   * possible player slots instead. */ 
   for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
     game.players[i].nation = NULL;
   }
 
-  /* After nation ruleset free/alloc, nation->player pointers are NULL.
-   * We have to initialize player->nation too, to keep state consistent. */ 
-  players_iterate(pplayer) {
-    pplayer->nation = NO_NATION_SELECTED;
-  } players_iterate_end;
-
   if (packet->prefered_tileset[0] != '\0') {
     /* There is tileset suggestion */
     if (strcmp(packet->prefered_tileset, tileset_get_name(tileset))) {
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-09-01 14:53:26.000000000 +0300
+++ freeciv/client/packhand.c	2007-09-23 01:55:52.000000000 +0300
@@ -2109,6 +2109,8 @@
 **************************************************************************/
 void handle_ruleset_control(struct packet_ruleset_control *packet)
 {
+  int i;
+
   ruleset_data_free();
 
   ruleset_cache_init();
@@ -2119,10 +2121,13 @@
   city_styles_alloc(packet->styles_count);
 
   /* After nation ruleset free/alloc, nation->player pointers are NULL.
-   * We have to initialize player->nation too, to keep state consistent. */ 
-  players_iterate(pplayer) {
-    pplayer->nation = NO_NATION_SELECTED;
-  } players_iterate_end;
+   * We have to initialize player->nation too, to keep state consistent.
+   * In case of /taking player, number of players has been reseted, so
+   * we can't use players_iterate() here, but have to go through all
+   * possible player slots instead. */ 
+  for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
+    game.players[i].nation = NULL;
+  }
 
   if (packet->prefered_tileset[0] != '\0') {
     /* There is tileset suggestion */
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to