From 647bb72a88e036239b4f4fd03eccc00b18a4c6c2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 1 Apr 2023 08:53:18 +0300 Subject: [PATCH 26/26] savecompat: Do not insert orders_max_length to savegame2 saves See osdn #47726 Signed-off-by: Marko Lindqvist --- server/savegame/savecompat.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index 8b3cdbfda9..b389ea938b 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -2281,10 +2281,9 @@ static void compat_load_030200(struct loaddata *loading, { player_slots_iterate(pslot) { int plrno = player_slot_index(pslot); - int ncities, nunits; - int cnro, unro; + int ncities; + int cnro; size_t wlist_max_length = 0; - size_t olist_max_length = 0; if (secfile_section_lookup(loading->file, "player%d", plrno) == NULL) { continue; @@ -2304,21 +2303,25 @@ static void compat_load_030200(struct loaddata *loading, secfile_insert_int(loading->file, wlist_max_length, "player%d.wl_max_length", plrno); - nunits = secfile_lookup_int_default(loading->file, 0, - "player%d.nunits", plrno); + if (format_class == SAVEGAME_3) { + int nunits; + int unro; + size_t olist_max_length = 0; - for (unro = 0; unro < nunits; unro++) { - int ol_length = secfile_lookup_int_default(loading->file, 0, - "player%d.u%d.orders_length", - plrno, unro); + nunits = secfile_lookup_int_default(loading->file, 0, + "player%d.nunits", plrno); - olist_max_length = MAX(olist_max_length, ol_length); - } + for (unro = 0; unro < nunits; unro++) { + int ol_length = secfile_lookup_int_default(loading->file, 0, + "player%d.u%d.orders_length", + plrno, unro); - secfile_insert_int(loading->file, olist_max_length, - "player%d.orders_max_length", plrno); + olist_max_length = MAX(olist_max_length, ol_length); + } + + secfile_insert_int(loading->file, olist_max_length, + "player%d.orders_max_length", plrno); - if (format_class == SAVEGAME_3) { secfile_insert_int(loading->file, MAX_TRADE_ROUTES_OLD, "player%d.routes_max_length", plrno); } -- 2.39.2