Author: cazfi Date: Tue Oct 13 18:12:07 2015 New Revision: 30063 URL: http://svn.gna.org/viewcvs/freeciv?rev=30063&view=rev Log: Load ruleset data before compatibility conversion from an older savegame2.c savegame.
See bug #23929 Modified: branches/S2_6/server/savecompat.c branches/S2_6/server/savegame2.c Modified: branches/S2_6/server/savecompat.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savecompat.c?rev=30063&r1=30062&r2=30063&view=diff ============================================================================== --- branches/S2_6/server/savecompat.c (original) +++ branches/S2_6/server/savecompat.c Tue Oct 13 18:12:07 2015 @@ -885,7 +885,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: branches/S2_6/server/savegame2.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame2.c?rev=30063&r1=30062&r2=30063&view=diff ============================================================================== --- branches/S2_6/server/savegame2.c (original) +++ branches/S2_6/server/savegame2.c Tue Oct 13 18:12:07 2015 @@ -356,6 +356,7 @@ static void technology_save(struct section_file *file, const char* path, int plrno, Tech_type_id tech); +static void sg_load_ruleset(struct loaddata *loading); static void sg_load_savefile(struct loaddata *loading); static void sg_save_savefile(struct savedata *saving); static void sg_save_savefile_options(struct savedata *saving, @@ -544,6 +545,8 @@ sg_success = TRUE; /* Load the savegame data. */ + /* Set up correct ruleset */ + sg_load_ruleset(loading); /* [compat] */ sg_load_compat(loading); /* [savefile] */ @@ -1530,22 +1533,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, "classic", @@ -1555,8 +1546,26 @@ } if (!load_rulesets(NULL, 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