From 9cc4046acb32721f630c07d2e68c8ccdba5c6ccf Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 7 Apr 2023 19:45:02 +0300 Subject: [PATCH 26/26] Savegame: Do not save invalid gamestart values See osdn #47793 Signed-off-by: Marko Lindqvist --- server/settings.c | 48 +++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/server/settings.c b/server/settings.c index d3aa0826b3..2984008ecf 100644 --- a/server/settings.c +++ b/server/settings.c @@ -4825,53 +4825,69 @@ void settings_game_save(struct section_file *file, const char *section) /* It must be same at loading time as it was saving time, even if * freeciv's default has changed. */ || !setting_is_free_to_change(pset, errbuf, sizeof(errbuf))) { + bool gamestart = game.server.settings_gamestart_valid; + secfile_insert_str(file, setting_name(pset), "%s.set%d.name", section, set_count); switch (setting_type(pset)) { case SST_BOOL: secfile_insert_bool(file, *pset->boolean.pvalue, "%s.set%d.value", section, set_count); - secfile_insert_bool(file, pset->boolean.game_value, - "%s.set%d.gamestart", section, set_count); + if (gamestart) { + secfile_insert_bool(file, pset->boolean.game_value, + "%s.set%d.gamestart", section, set_count); + } break; case SST_INT: secfile_insert_int(file, *pset->integer.pvalue, "%s.set%d.value", section, set_count); - secfile_insert_int(file, pset->integer.game_value, - "%s.set%d.gamestart", section, set_count); + if (gamestart) { + secfile_insert_int(file, pset->integer.game_value, + "%s.set%d.gamestart", section, set_count); + } break; case SST_STRING: secfile_insert_str(file, pset->string.value, "%s.set%d.value", section, set_count); - secfile_insert_str(file, pset->string.game_value, - "%s.set%d.gamestart", section, set_count); + if (gamestart) { + secfile_insert_str(file, pset->string.game_value, + "%s.set%d.gamestart", section, set_count); + } break; case SST_ENUM: secfile_insert_enum_data(file, read_enum_value(pset), FALSE, setting_enum_secfile_str, &info, "%s.set%d.value", section, set_count); - secfile_insert_enum_data(file, pset->enumerator.game_value, FALSE, - setting_enum_secfile_str, &info, - "%s.set%d.gamestart", section, set_count); + if (gamestart) { + secfile_insert_enum_data(file, pset->enumerator.game_value, FALSE, + setting_enum_secfile_str, &info, + "%s.set%d.gamestart", section, set_count); + } break; case SST_BITWISE: secfile_insert_enum_data(file, *pset->bitwise.pvalue, TRUE, setting_bitwise_secfile_str, &info, "%s.set%d.value", section, set_count); - secfile_insert_enum_data(file, pset->bitwise.game_value, TRUE, - setting_bitwise_secfile_str, &info, - "%s.set%d.gamestart", section, set_count); + if (gamestart) { + secfile_insert_enum_data(file, pset->bitwise.game_value, TRUE, + setting_bitwise_secfile_str, &info, + "%s.set%d.gamestart", section, set_count); + } break; case SST_COUNT: fc_assert(setting_type(pset) != SST_COUNT); secfile_insert_str(file, "Unknown setting type", "%s.set%d.value", section, set_count); - secfile_insert_str(file, "Unknown setting type", - "%s.set%d.gamestart", section, set_count); + if (gamestart) { + secfile_insert_str(file, "Unknown setting type", + "%s.set%d.gamestart", section, set_count); + } break; } - secfile_insert_str(file, setting_default_level_name(pset->game_setdef), - "%s.set%d.gamesetdef", section, set_count); + if (gamestart) { + secfile_insert_str(file, setting_default_level_name(pset->game_setdef), + "%s.set%d.gamesetdef", section, set_count); + } set_count++; } } settings_iterate_end; -- 2.39.2