From 9c71bdf28fed85e6d0608ca809343f8ac5043df5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 3 Jul 2022 21:01:46 +0300 Subject: [PATCH 30/30] AI: Do not revolt to get rid of Senate if Anarchy has Senate See osdn #44847 Signed-off-by: Marko Lindqvist --- ai/default/daidiplomacy.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/ai/default/daidiplomacy.c b/ai/default/daidiplomacy.c index 63f8bb1cdc..2c0645e13d 100644 --- a/ai/default/daidiplomacy.c +++ b/ai/default/daidiplomacy.c @@ -1273,7 +1273,7 @@ static void dai_share(struct ai_type *ait, struct player *pplayer, } /********************************************************************** - Go to war. Explain to target why we did it, and set countdown to + Go to war. Explain to target why we did it, and set countdown to some negative value to make us a bit stubborn to avoid immediate reversal to ceasefire. ***********************************************************************/ @@ -1287,7 +1287,7 @@ static void dai_go_to_war(struct ai_type *ait, struct player *pplayer, switch (reason) { case DAI_WR_SPACE: - dai_diplo_notify(target, _("*%s (AI)* Space will never be yours. "), + dai_diplo_notify(target, _("*%s (AI)* Space will never be yours."), player_name(pplayer)); adip->countdown = -10; break; @@ -1342,17 +1342,33 @@ static void dai_go_to_war(struct ai_type *ait, struct player *pplayer, remove_shared_vision(pplayer, target); } - /* Check for Senate obstruction. If so, dissolve it. */ + /* Check for Senate obstruction. If so, dissolve it. */ if (pplayer_can_cancel_treaty(pplayer, target) == DIPL_SENATE_BLOCKING) { - handle_player_change_government(pplayer, - game.info.government_during_revolution_id); + struct government *real_gov = pplayer->government; + + pplayer->government = game.government_during_revolution; + + if (pplayer_can_cancel_treaty(pplayer, target) == DIPL_OK) { + /* It seems that revolution would help. */ + pplayer->government = real_gov; + handle_player_change_government(pplayer, + game.info.government_during_revolution_id); + } else { + /* There would be Senate even during revolution. Better not to revolt for nothing */ + pplayer->government = real_gov; + + DIPLO_LOG(ait, LOG_DEBUG, pplayer, target, + "Not revolting, as there would be Senate regardless."); + + return; + } } /* This will take us straight to war. */ while (player_diplstate_get(pplayer, target)->type != DS_WAR) { if (pplayer_can_cancel_treaty(pplayer, target) != DIPL_OK) { - DIPLO_LOG(ait, LOG_ERROR, pplayer, target, "Wanted to cancel treaty but " - "was unable to."); + DIPLO_LOG(ait, LOG_ERROR, pplayer, target, + "Wanted to cancel treaty but was unable to."); return; } handle_diplomacy_cancel_pact(pplayer, player_number(target), clause_type_invalid()); -- 2.35.1