Author: cazfi Date: Tue Oct 13 18:11:59 2015 New Revision: 30062 URL: http://svn.gna.org/viewcvs/freeciv?rev=30062&view=rev Log: Load ruleset data before compatibility conversion from an older savegame2.c savegame.
See bug #23929 Modified: trunk/server/savecompat.c trunk/server/savegame2.c Modified: trunk/server/savecompat.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.c?rev=30062&r1=30061&r2=30062&view=diff ============================================================================== --- trunk/server/savecompat.c (original) +++ trunk/server/savecompat.c Tue Oct 13 18:11:59 2015 @@ -927,7 +927,7 @@ int ncities; int i; - ncities = secfile_lookup_int(loading->file, &ncities, "player%d.ncities", plrno); + ncities = secfile_lookup_int_default(loading->file, 0, "player%d.ncities", plrno); for (i = 0; i < ncities; i++) { int k = 0; Modified: trunk/server/savegame2.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=30062&r1=30061&r2=30062&view=diff ============================================================================== --- trunk/server/savegame2.c (original) +++ trunk/server/savegame2.c Tue Oct 13 18:11:59 2015 @@ -309,6 +309,7 @@ static Tech_type_id technology_load(struct section_file *file, const char* path, int plrno); +static void sg_load_ruleset(struct loaddata *loading); static void sg_load_savefile(struct loaddata *loading); static void sg_load_game(struct loaddata *loading); @@ -427,6 +428,8 @@ sg_success = TRUE; /* Load the savegame data. */ + /* Set up correct ruleset */ + sg_load_ruleset(loading); /* [compat] */ sg_load_compat(loading); /* [savefile] */ @@ -1092,22 +1095,10 @@ * ======================================================================= */ /**************************************************************************** - Load '[savefile]'. -****************************************************************************/ -static void sg_load_savefile(struct loaddata *loading) -{ - /* Check status and return if not OK (sg_success != TRUE). */ - sg_check_ret(); - - /* Load savefile options. */ - loading->secfile_options - = secfile_lookup_str(loading->file, "savefile.options"); - - /* We don't need these entries, but read them anyway to avoid - * warnings about unread secfile entries. */ - (void) secfile_entry_by_path(loading->file, "savefile.reason"); - (void) secfile_entry_by_path(loading->file, "savefile.revision"); - + Set up correct ruleset for the savegame +****************************************************************************/ +static void sg_load_ruleset(struct loaddata *loading) +{ /* Load ruleset. */ sz_strlcpy(game.server.rulesetdir, secfile_lookup_str_default(loading->file, GAME_DEFAULT_RULESETDIR, @@ -1119,8 +1110,26 @@ } if (!load_rulesets(NULL, FALSE, TRUE, FALSE)) { /* Failed to load correct ruleset */ - sg_failure_ret(TRUE, "Failed to load ruleset"); - } + sg_failure_ret(TRUE, _("Failed to load ruleset")); + } +} + +/**************************************************************************** + Load '[savefile]'. +****************************************************************************/ +static void sg_load_savefile(struct loaddata *loading) +{ + /* Check status and return if not OK (sg_success != TRUE). */ + sg_check_ret(); + + /* Load savefile options. */ + loading->secfile_options + = secfile_lookup_str(loading->file, "savefile.options"); + + /* We don't need these entries, but read them anyway to avoid + * warnings about unread secfile entries. */ + (void) secfile_entry_by_path(loading->file, "savefile.reason"); + (void) secfile_entry_by_path(loading->file, "savefile.revision"); /* Load improvements. */ loading->improvement.size _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits