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

 Use player_set_nation() instead of just setting player->nation. This
should help keeping player->nation and nation->player consistent.
Inconsistency means that new players created by civil war may get same
nation than somebody already in the game.

 This patch is not enough, however. Sanity check still fails.


 - ML

diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c	2007-03-14 17:53:41.000000000 +0200
+++ freeciv/server/savegame.c	2007-03-15 14:23:48.000000000 +0200
@@ -1886,6 +1886,7 @@
   int id;
   struct team *pteam;
   struct player_research *research;
+  struct nation_type *pnation;
 
   /* not all players have teams */
   id = secfile_lookup_int_default(file, -1, "player%d.team_no", plrno);
@@ -1942,7 +1943,13 @@
       p = "";
     }
   }
-  plr->nation = find_nation_by_name_orig(p);
+  pnation = find_nation_by_name_orig(p);
+
+  if (pnation != NO_NATION_SELECTED) {
+    player_set_nation(plr, pnation);
+  } else {
+    plr->nation = NO_NATION_SELECTED;
+  }
   /* Nation may be unselected at this point; we check for this later and
    * reassign nations to players who don't have them. */
 
@@ -1956,10 +1963,11 @@
    * calling is_barbarian() and is_land_barbarian() */
   if (is_barbarian(plr) && plr->nation == NO_NATION_SELECTED) {
     if (is_land_barbarian(plr)) {
-      plr->nation = pick_a_nation(NULL, FALSE, TRUE, LAND_BARBARIAN);
+      pnation = pick_a_nation(NULL, FALSE, TRUE, LAND_BARBARIAN);
     } else {
-      plr->nation = pick_a_nation(NULL, FALSE, TRUE, SEA_BARBARIAN);
+      pnation = pick_a_nation(NULL, FALSE, TRUE, SEA_BARBARIAN);
     }
+    player_set_nation(plr, pnation);
   }
 
   /* government */
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to