Project

General

Profile

Bug #2400 » 0061-AI-Fix-declaring-war-on-multiple-targets-after-senat.patch

main - Marko Lindqvist, 11/08/2026 05:35 AM

View differences:

ai/default/daidata.h
char love_incr; /* Modify love with this fixed amount */
int req_love_for_peace;
int req_love_for_alliance;
struct player *war_target;
} diplomacy;
/* Cache map for AI settlers; defined in daisettler.c. */
ai/default/daidiplomacy.c
pplayer->government = real_gov;
handle_player_change_government(pplayer,
game.info.government_during_revolution_id);
def_ai_player_data(pplayer, ait)->diplomacy.war_target = target;
return;
} else {
/* There would be Senate even during revolution. Better not to revolt for nothing */
......
**********************************************************************/
void dai_revolution_start(struct ai_type *ait, struct player *pplayer)
{
struct ai_plr *data = def_ai_player_data(pplayer, ait);
if (data->diplomacy.war_target != nullptr) {
/* Target might have died since it was set. */
if (data->diplomacy.war_target->is_alive) {
if (gives_shared_vision(pplayer, data->diplomacy.war_target)) {
remove_shared_vision(pplayer, data->diplomacy.war_target);
players_iterate_alive(opponent) {
struct ai_dip_intel *adip = dai_diplomacy_get(ait, pplayer, opponent);
if (adip->countdown < -1 && !pplayers_at_war(pplayer, opponent)) {
/* We were waiting for opportunity to declare war without
* the senate intervening. */
if (gives_shared_vision(pplayer, opponent)) {
remove_shared_vision(pplayer, opponent);
}
dai_declare_war(ait, pplayer, data->diplomacy.war_target);
dai_declare_war(ait, pplayer, opponent);
}
data->diplomacy.war_target = nullptr;
}
} players_iterate_alive_end;
}
/******************************************************************//**
ai/default/daisanity.c
#define SANITY_CHECK(check) \
fc_assert_full(__FILE__, __FUNCTION__, __FC_LINE__, check, , NOLOGMSG, NOLOGMSG)
struct player *wt;
#if 0
if (!pplayer->is_alive) {
return;
}
wt = def_ai_player_data(pplayer, ait)->diplomacy.war_target;
players_iterate_alive(opponent) {
struct ai_dip_intel *adip = dai_diplomacy_get(ait, pplayer, opponent);
bool at_war = pplayers_at_war(pplayer, opponent);
bool war_target = (wt == opponent);
/* SANITY_CHECK(adip->countdown < 0 || !at_war); */
SANITY_CHECK(adip->countdown >= -1 || at_war || war_target);
/* It's ok for countdown to show war, but player being only in the process
* of dissolving the senate and declaring the war after that.
* Countdown is actually the trigger that causes the war declaration
* in that case. */
/* SANITY_CHECK(adip->countdown >= -1 || at_war); */
} players_iterate_alive_end;
#endif
#endif /* SANITY_CHECKING */
}
(1-1/2)