Feature #1117 ยป 0076-AI-Pass-civ_map-to-dai_process_defender_want.patch
ai/default/daicity.c | ||
---|---|---|
struct adv_choice *newchoice;
|
||
struct adv_data *adv = adv_data_get(pplayer, NULL);
|
||
struct ai_city *city_data = def_ai_city_data(pcity, ait);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (has_handicap(pplayer, H_AWAY)
|
||
&& !city_built_last_turn(pcity)
|
||
... | ... | |
unsigned int our_def = assess_defense_quadratic(ait, pcity);
|
||
if (our_def == 0
|
||
&& dai_process_defender_want(ait, pplayer, pcity, 1,
|
||
&& dai_process_defender_want(ait, nmap, pplayer, pcity, 1,
|
||
&(city_data->choice), 0)) {
|
||
adv_choice_set_use(&(city_data->choice), "fallback defender");
|
||
CITY_LOG(LOG_DEBUG, pcity, "Building fallback defender");
|
ai/default/daimilitary.c | ||
---|---|---|
type in choice. Also sets the technology want for the units we can't
|
||
build yet.
|
||
**************************************************************************/
|
||
bool dai_process_defender_want(struct ai_type *ait, struct player *pplayer,
|
||
bool dai_process_defender_want(struct ai_type *ait, const struct civ_map *nmap,
|
||
struct player *pplayer,
|
||
struct city *pcity, unsigned int danger,
|
||
struct adv_choice *choice, adv_want extra_want)
|
||
{
|
||
... | ... | |
struct ai_city *city_data = def_ai_city_data(pcity, ait);
|
||
struct ai_plr *plr_data = def_ai_player_data(pplayer, ait);
|
||
adv_want total_want = danger + extra_want;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
memset(tech_desire, 0, sizeof(tech_desire));
|
||
... | ... | |
if (our_def == 0 && danger > 0) {
|
||
/* Build defensive unit first! Walls will help nothing if there's
|
||
* nobody behind them. */
|
||
if (dai_process_defender_want(ait, pplayer, pcity, danger, choice,
|
||
if (dai_process_defender_want(ait, nmap, pplayer, pcity, danger, choice,
|
||
martial_value)) {
|
||
choice->want = DAI_WANT_BELOW_MIL_EMERGENCY + danger;
|
||
adv_choice_set_use(choice, "first defender");
|
||
... | ... | |
adv_init_choice(&uchoice);
|
||
/* Consider building defensive units */
|
||
if (dai_process_defender_want(ait, pplayer, pcity, danger, &uchoice,
|
||
martial_value)) {
|
||
if (dai_process_defender_want(ait, nmap, pplayer, pcity, danger,
|
||
&uchoice, martial_value)) {
|
||
/* Potential defender found */
|
||
if (urgency == 0
|
||
&& uchoice.value.utype->defense_strength == 1) {
|
ai/default/daimilitary.h | ||
---|---|---|
int assess_defense_unit(struct ai_type *ait, struct city *pcity,
|
||
struct unit *punit, bool igwall);
|
||
int assess_defense(struct ai_type *ait, struct city *pcity);
|
||
bool dai_process_defender_want(struct ai_type *ait, struct player *pplayer,
|
||
bool dai_process_defender_want(struct ai_type *ait, const struct civ_map *nmap,
|
||
struct player *pplayer,
|
||
struct city *pcity, unsigned int danger,
|
||
struct adv_choice *choice, adv_want extra_want);
|
||