Bug #2451 » 0001-ai-default-Look-the-bodyguard-up-again-after-da-S3_2.patch
| ai/default/aitools.c | ||
|---|---|---|
|
struct unit *ptrans;
|
||
|
struct unit *bodyguard = aiguard_guard_of(ait, punit);
|
||
|
int sanity = punit->id;
|
||
|
int guard_id = (bodyguard != NULL) ? 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) != NULL);
|
||
|
/* 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) : NULL;
|
||
|
if (alive && same_pos(ptile, unit_tile(punit))
|
||
|
&& bodyguard != NULL && def_ai_unit_data(bodyguard, ait)->charge == punit->id) {
|
||