Freeciv-3.1: /fast/freeciv/nightly/S3_1/ai/default/aiguard.h File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Macros | Functions
aiguard.h File Reference
`#include "support.h"`
`#include "fc_types.h"`

Go to the source code of this file.

## Macros

#define | CHECK_GUARD(ait, guard) aiguard_check_guard(ait, guard)
#define | CHECK_CHARGE_UNIT(ait, charge) aiguard_check_charge_unit(ait, charge)

## Functions

void | aiguard_check_guard (struct ai_type *ait, const struct unit *guard)
void | aiguard_check_charge_unit (struct ai_type *ait, const struct unit *charge)
void | aiguard_clear_charge (struct ai_type *ait, struct unit *guard)
void | aiguard_clear_guard (struct ai_type *ait, struct unit *charge)
void | aiguard_assign_guard_unit (struct ai_type *ait, struct unit *charge, struct unit *guard)
void | aiguard_assign_guard_city (struct ai_type *ait, struct city *charge, struct unit *guard)
void | aiguard_request_guard (struct ai_type *ait, struct unit *punit)
bool | aiguard_wanted (struct ai_type *ait, struct unit *charge)
bool | aiguard_has_charge (struct ai_type *ait, struct unit *charge)
bool | aiguard_has_guard (struct ai_type *ait, struct unit *charge)
struct unit * | aiguard_guard_of (struct ai_type *ait, struct unit *charge)
struct unit * | aiguard_charge_unit (struct ai_type *ait, struct unit *guard)
struct city * | aiguard_charge_city (struct ai_type *ait, struct unit *guard)
void | aiguard_update_charge (struct ai_type *ait, struct unit *guard)

## Macro Definition Documentation

## ◆ CHECK_CHARGE_UNIT

#define CHECK_CHARGE_UNIT | ( |  | ait,
|  |  | charge
| ) |  | aiguard_check_charge_unit(ait, charge)

Definition at line 22 of file aiguard.h.

## ◆ CHECK_GUARD

#define CHECK_GUARD | ( |  | ait,
|  |  | guard
| ) |  | aiguard_check_guard(ait, guard)

Definition at line 21 of file aiguard.h.

## Function Documentation

## ◆ aiguard_assign_guard_city()

void aiguard_assign_guard_city | ( | struct ai_type * | ait,
|  | struct city * | charge,
|  | struct unit * | guard
| ) |  |

Assign a guard to a city.

Definition at line 197 of file aiguard.c.

Referenced by dai_military_findjob(), and dai_unit_new_task().

## ◆ aiguard_assign_guard_unit()

void aiguard_assign_guard_unit | ( | struct ai_type * | ait,
|  | struct unit * | charge,
|  | struct unit * | guard
| ) |  |

Assign a bodyguard to a unit.

Assumes that a unit can have at most one guard.

Definition at line 174 of file aiguard.c.

Referenced by dai_military_findjob().

## ◆ aiguard_charge_city()

struct city * aiguard_charge_city | ( | struct ai_type * | ait,
|  | struct unit * | guard
| ) |  |

Which city (if any) has a guard been assigned to? Returns NULL if the unit is not a guard for a city.

Definition at line 290 of file aiguard.c.

Referenced by dai_military_bodyguard(), dai_military_defend(), and dai_military_findjob().

## ◆ aiguard_charge_unit()

struct unit * aiguard_charge_unit | ( | struct ai_type * | ait,
|  | struct unit * | guard
| ) |  |

Which unit (if any) has a guard been assigned to? Returns NULL if the unit is not the guard for a unit.

Definition at line 280 of file aiguard.c.

Referenced by dai_military_bodyguard(), dai_military_findjob(), and dai_unit_bodyguard_move().

## ◆ aiguard_check_charge_unit()

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.

Inconsistent references do not always indicate an error, because units can change owners (for example, because of civil war) outside the control of the AI code.

Definition at line 91 of file aiguard.c.

## ◆ aiguard_check_guard()

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.

Inconsistent references do not always indicate an error, because units can change owners (for example, because of civil war) outside the control of the AI code.

Definition at line 49 of file aiguard.c.

## ◆ aiguard_clear_charge()

void aiguard_clear_charge | ( | struct ai_type * | ait,
|  | struct unit * | guard
| ) |  |

Remove the assignment of a charge to a guard.

Assumes that a unit can have at most one guard.

Definition at line 118 of file aiguard.c.

Referenced by aiguard_assign_guard_city(), aiguard_assign_guard_unit(), aiguard_update_charge(), dai_military_defend(), dai_unit_close(), and dai_unit_new_task().

## ◆ aiguard_clear_guard()

void aiguard_clear_guard | ( | struct ai_type * | ait,
|  | struct unit * | charge
| ) |  |

Remove assignment of bodyguard for a unit.

Assumes that a unit can have at most one guard.

There is no analogous function for cities, because cities can have many guards: instead use aiguard_clear_charge for each city guard.

Definition at line 147 of file aiguard.c.

Referenced by aiguard_assign_guard_unit(), aiguard_request_guard(), dai_gothere_bodyguard(), and dai_unit_close().

## ◆ aiguard_guard_of()

struct unit * aiguard_guard_of | ( | struct ai_type * | ait,
|  | struct unit * | charge
| ) |  |

Which unit, if any, is the body guard of a unit? Returns NULL if the unit has not been assigned a guard.

Definition at line 270 of file aiguard.c.

Referenced by dai_gothere_bodyguard(), dai_manage_unit(), dai_unit_attack(), dai_unit_move(), and dai_unit_new_task().

## ◆ aiguard_has_charge()

bool aiguard_has_charge | ( | struct ai_type * | ait,
|  | struct unit * | guard
| ) |  |

Has a charge unit been assigned to a guard?

Definition at line 251 of file aiguard.c.

Referenced by dai_military_findjob().

## ◆ aiguard_has_guard()

bool aiguard_has_guard | ( | struct ai_type * | ait,
|  | struct unit * | charge
| ) |  |

Has a guard been assigned to a charge?

Definition at line 260 of file aiguard.c.

Referenced by dai_manage_unit(), and dai_military_findjob().

## ◆ aiguard_request_guard()

void aiguard_request_guard | ( | struct ai_type * | ait,
|  | struct unit * | punit
| ) |  |

Request a (new) bodyguard for the unit.

Definition at line 228 of file aiguard.c.

Referenced by dai_gothere_bodyguard(), dai_manage_diplomat(), and dai_manage_unit().

## ◆ aiguard_update_charge()

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. It was once sane, but might have been destroyed or become an enemy since.

Definition at line 300 of file aiguard.c.

Referenced by dai_military_findjob().

## ◆ aiguard_wanted()

bool aiguard_wanted | ( | struct ai_type * | ait,
|  | struct unit * | charge
| ) |  |

Has a unit requested a guard and not (yet) been provided with one?

Definition at line 242 of file aiguard.c.

Referenced by dai_military_findjob(), and look_for_charge().