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

On 3/15/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  Use player_set_nation() instead of just setting player->nation. This
> should help keeping player->nation and nation->player consistent.

 S2_1 version.


 - ML

diff -Nurd -X.diff_ignore freeciv/common/player.c freeciv/common/player.c
--- freeciv/common/player.c	2007-03-05 19:14:29.000000000 +0200
+++ freeciv/common/player.c	2007-03-16 19:31:29.000000000 +0200
@@ -235,6 +235,9 @@
       pplayer->nation->player = NULL;
     }
     if (pnation) {
+      /* Note that both barbarian players use same nation.
+       * For barbarian nations nation->player points essentially to
+       * random player */
       pnation->player = pplayer;
     }
     pplayer->nation = pnation;
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c	2007-03-10 23:18:01.000000000 +0200
+++ freeciv/server/savegame.c	2007-03-16 19:27:06.000000000 +0200
@@ -1850,6 +1850,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);
@@ -1906,7 +1907,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. */
 
@@ -1917,7 +1924,8 @@
    * give_initial_techs will crash if the nation is unset. */
 
   if (is_barbarian(plr) && plr->nation == NO_NATION_SELECTED) {
-    plr->nation = pick_barbarian_nation();
+    pnation = pick_barbarian_nation();
+    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