From 27d7a80f20f3a9cc1872628ed129f59371599757 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 6 Aug 2022 04:25:30 +0300 Subject: [PATCH 39/39] Stop cancelling "No Contact" to war See osdn #45124 Signed-off-by: Marko Lindqvist --- common/player.c | 13 +++++++++---- server/plrhand.c | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common/player.c b/common/player.c index 05b8cbf2db..9f9e66d080 100644 --- a/common/player.c +++ b/common/player.c @@ -67,7 +67,6 @@ static void player_diplstate_destroy(const struct player *plr1, enum diplstate_type cancel_pact_result(enum diplstate_type oldstate) { switch (oldstate) { - case DS_NO_CONTACT: /* possible if someone declares war on our ally */ case DS_WAR: /* no change */ case DS_ARMISTICE: case DS_CEASEFIRE: @@ -77,10 +76,16 @@ enum diplstate_type cancel_pact_result(enum diplstate_type oldstate) return DS_ARMISTICE; case DS_TEAM: /* no change */ return DS_TEAM; - default: - log_error("non-pact diplstate %d in cancel_pact_result", oldstate); - return DS_WAR; /* arbitrary */ + case DS_NO_CONTACT: /* Possible if someone declares war on our ally */ + return DS_NO_CONTACT; /* Can't cancel lack of contact */ + case DS_LAST: + fc_assert(oldstate != DS_LAST); + return DS_WAR; /* Arbitrary */ } + + fc_assert(FALSE); + + return DS_WAR; /* Arbitrary */ } /*******************************************************************//** diff --git a/server/plrhand.c b/server/plrhand.c index ed13ffea59..82b2ae48be 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -909,6 +909,11 @@ void handle_diplomacy_cancel_pact(struct player *pplayer, /* check what the new status will be */ new_type = cancel_pact_result(old_type); + if (new_type == old_type) { + /* No change */ + return; + } + ds_plrplr2 = player_diplstate_get(pplayer, pplayer2); ds_plr2plr = player_diplstate_get(pplayer2, pplayer); -- 2.35.1