Re: [Freeciv-Dev] (PR#38193) [Patch] Use player_set_nation() when loading saved game
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.0 +0200 +++ freeciv/common/player.c 2007-03-16 19:31:29.0 +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.0 +0200 +++ freeciv/server/savegame.c 2007-03-16 19:27:06.0 +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
[Freeciv-Dev] (PR#38193) [Patch] Use player_set_nation() when loading saved game
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.0 +0200 +++ freeciv/server/savegame.c 2007-03-15 14:23:48.0 +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