From 83f1a32461ca55e2df8ab2c04e2fc6f0874e3d7c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 7 Apr 2023 19:57:09 +0300 Subject: [PATCH 28/28] 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 f8d959ab30..955d20f1dd 100644 --- a/server/settings.c +++ b/server/settings.c @@ -4570,53 +4570,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, pset, "%s.set%d.value", section, set_count); - secfile_insert_enum_data(file, pset->enumerator.game_value, FALSE, - setting_enum_secfile_str, pset, - "%s.set%d.gamestart", section, set_count); + if (gamestart) { + secfile_insert_enum_data(file, pset->enumerator.game_value, FALSE, + setting_enum_secfile_str, pset, + "%s.set%d.gamestart", section, set_count); + } break; case SST_BITWISE: secfile_insert_enum_data(file, *pset->bitwise.pvalue, TRUE, setting_bitwise_secfile_str, pset, "%s.set%d.value", section, set_count); - secfile_insert_enum_data(file, pset->bitwise.game_value, TRUE, - setting_bitwise_secfile_str, pset, - "%s.set%d.gamestart", section, set_count); + if (gamestart) { + secfile_insert_enum_data(file, pset->bitwise.game_value, TRUE, + setting_bitwise_secfile_str, pset, + "%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