From 7504914519a98946e2e1cdde2060c087c8c3ebf5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 21 Aug 2022 07:50:31 +0300 Subject: [PATCH 34/34] Cancel invalid war from old savegames See osdn #45345 Signed-off-by: Marko Lindqvist --- server/savegame/savegame2.c | 6 ++++++ server/savegame/savegame3.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c index be690ba8cd..f11c8d035d 100644 --- a/server/savegame/savegame2.c +++ b/server/savegame/savegame2.c @@ -2887,6 +2887,12 @@ static void sg_load_player_main(struct loaddata *loading, ds->max_state = DS_WAR; } + if (ds->type == DS_WAR && ds->first_contact_turn <= 0) { + sg_regr(03020000, + "Player%d: War with player %d who has never been met. " + "Reverted to No Contact state.", plrno, i); + ds->type = DS_NO_CONTACT; + } ds->first_contact_turn = secfile_lookup_int_default(loading->file, 0, diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c index e76a77a529..2e142f0276 100644 --- a/server/savegame/savegame3.c +++ b/server/savegame/savegame3.c @@ -4067,6 +4067,14 @@ static void sg_load_player_main(struct loaddata *loading, ds->max_state = secfile_lookup_enum_default(loading->file, DS_WAR, diplstate_type, "%s.closest", buf); + + if (ds->type == DS_WAR && ds->first_contact_turn <= 0) { + sg_regr(03020000, + "Player%d: War with player %d who has never been met. " + "Reverted to No Contact state.", plrno, i); + ds->type = DS_NO_CONTACT; + } + ds->first_contact_turn = secfile_lookup_int_default(loading->file, 0, "%s.first_contact_turn", buf); -- 2.35.1