Feature #1181 ยป 0053-AI-Pass-civ_map-to-dai_manage_military.patch
ai/default/aiferry.c | ||
---|---|---|
struct unit_ai *unit_data;
|
||
int bossid;
|
||
const struct unit_type *ptype;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
CHECK_UNIT(punit);
|
||
... | ... | |
* -- Syela */
|
||
dai_unit_new_task(ait, punit, AIUNIT_NONE, NULL);
|
||
UNIT_LOG(LOGLEVEL_FERRY, punit, "passing ferry over to attack code");
|
||
dai_manage_military(ait, pplayer, punit);
|
||
dai_manage_military(ait, nmap, pplayer, punit);
|
||
return;
|
||
}
|
||
ai/default/daiparadrop.c | ||
---|---|---|
} else {
|
||
UNIT_LOG(LOGLEVEL_PARATROOPER, punit,
|
||
"didn't find city to go and recover.");
|
||
dai_manage_military(ait, pplayer, punit);
|
||
dai_manage_military(ait, nmap, pplayer, punit);
|
||
}
|
||
}
|
||
}
|
ai/default/daiunit.c | ||
---|---|---|
struct player *pplayer,
|
||
struct unit *leader);
|
||
static void dai_military_findjob(struct ai_type *ait,
|
||
static void dai_military_findjob(struct ai_type *ait, const struct civ_map *nmap,
|
||
struct player *pplayer, struct unit *punit);
|
||
static void dai_military_defend(struct ai_type *ait, struct player *pplayer,
|
||
struct unit *punit);
|
||
... | ... | |
/**********************************************************************//**
|
||
See if we have a specific job for the unit.
|
||
**************************************************************************/
|
||
static void dai_military_findjob(struct ai_type *ait,
|
||
static void dai_military_findjob(struct ai_type *ait, const struct civ_map *nmap,
|
||
struct player *pplayer, struct unit *punit)
|
||
{
|
||
const struct unit_type *punittype = unit_type_get(punit);
|
||
struct unit_ai *unit_data;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
CHECK_UNIT(punit);
|
||
... | ... | |
Decide what to do with a military unit. It will be managed once only.
|
||
It is up to the caller to try again if it has moves left.
|
||
**************************************************************************/
|
||
void dai_manage_military(struct ai_type *ait, struct player *pplayer,
|
||
struct unit *punit)
|
||
void dai_manage_military(struct ai_type *ait, const struct civ_map *nmap,
|
||
struct player *pplayer, struct unit *punit)
|
||
{
|
||
struct unit_ai *unit_data = def_ai_unit_data(punit, ait);
|
||
int id = punit->id;
|
||
... | ... | |
/* Do we have a specific job for this unit? If not, we default
|
||
* to attack. */
|
||
dai_military_findjob(ait, pplayer, punit);
|
||
dai_military_findjob(ait, nmap, pplayer, punit);
|
||
switch (unit_data->task) {
|
||
case AIUNIT_AUTO_WORKER:
|
||
... | ... | |
struct unit *bodyguard = aiguard_guard_of(ait, punit);
|
||
bool is_ferry = FALSE;
|
||
const struct unit_type *ptype;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
CHECK_UNIT(punit);
|
||
... | ... | |
} else if (!is_special_unit(punit)) {
|
||
TIMING_LOG(AIT_MILITARY, TIMER_START);
|
||
UNIT_LOG(LOG_DEBUG, punit, "recruit unit for the military");
|
||
dai_manage_military(ait, pplayer, punit);
|
||
dai_manage_military(ait, nmap, pplayer, punit);
|
||
TIMING_LOG(AIT_MILITARY, TIMER_STOP);
|
||
return;
|
||
} else {
|
ai/default/daiunit.h | ||
---|---|---|
void dai_manage_units(struct ai_type *ait, struct player *pplayer);
|
||
void dai_manage_unit(struct ai_type *ait, struct player *pplayer,
|
||
struct unit *punit);
|
||
void dai_manage_military(struct ai_type *ait, struct player *pplayer,
|
||
struct unit *punit);
|
||
void dai_manage_military(struct ai_type *ait, const struct civ_map *nmap,
|
||
struct player *pplayer, struct unit *punit);
|
||
struct city *find_nearest_safe_city(struct unit *punit);
|
||
bool uclass_need_trans_between(struct unit_class *pclass,
|
||
struct tile *ctile, struct tile *ptile);
|