From f4af7acc8a5c6369e0dcdcd2fc18a3b7bb7a7c6f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 9 Oct 2021 07:30:07 +0300 Subject: [PATCH 43/43] Savecompat: Add setting gamesetdef values when updating from < 3.1 See osdn #42985 Signed-off-by: Marko Lindqvist --- server/savegame/savecompat.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index 9b5d072f99..4770c85ed1 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -1558,6 +1558,33 @@ static void compat_load_030100(struct loaddata *loading, } } player_slots_iterate_end; + /* Server setting migration. */ + { + int set_count; + + if (secfile_lookup_int(loading->file, &set_count, "settings.set_count")) { + int i; + bool gamestart_valid + = secfile_lookup_bool_default(loading->file, FALSE, + "settings.gamestart_valid"); + + /* Only add gamesetdef if gamestart is valid at all */ + if (gamestart_valid) { + for (i = 0; i < set_count; i++) { + const char *name + = secfile_lookup_str(loading->file, "settings.set%d.name", i); + + if (!name) { + continue; + } + + secfile_insert_str(loading->file, setting_default_level_name(SETDEF_CHANGED), + "settings.set%d.gamesetdef", i); + } + } + } + } + /* Explicit server side agent was new in 3.1 */ insert_server_side_agent(loading, format_class); } -- 2.33.0