Author: cazfi Date: Sat Oct 10 20:06:38 2015 New Revision: 30040 URL: http://svn.gna.org/viewcvs/freeciv?rev=30040&view=rev Log: Always respect scenario.is_scenario savegame property when it's present.
See bug #23912 Modified: trunk/server/savegame2.c trunk/server/savegame3.c Modified: trunk/server/savegame2.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=30040&r1=30039&r2=30040&view=diff ============================================================================== --- trunk/server/savegame2.c (original) +++ trunk/server/savegame2.c Sat Oct 10 20:06:38 2015 @@ -1632,59 +1632,59 @@ sg_check_ret(); if (NULL == secfile_section_lookup(loading->file, "scenario")) { - /* Nothing to do. */ + game.scenario.is_scenario = FALSE; + return; } /* Default is that when there's scenario section (which we already checked) * this is a scenario. Only if it explicitly says that it's not, we consider * this regular savegame */ - if (!secfile_lookup_bool_default(loading->file, TRUE, "scenario.is_scenario")) { + game.scenario.is_scenario = secfile_lookup_bool_default(loading->file, TRUE, "scenario.is_scenario"); + + if (!game.scenario.is_scenario) { return; } buf = secfile_lookup_str_default(loading->file, "", "scenario.name"); if (buf[0] != '\0') { - game.scenario.is_scenario = TRUE; sz_strlcpy(game.scenario.name, buf); - buf = secfile_lookup_str_default(loading->file, "", - "scenario.description"); - if (buf[0] != '\0') { - sz_strlcpy(game.scenario.description, buf); - } else { - game.scenario.description[0] = '\0'; - } - game.scenario.save_random - = secfile_lookup_bool_default(loading->file, FALSE, "scenario.save_random"); - game.scenario.players - = secfile_lookup_bool_default(loading->file, TRUE, "scenario.players"); - game.scenario.startpos_nations - = secfile_lookup_bool_default(loading->file, FALSE, - "scenario.startpos_nations"); - - game.scenario.prevent_new_cities - = secfile_lookup_bool_default(loading->file, FALSE, - "scenario.prevent_new_cities"); - game.scenario.handmade - = secfile_lookup_bool_default(loading->file, FALSE, - "scenario.handmade"); - - sg_failure_ret(loading->server_state == S_S_INITIAL - || (loading->server_state == S_S_RUNNING - && game.scenario.players == TRUE), - "Invalid scenario definition (server state '%s' and " - "players are %s).", - server_states_name(loading->server_state), - game.scenario.players ? "saved" : "not saved"); + } + + buf = secfile_lookup_str_default(loading->file, "", + "scenario.description"); + if (buf[0] != '\0') { + sz_strlcpy(game.scenario.description, buf); } else { - game.scenario.is_scenario = FALSE; - } - - if (game.scenario.is_scenario) { - /* Remove all defined players. They are recreated with the skill level - * defined by the scenario. */ - (void) aifill(0); - } + game.scenario.description[0] = '\0'; + } + + game.scenario.save_random + = secfile_lookup_bool_default(loading->file, FALSE, "scenario.save_random"); + game.scenario.players + = secfile_lookup_bool_default(loading->file, TRUE, "scenario.players"); + game.scenario.startpos_nations + = secfile_lookup_bool_default(loading->file, FALSE, + "scenario.startpos_nations"); + + game.scenario.prevent_new_cities + = secfile_lookup_bool_default(loading->file, FALSE, + "scenario.prevent_new_cities"); + game.scenario.handmade + = secfile_lookup_bool_default(loading->file, FALSE, + "scenario.handmade"); + + sg_failure_ret(loading->server_state == S_S_INITIAL + || (loading->server_state == S_S_RUNNING + && game.scenario.players == TRUE), + "Invalid scenario definition (server state '%s' and " + "players are %s).", + server_states_name(loading->server_state), + game.scenario.players ? "saved" : "not saved"); + + /* Remove all defined players. They are recreated with the skill level + * defined by the scenario. */ + (void) aifill(0); } /* ======================================================================= Modified: trunk/server/savegame3.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=30040&r1=30039&r2=30040&view=diff ============================================================================== --- trunk/server/savegame3.c (original) +++ trunk/server/savegame3.c Sat Oct 10 20:06:38 2015 @@ -2160,62 +2160,60 @@ sg_check_ret(); if (NULL == secfile_section_lookup(loading->file, "scenario")) { - /* Nothing to do. */ + game.scenario.is_scenario = FALSE; + return; } /* Default is that when there's scenario section (which we already checked) * this is a scenario. Only if it explicitly says that it's not, we consider * this regular savegame */ - if (!secfile_lookup_bool_default(loading->file, TRUE, "scenario.is_scenario")) { + game.scenario.is_scenario = secfile_lookup_bool_default(loading->file, TRUE, "scenario.is_scenario"); + if (!game.scenario.is_scenario) { return; } buf = secfile_lookup_str_default(loading->file, "", "scenario.name"); if (buf[0] != '\0') { - game.scenario.is_scenario = TRUE; sz_strlcpy(game.scenario.name, buf); - buf = secfile_lookup_str_default(loading->file, "", - "scenario.description"); - if (buf[0] != '\0') { - sz_strlcpy(game.scenario.description, buf); - } else { - game.scenario.description[0] = '\0'; - } - game.scenario.save_random - = secfile_lookup_bool_default(loading->file, FALSE, "scenario.save_random"); - game.scenario.players - = secfile_lookup_bool_default(loading->file, TRUE, "scenario.players"); - game.scenario.startpos_nations - = secfile_lookup_bool_default(loading->file, FALSE, - "scenario.startpos_nations"); - game.scenario.prevent_new_cities - = secfile_lookup_bool_default(loading->file, FALSE, - "scenario.prevent_new_cities"); - game.scenario.handmade - = secfile_lookup_bool_default(loading->file, FALSE, - "scenario.handmade"); - - game.scenario.ruleset_locked - = secfile_lookup_bool_default(loading->file, TRUE, - "scenario.ruleset_locked"); - - sg_failure_ret(loading->server_state == S_S_INITIAL - || (loading->server_state == S_S_RUNNING - && game.scenario.players == TRUE), - "Invalid scenario definition (server state '%s' and " - "players are %s).", - server_states_name(loading->server_state), - game.scenario.players ? "saved" : "not saved"); + } + + buf = secfile_lookup_str_default(loading->file, "", + "scenario.description"); + if (buf[0] != '\0') { + sz_strlcpy(game.scenario.description, buf); } else { - game.scenario.is_scenario = FALSE; - } - - if (game.scenario.is_scenario) { - /* Remove all defined players. They are recreated with the skill level - * defined by the scenario. */ - (void) aifill(0); - } + game.scenario.description[0] = '\0'; + } + game.scenario.save_random + = secfile_lookup_bool_default(loading->file, FALSE, "scenario.save_random"); + game.scenario.players + = secfile_lookup_bool_default(loading->file, TRUE, "scenario.players"); + game.scenario.startpos_nations + = secfile_lookup_bool_default(loading->file, FALSE, + "scenario.startpos_nations"); + game.scenario.prevent_new_cities + = secfile_lookup_bool_default(loading->file, FALSE, + "scenario.prevent_new_cities"); + game.scenario.handmade + = secfile_lookup_bool_default(loading->file, FALSE, + "scenario.handmade"); + + game.scenario.ruleset_locked + = secfile_lookup_bool_default(loading->file, TRUE, + "scenario.ruleset_locked"); + + sg_failure_ret(loading->server_state == S_S_INITIAL + || (loading->server_state == S_S_RUNNING + && game.scenario.players == TRUE), + "Invalid scenario definition (server state '%s' and " + "players are %s).", + server_states_name(loading->server_state), + game.scenario.players ? "saved" : "not saved"); + + /* Remove all defined players. They are recreated with the skill level + * defined by the scenario. */ + (void) aifill(0); } /**************************************************************************** _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits