From b51395ea3458a18f6b749e6e2b90602c44f654e1 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 12 Jun 2022 03:20:27 +0300 Subject: [PATCH 19/19] Set diplstate max_state on first contact See osdn #44759 Signed-off-by: Marko Lindqvist --- server/diplhand.c | 23 +++++++++++++++++++---- server/diplhand.h | 4 ++++ server/plrhand.c | 3 +-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/server/diplhand.c b/server/diplhand.c index d774d87da2..19a4ededed 100644 --- a/server/diplhand.c +++ b/server/diplhand.c @@ -154,12 +154,27 @@ static enum diplstate_type dst_closest(enum diplstate_type a, } /************************************************************************** -pplayer clicked the accept button. If he accepted the treaty we check the -clauses. If both players have now accepted the treaty we execute the agreed -clauses. + 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 + agreed clauses. **************************************************************************/ void handle_diplomacy_accept_treaty_req(struct player *pplayer, - int counterpart) + int counterpart) { struct Treaty *ptreaty; bool *player_accept, *other_accept; 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 90914dd0ad..5d3b9bb567 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -2071,8 +2071,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