Re: [Freeciv-Dev] (PR#39707) [Patch] Remove duplicate player->nation zeroing

2007-09-22 Thread Marko Lindqvist

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.0 +0300
+++ freeciv/client/packhand.c	2007-09-23 01:54:00.0 +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.0 +0300
+++ freeciv/client/packhand.c	2007-09-23 01:55:52.0 +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


Re: [Freeciv-Dev] (PR#39707) [Patch] Remove duplicate player->nation zeroing

2007-09-19 Thread Marko Lindqvist

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.
>
>  To be committed to S2_2 and trunk.

 - Fixed compiler warning


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-09-14 14:52:09.0 +0300
+++ freeciv/client/packhand.c	2007-09-19 13:55:57.0 +0300
@@ -2190,8 +2190,6 @@
 **/
 void handle_ruleset_control(struct packet_ruleset_control *packet)
 {
-  int i;
-
   ruleset_data_free();
 
   ruleset_cache_init();
@@ -2226,12 +2224,6 @@
   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 */
-  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) {
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39707) [Patch] Remove duplicate player->nation zeroing

2007-09-14 Thread Marko Lindqvist

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

 Seems that trunk already had proper player->nation zeroing before
S2_1 bugfix was ported.

 To be committed to S2_2 and trunk.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-09-14 15:13:54.0 +0300
+++ freeciv/client/packhand.c	2007-09-14 21:49:05.0 +0300
@@ -2218,12 +2218,6 @@
   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 */
-  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) {
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev