Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] Re: (PR#3621) Freeciv 1.14.0 Changes Nations in Saved Game
Home

[Freeciv-Dev] Re: (PR#3621) Freeciv 1.14.0 Changes Nations in Saved Game

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jared.Blackburn@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3621) Freeciv 1.14.0 Changes Nations in Saved Games
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 31 Mar 2003 10:40:20 -0800
Reply-to: rt@xxxxxxxxxxxxxx


Raimar Falke wrote:

> On Sat, Mar 29, 2003 at 06:56:52PM -0800, Mike Kaufman wrote:
> 
>>On Sat, Mar 29, 2003 at 03:36:16PM -0800, Raimar Falke wrote:
>>
>>>Save a game with 1.14.0 and load it with the CVS version. Since the
>>>savegame only contains the nation ids and these got reordered you end
>>>up with different nations.
>>>
>>even with this supposition, I cannot reproduce. You have reproduced this?
>>Note that this was added on Jan 29th to savegame.c:
>>
>> /* 1.15 and later versions store nations by name.  Try that first. */
>>  p = secfile_lookup_str_default(file, NULL, "player%d.nation", plrno);
>>  if (!p) {
>>    /*
>>     * Otherwise read as a pre-1.15 savefile with numeric nation indexes.
>>     * This random-looking order is from the old nations/ruleset file.
>>     * Use it to convert old-style nation indices to name strings.
>>     * The idea is not to be dependent on the order in which nations 
>>     * get read into the registry.
>>     */
>>    const char *name_order[] = {
>>      "roman", "babylonian", "german", "egyptian", "american", "greek",
>>      "indian", "russian", "zulu", "french", "aztec", "chinese", "english",
>>      "mongol", "turk", "spanish", "persian", "arab", "carthaginian", "inca",
>>      "viking", "polish", "hungarian", "danish", "dutch", "swedish",
>>      "japanese", "portuguese", "finnish", "sioux", "czech", "australian",
>>      "welsh", "korean", "scottish", "israeli", "argentine", "canadian",
>>      "ukrainian", "lithuanian", "kenyan", "dunedain", "vietnamese", "thai",
>>      "mordor", "bavarian", "brazilian", "irish", "cornish", "italian",
>>      "filipino", "estonian", "latvian", "boer", "silesian", "singaporean",
>>      "chilean", "catalan", "croatian", "slovenian", "serbian", "barbarian",
>>    };
>>    p = (char *)name_order[secfile_lookup_int(file, "player%d.race", plrno)];
>>  }
>>  plr->nation = find_nation_by_name_orig(p);
>>
> 
> I missed this completely.
> 
> Ok these leaves two smaller problems:
>  - using an unknown value as an array index in the code above
>  - loading a new savegame with an old server. ESR also noted this in
>  his comment:
>      Savefiles written by the new savegame() may even be readable by
>      older versions, because the numeric index is still saved as
>      "race".  The nation assignments in the resulting save may be
>      scrambled when reread, though.


There is another situation that can lead to scrambling: loading a 
savegame from an older version of freeciv that was originally played 
with a different set of nations.  This could happen with pre-1.14 
freeciv savegames (presumably new nations were added at some point) or 
any freeciv where nation rulesets were added/removed.


In other words, the hard-coding of the ordering of the nations in 
savegame.c assumes that data/xxx/nations.ruleset has the same ordering. 
  This is bad, although probably unavoidable.

jason




[Prev in Thread] Current Thread [Next in Thread]