From 3dfe7d09e1c7c23787df938222b5f7ebea524c1a Mon Sep 17 00:00:00 2001 From: ZombieFreak115 Date: Sat, 1 Feb 2025 22:58:06 +0100 Subject: [PATCH] rewrite the rebels section in is_attacker_in_battle to work with multiple countries fighting rebels --- src/military/military.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/military/military.cpp b/src/military/military.cpp index 82e830fc1..892753c4c 100644 --- a/src/military/military.cpp +++ b/src/military/military.cpp @@ -4873,9 +4873,9 @@ bool is_attacker_in_battle(sys::state& state, dcon::army_id a) { auto lead_attacker = get_land_battle_lead_attacker(state, battle); auto lead_defender = get_land_battle_lead_defender(state, battle); auto thisnation = state.world.army_get_controller_from_army_control(a); + bool war_attacker = state.world.land_battle_get_war_attacker_is_attacker(battle); // country vs country if(lead_attacker && lead_defender) { - bool war_attacker = state.world.land_battle_get_war_attacker_is_attacker(battle); for(const auto par : state.world.nation_get_war_participant(thisnation)) { if((par.get_is_attacker() && war_attacker) || (!par.get_is_attacker() && !war_attacker)) { return true; @@ -4888,13 +4888,13 @@ bool is_attacker_in_battle(sys::state& state, dcon::army_id a) { } // country vs rebels else { - // if the "this" nation is not rebels - if(thisnation) { - return lead_attacker == thisnation; + // if the "this" nation is the rebels, and they are attacking + if(!thisnation) { + return war_attacker; } - // if the "this" nation is rebels + // if the "this" nation is not rebels else { - return lead_defender == thisnation; + return !war_attacker; } } }