45 const struct player *charge_owner =
nullptr;
46 struct unit_ai *charge_data =
nullptr;
50 fc_assert_ret(charge_unit ==
nullptr || charge_city ==
nullptr);
55 }
else if (charge_city) {
59 if (charge_unit && charge_data->
bodyguard != guard->
id) {
61 }
else if (!charge_unit && !charge_city && 0 < guard_data->
charge) {
67 }
else if (charge_owner && charge_owner != guard_owner) {
87 struct unit_ai *guard_data =
nullptr;
95 || (guard_data && BODYGUARD_WANTED <= guard_data->
bodyguard));
99 }
else if (guard &&
unit_owner(guard) != charge_owner) {
116 fc_assert_ret(charge_unit ==
nullptr || charge_city ==
nullptr);
121 }
else if (charge_city) {
297 const struct player *charge_owner =
nullptr;
301 fc_assert_ret(charge_unit ==
nullptr || charge_city ==
nullptr);
305 }
else if (charge_city) {
309 if (!charge_unit && !charge_city && 0 < guard_data->
charge) {
313 if (charge_owner && charge_owner != guard_owner) {
315 "charge transferred, dismiss");
struct unit * aiguard_charge_unit(struct ai_type *ait, struct unit *guard)
Which unit (if any) has a guard been assigned to? Returns nullptr if the unit is not the guard for a ...
void aiguard_clear_charge(struct ai_type *ait, struct unit *guard)
Remove the assignment of a charge to a guard.
void aiguard_request_guard(struct ai_type *ait, struct unit *punit)
Request a (new) bodyguard for the unit.
bool aiguard_has_guard(struct ai_type *ait, struct unit *charge)
Has a guard been assigned to a charge?
void aiguard_assign_guard_unit(struct ai_type *ait, struct unit *charge, struct unit *guard)
Assign a bodyguard to a unit.
bool aiguard_wanted(struct ai_type *ait, struct unit *charge)
Has a unit requested a guard and not (yet) been provided with one?
void aiguard_assign_guard_city(struct ai_type *ait, struct city *charge, struct unit *guard)
Assign a guard to a city.
struct city * aiguard_charge_city(struct ai_type *ait, struct unit *guard)
Which city (if any) has a guard been assigned to? Returns nullptr if the unit is not a guard for a ci...
void aiguard_clear_guard(struct ai_type *ait, struct unit *charge)
Remove assignment of bodyguard for a unit.
struct unit * aiguard_guard_of(struct ai_type *ait, struct unit *charge)
Which unit, if any, is the body guard of a unit? Returns nullptr if the unit has not been assigned a ...
bool aiguard_has_charge(struct ai_type *ait, struct unit *guard)
Has a charge unit been assigned to a guard?
void aiguard_update_charge(struct ai_type *ait, struct unit *guard)
Check whether the assignment of a guard is still sane, and fix and problems.
void aiguard_check_charge_unit(struct ai_type *ait, const struct unit *charge)
Do sanity checks on a charge, reporting error messages to the log if necessary.
void aiguard_check_guard(struct ai_type *ait, const struct unit *guard)
Do sanity checks on a guard, reporting error messages to the log if necessary.
#define CHECK_CHARGE_UNIT(ait, charge)
#define CHECK_GUARD(ait, guard)
#define BODYGUARD_LOG(ait, loglevel, punit, msg,...)
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
#define fc_assert_ret(condition)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players can attack each other.
#define UNIT_LOG(_, punit, msg,...)
#define LOGLEVEL_BODYGUARD