From 66ee0412bb41dc144075700f675689c6a9bde13a Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 7 Apr 2023 20:02:24 +0300 Subject: [PATCH 19/19] Savegame: Do not save invalid gamestart values See osdn #47793 Signed-off-by: Marko Lindqvist --- server/settings.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/server/settings.c b/server/settings.c index 2fd58bc14d..80b24482d9 100644 --- a/server/settings.c +++ b/server/settings.c @@ -4499,49 +4499,63 @@ 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; } set_count++; -- 2.39.2