Project

General

Profile

Bug #2451 » 0001-ai-default-Look-the-bodyguard-up-again-after-dai_uni.patch

Sweet Tea Dorminy, 11/08/2026 02:51 AM

View differences:

ai/default/daitools.c
struct unit *ptrans;
struct unit *bodyguard = aiguard_guard_of(ait, punit);
int sanity = punit->id;
int guard_id = (bodyguard != nullptr) ? bodyguard->id : 0;
bool alive;
struct city *tcity;
const struct civ_map *nmap = &(wld.map);
......
0, "", ACTION_UNIT_MOVE3);
}
alive = (game_unit_by_number(sanity) != nullptr);
/* The action can remove the bodyguard too: capturing a capital starts
* a civil war, and the stack resolution against the new player wipes
* units standing beside the attacker. Look the guard up again rather
* than trusting the pointer read before the action. */
bodyguard = (guard_id > 0) ? game_unit_by_number(guard_id) : nullptr;
if (alive && same_pos(ptile, unit_tile(punit))
&& bodyguard != nullptr
(1-1/3)