Freeciv-3.3
Loading...
Searching...
No Matches
Enumerations | Functions
aiguard.c File Reference
#include "log.h"
#include "game.h"
#include "unit.h"
#include "srv_log.h"
#include "dailog.h"
#include "daiplayer.h"
#include "daiunit.h"
#include "aiguard.h"

Go to the source code of this file.

Enumerations

enum  bodyguard_enum { BODYGUARD_WANTED = -1 , BODYGUARD_NONE }
 

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 *guard)
 
bool aiguard_has_guard (struct ai_type *ait, struct unit *charge)
 
struct unitaiguard_guard_of (struct ai_type *ait, struct unit *charge)
 
struct unitaiguard_charge_unit (struct ai_type *ait, struct unit *guard)
 
struct cityaiguard_charge_city (struct ai_type *ait, struct unit *guard)
 
void aiguard_update_charge (struct ai_type *ait, struct unit *guard)
 

Enumeration Type Documentation

◆ bodyguard_enum

Enumerator
BODYGUARD_WANTED 
BODYGUARD_NONE 

Definition at line 35 of file aiguard.c.

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 196 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 173 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 289 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 279 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 90 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 48 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 117 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 146 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 269 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 250 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 259 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 227 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 299 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 241 of file aiguard.c.

Referenced by dai_military_findjob(), and look_for_charge().