From 22bbe858c317c935fe34297ce4720f9561bca2a5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 12 Jun 2022 03:16:51 +0300 Subject: [PATCH 25/25] Set diplstate max_state on first contact See osdn #44759 Signed-off-by: Marko Lindqvist --- server/diplhand.c | 15 +++++++++++++++ server/diplhand.h | 4 ++++ server/plrhand.c | 3 +-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/server/diplhand.c b/server/diplhand.c index 16f98892f5..7dee35342a 100644 --- a/server/diplhand.c +++ b/server/diplhand.c @@ -153,6 +153,21 @@ static enum diplstate_type dst_closest(enum diplstate_type a, } } +/**********************************************************************//** + Set diplstate between two players. +**************************************************************************/ +void set_diplstate_type(struct player_diplstate *state1, + struct player_diplstate *state2, + enum diplstate_type type) +{ + enum diplstate_type max = dst_closest(type, state1->max_state); + + state1->type = type; + state2->type = type; + state1->max_state = max; + state2->max_state = max; +} + /**********************************************************************//** pplayer clicked the accept button. If they accepted the treaty we check the clauses. If both players have now accepted the treaty we execute the diff --git a/server/diplhand.h b/server/diplhand.h index 38ed9e4ac0..e8476ad023 100644 --- a/server/diplhand.h +++ b/server/diplhand.h @@ -43,4 +43,8 @@ void reject_all_treaties(struct player *pplayer); struct treaty_list *get_all_treaties(void); +void set_diplstate_type(struct player_diplstate *state1, + struct player_diplstate *state2, + enum diplstate_type type); + #endif /* FC__DIPLHAND_H */ diff --git a/server/plrhand.c b/server/plrhand.c index c80a514292..1de7a61162 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -2140,8 +2140,7 @@ void make_contact(struct player *pplayer1, struct player *pplayer2, enum diplstate_type new_state = get_default_diplstate(pplayer1, pplayer2); - ds_plr1plr2->type = new_state; - ds_plr2plr1->type = new_state; + set_diplstate_type(ds_plr1plr2, ds_plr2plr1, new_state); ds_plr1plr2->first_contact_turn = game.info.turn; ds_plr2plr1->first_contact_turn = game.info.turn; notify_player(pplayer1, ptile, E_FIRST_CONTACT, ftc_server, -- 2.35.1