From 89d5f7ae3bc4021c924111767b2006f5a9e03ab5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 22 Apr 2023 16:09:33 +0300 Subject: [PATCH 22/22] Savegame: Silence "unused entry" warnings about gamestart values Those were unnecessarily saved before freeciv-3.2, so warnings ignored when loading such savegames. See osdn #47670 Signed-off-by: Marko Lindqvist --- server/savegame/savecompat.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index dec392759e..3c971e6dd5 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -2034,6 +2034,13 @@ static void compat_load_030200(struct loaddata *loading, secfile_replace_str(loading->file, name, "settings.set%d.name", i); } + if (!gamestart_valid) { + /* Older savegames saved these values even when they were not valid. + * Silence warnings caused by them. */ + (void) secfile_entry_lookup(loading->file, "settings.set%d.gamestart", i); + (void) secfile_entry_lookup(loading->file, "settings.set%d.gamesetdef", i); + } + if (!fc_strcasecmp("compresstype", name)) { const char *val = secfile_lookup_str(loading->file, "settings.set%d.value", i); @@ -2172,7 +2179,7 @@ static void compat_load_030200(struct loaddata *loading, || !secfile_lookup_bool(loading->file, &alltemperate, "settings.set%d.value", alltemperate_idx)) { - /* infer what would've been the ruleset default */ + /* Infer what would've been the ruleset default */ alltemperate = (wld.map.north_latitude == wld.map.south_latitude); } @@ -2180,7 +2187,7 @@ static void compat_load_030200(struct loaddata *loading, || !secfile_lookup_bool(loading->file, &singlepole, "settings.set%d.value", singlepole_idx)) { - /* infer what would've been the ruleset default */ + /* Infer what would've been the ruleset default */ singlepole = (wld.map.south_latitude >= 0); } @@ -2985,6 +2992,30 @@ static void compat_load_dev(struct loaddata *loading) } } + /* Server setting migration. */ + { + int set_count; + + if (secfile_lookup_int(loading->file, &set_count, "settings.set_count")) { + bool gamestart_valid = FALSE; + + gamestart_valid + = secfile_lookup_bool_default(loading->file, FALSE, + "settings.gamestart_valid"); + + if (!gamestart_valid) { + int i; + + /* Older savegames saved gamestart values even when they were not valid. + * Silence warnings caused by them. */ + for (i = 0; i < set_count; i++) { + (void) secfile_entry_lookup(loading->file, "settings.set%d.gamestart", i); + (void) secfile_entry_lookup(loading->file, "settings.set%d.gamesetdef", i); + } + } + } + } + } /* Version < 3.1.94 */ #endif /* FREECIV_DEV_SAVE_COMPAT_3_2 */ -- 2.39.2