86#define LOGLEVEL_RECOVERY LOG_DEBUG
87#define LOG_CARAVAN LOG_DEBUG
88#define LOG_CARAVAN2 LOG_DEBUG
89#define LOG_CARAVAN3 LOG_DEBUG
109 const struct unit *pdef);
138 const struct player *pplayer)
140 struct city *neediest_city = NULL;
147 if (pcity->airlift) {
148 if (city_data->
urgency > most_urgent) {
149 most_urgent = city_data->
urgency;
150 neediest_city = pcity;
151 }
else if (0 == most_urgent
152 && city_data->
danger > most_danger) {
153 most_danger = city_data->
danger;
154 neediest_city = pcity;
159 return neediest_city;
170 struct city *most_needed;
172 struct unit *transported;
200 comparison = city_data->
danger;
211 0,
"", ACTION_AIRLIFT);
278 const struct unit *defender)
283 * (attacker->
id != 0 ? defender->
hp : def_type->
hp)
291 const struct unit *defender)
305 struct player *def_player,
306 struct tile *ptile,
bool fortified,
311 ptile, fortified, veteran)
347 desire = (benefit *
attack - loss * vuln) * victim_count
376 int *value,
int *
cost)
479 && unit_list_size(ptile->
units) > 1) {
494 return MAX(0, desire);
496 }
else if (0 == unit_list_size(ptile->
units)) {
522 int thresh_adj,
int thresh_move)
564 thresh = (move_needed ? thresh_move : thresh_adj);
565 want = (want < 0 ? -want : want);
567 if (want > max_want && want > thresh) {
652 if (me2goal < me2them
716 struct unit **aunit,
struct city **acity)
721 struct ai_city *data, *best_data = NULL;
723 int def, best_def = -1;
730 if (0 == toughness) {
740 if (move_cost > max_move_cost) {
776 if (def > best_def) {
788 && 0 < data->urgency) {
789 if (NULL != best_data
791 || best_data->
urgency > data->urgency
792 || ((best_data->
danger > data->danger
794 && 0 == data->grave_danger))) {
817 __FUNCTION__, best_def * 100 / toughness,
827 return ((best_def * 100) / toughness);
840 if (pcharge == followee) {
883 struct ai_city *city_data = NULL;
1017 bool dest,
int radius,
int which)
1059 struct tile *dest_tile,
1061 struct tile **ferry_dest,
struct tile **beachhead_tile)
1066 struct tile *best_tile = NULL;
1069 if (NULL != beachhead_tile) {
1070 *beachhead_tile = dest_tile;
1076 && (NULL == best_tile ||
cost < best_cost)) {
1082 if (NULL != ferry_dest) {
1083 *ferry_dest = best_tile;
1089 struct tile *best_tile = NULL, *best_beach = NULL;
1090 struct tile_list *checked_tiles = tile_list_new();
1093 tile_list_append(checked_tiles, dest_tile);
1098 if (!tile_list_search(checked_tiles, ptile)
1100 tile_list_append(checked_tiles, ptile);
1103 && (NULL == best_tile ||
cost < best_cost)) {
1113 tile_list_destroy(checked_tiles);
1115 if (NULL != beachhead_tile) {
1116 *beachhead_tile = best_beach;
1118 if (NULL != ferry_dest) {
1119 *ferry_dest = best_tile;
1136 struct pf_map **pferrymap,
1137 struct unit **pferryboat,
1138 const struct unit_type **pboattype,
int *pmove_time)
1142 struct pf_map *punit_map, *ferry_map;
1148 const struct unit_type *boattype = NULL;
1149 struct unit *ferryboat = NULL;
1152 int bcost, bcost_bal;
1155 bool harbor =
FALSE;
1159 struct unit *pdefender;
1172 struct tile *goto_dest_tile = NULL;
1177 *pdest_tile = punit_tile;
1178 if (NULL != pferrymap) {
1181 if (NULL != pferryboat) {
1184 if (NULL != pboattype) {
1187 if (NULL != pmove_time) {
1190 if (NULL != ppath) {
1194 if (0 == attack_value) {
1231 if (aunit ==
punit) {
1239 if (aunit->activity == ACTIVITY_GOTO) {
1243 if ((pcity =
tile_city(aunit->goto_tile))) {
1256 if (aunit->activity == ACTIVITY_GOTO) {
1296 if (NULL == ferryboat) {
1307 if (NULL != ferryboat) {
1314 if (NULL == boattype) {
1318 if (NULL != boattype && harbor) {
1321 punit_tile, pplayer);
1357 move_time =
pos.turn;
1358 }
else if (NULL == ferry_map) {
1361 struct tile *dest, *beach;
1371 move_time =
pos.turn;
1372 if (dest != beach) {
1375 if (NULL != ferryboat &&
unit_tile(ferryboat) != punit_tile) {
1377 move_time +=
pos.turn;
1395 if (1 < move_time) {
1400 punit_type, def_type, aplayer, atile,
FALSE,
1402 if (v > vulnerability) {
1413 - unit_list_size(acity->tile->units));
1425 if (0 < reserves && (can_occupy
1429 benefit += acity_data->
worth * reserves / 5;
1439 victim_count = unit_list_size(atile->
units);
1441 if (!can_occupy && NULL == pdefender) {
1445 }
else if (10 < move_time) {
1450 || victim_count == 0)) {
1455 vulnerability, victim_count + 1);
1460 needferry = (go_by_boat && NULL == ferryboat
1464 want,
MAX(1, move_time),
1465 bcost_bal + needferry);
1468 if (0 >= want && 0 ==
punit->
id && 0 >= best) {
1473 bcost_bal + needferry);
1476 *pdest_tile = atile;
1477 if (NULL != pferrymap) {
1478 *pferrymap = go_by_boat ? ferry_map : NULL;
1480 if (NULL != pferryboat) {
1481 *pferryboat = go_by_boat ? ferryboat : NULL;
1483 if (NULL != pboattype) {
1484 *pboattype = go_by_boat ? boattype : NULL;
1486 if (NULL != pmove_time) {
1487 *pmove_time = move_time;
1489 goto_dest_tile = (go_by_boat && NULL != ferryboat
1497 && NULL != ferryboat
1500 "%s(): with boat %s@(%d, %d) -> %s@(%d, %d)"
1505 TILE_XY(atile), go_by_boat, move_time, want, best);
1511 *pdest_tile = atile;
1512 if (NULL != pferrymap) {
1513 *pferrymap = go_by_boat ? ferry_map : NULL;
1515 if (NULL != pferryboat) {
1516 *pferryboat = go_by_boat ? ferryboat : NULL;
1518 if (NULL != pboattype) {
1519 *pboattype = go_by_boat ? boattype : NULL;
1521 if (NULL != pmove_time) {
1522 *pmove_time = move_time;
1524 goto_dest_tile = (go_by_boat && NULL != ferryboat
1570 move_time =
pos.turn;
1571 if (10 < move_time) {
1584 want,
MAX(1, move_time), bcost_bal);
1587 *pdest_tile = atile;
1588 if (NULL != pferrymap) {
1591 if (NULL != pferryboat) {
1594 if (NULL != pboattype) {
1597 if (NULL != pmove_time) {
1598 *pmove_time = move_time;
1600 goto_dest_tile = atile;
1605 if (NULL != ppath) {
1606 *ppath = (NULL != goto_dest_tile && goto_dest_tile != punit_tile
1611 if (NULL != ferry_map
1612 && (NULL == pferrymap || *pferrymap != ferry_map)) {
1634 struct city *pcity, *best_city = NULL;
1643 if (move_cost > best) {
1685 bool only_continent =
TRUE;
1690 only_continent =
FALSE;
1700 struct unit *ferry = NULL;
1746 struct tile *dest_tile;
1749 struct city *pcity = NULL;
1779 struct unit *ferryboat;
1783 NULL, &ferryboat, NULL, NULL);
1803 if (NULL != ferryboat) {
1901 struct pf_path *path_to_ferry = NULL;
1906 if ((ferryboat <= 0)) {
1908 "in find_boat_for_unit cannot find any boats.");
1911 if (current_city == NULL) {
1913 if (city_near != NULL) {
1918 if (path_to_ferry != NULL) {
1922 path_to_ferry = NULL;
1926 path_to_ferry = NULL;
1943 struct tile *ctile,
struct tile *ptile)
1983 const struct city *dest_city,
1985 bool required_boat,
bool request_boat)
2000 help_wonder ?
"help a wonder" :
"trade",
city_name_get(dest_city),
2001 required_boat ?
"with a boat" :
"");
2002 if (required_boat) {
2034 punit, dest_city)) {
2047 0,
"", ACTION_HELP_WONDER);
2049 punit, dest_city)) {
2057 0,
"", ACTION_TRADE_ROUTE);
2059 punit, dest_city)) {
2068 0,
"", ACTION_MARKETPLACE);
2079 "%s %s[%d](%d,%d) unable to trade with %s",
2096 const struct unit *caravan = data;
2115 struct tile *src = NULL, *dest = NULL, *src_home_city = NULL;
2116 struct city *phome_city = NULL;
2122 if (phome_city != NULL) {
2127 if (src == NULL || dest == NULL) {
2135 if (src_home_city != NULL
2195 if (aplayer == pplayer || !aplayer->
is_alive) {
2218 struct city *nearest = NULL;
2230 if (this_dist < min_dist) {
2231 min_dist = this_dist;
2237 if (nearest != NULL) {
2258 const struct city *homecity;
2259 const struct city *dest = NULL;
2264 bool help_wonder =
FALSE;
2265 bool required_boat =
FALSE;
2266 bool request_boat =
FALSE;
2267 bool tired_of_waiting_boat =
FALSE;
2294 if (homecity == NULL) {
2305 if ((city_dest == NULL)
2322 punit, city_dest))) {
2336 tired_of_waiting_boat =
TRUE;
2341 request_boat =
FALSE;
2347 if (homecity == NULL) {
2354 if (homecity == NULL) {
2378 if (tired_of_waiting_boat) {
2384 if (result.
dest != NULL) {
2389 request_boat = required_boat;
2398 if (required_boat && !expect_boats) {
2405 required_boat, request_boat);
2426 struct city *safe = NULL;
2432 if (pcity != NULL) {
2469 no_recovery =
FALSE;
2528 int result, sanity =
punit->
id;
2540 }
else if (result >= 1) {
2556 switch (unit_data->
task) {
2656 bool is_ferry =
FALSE;
2769 int total_defense = 0;
2771 bool emergency =
FALSE;
2777 int entertainers = 0;
2778 bool enough =
FALSE;
2782 entertainers += pcity->specialists[sp];
2786 martless_unhappy += entertainers;
2790 && (total_defense <= total_attack
2791 || (count < mart_max && mart_each > 0
2792 && martless_unhappy > mart_each * count))) {
2794 struct unit *best = NULL;
2795 bool defense_needed = total_defense <= total_attack;
2805 if (want > best_want) {
2813 if (defense_needed) {
2826 if ((martless_unhappy < mart_each * count
2827 || count >= mart_max || mart_each <= 0)
2838 total_defense += best_want;
2839 UNIT_LOG(loglevel, best,
"Defending city");
2846 ", %d defenders (out of %d)", total_defense, total_attack, count,
2847 unit_list_size(pcity->tile->units));
2895 const struct city *pcity)
2897 const struct impr_type *impr_req = NULL;
2915 if (VUT_IMPROVEMENT == preq->source.kind && preq->present) {
2917 impr_req = preq->source.value.building;
2948 struct unit *leader)
2954 struct unit *worst_danger;
2955 int move_cost, best_move_cost;
2964 && 1 < unit_list_size(leader_tile->
units))) {
2980 && warrior->moves_left > 0) {
3006 if (0 < body_guards) {
3036 worst_danger = NULL;
3040 if (other_player == pplayer) {
3047 best_move_cost = move_cost;
3048 worst_danger =
punit;
3055 if (NULL == worst_danger) {
3068 safest_tile = leader_tile;
3080 && move_cost > best_move_cost) {
3082 "Barbarian leader: safest is (%d, %d), safeness %d",
3083 TILE_XY(near_tile), best_move_cost);
3084 best_move_cost = move_cost;
3085 safest_tile = near_tile;
3093 "Barbarian leader: reached the safest position.");
3126 int extras_bonus = 0;
3144 db += (db * extras_bonus) / 100;
3160 if ((a * a * 10) >= d) {
3182 if (
A_NEVER != punittype->require_advance
3188 && punittype->transport_capacity < 8) {
3224 if (pbonus->type == CBONUS_LOW_FIREPOWER) {
3236 if (punittype->transport_capacity > 0) {
3265 bool can_move_like_charge =
FALSE;
3275 can_move_like_charge =
TRUE;
3279 if (can_move_like_charge) {
3352 if (unit_data != NULL) {
3363 const struct unit *
punit,
const char *unitstr)
3382 struct unit *
punit,
const char *unitstr)
3432 enum terrain_class tc)
3443 const struct unit *defender)
3449 bool able_to_strike =
FALSE;
3457 if (move_cost > max_move_cost) {
3461 if (ptile == ptarget) {
3462 able_to_strike =
TRUE;
3469 return able_to_strike;
bool is_action_enabled_unit_on_city(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *target_city)
static struct action * action_by_number(action_id act_id)
bool adv_follow_path(struct unit *punit, struct pf_path *path, struct tile *ptile)
int adv_unit_def_rating_basic_squared(const struct unit *punit)
int adv_unit_def_rating_basic(const struct unit *punit)
int adv_unittype_att_rating(const struct unit_type *punittype, int veteran, int moves_left, int hp)
int adv_unit_att_rating(const struct unit *punit)
int adv_could_unit_move_to_tile(struct unit *punit, struct tile *dest_tile)
bool adv_unit_execute_path(struct unit *punit, struct pf_path *path)
void dai_manage_airunit(struct ai_type *ait, struct player *pplayer, struct unit *punit)
void dai_manage_diplomat(struct ai_type *ait, struct player *pplayer, struct unit *punit)
bool aiferry_gobyboat(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct tile *dest_tile, bool with_bodyguard)
int aiferry_find_boat(struct ai_type *ait, struct unit *punit, int cap, struct pf_path **path)
void dai_manage_ferryboat(struct ai_type *ait, struct player *pplayer, struct unit *punit)
bool is_boat_free(struct ai_type *ait, struct unit *boat, struct unit *punit, int cap)
bool aiferry_goto_amphibious(struct ai_type *ait, struct unit *ferry, struct unit *passenger, struct tile *ptile)
bool is_boss_of_boat(struct ai_type *ait, struct unit *punit)
int aiferry_avail_boats(struct ai_type *ait, struct player *pplayer)
bool dai_is_ferry(struct unit *pferry, struct ai_type *ait)
void aiferry_clear_boat(struct ai_type *ait, struct unit *punit)
struct city * aiguard_charge_city(struct ai_type *ait, struct unit *guard)
void aiguard_clear_charge(struct ai_type *ait, struct unit *guard)
void aiguard_request_guard(struct ai_type *ait, struct unit *punit)
bool aiguard_has_guard(struct ai_type *ait, struct unit *charge)
void aiguard_assign_guard_unit(struct ai_type *ait, struct unit *charge, struct unit *guard)
bool aiguard_wanted(struct ai_type *ait, struct unit *charge)
void aiguard_assign_guard_city(struct ai_type *ait, struct city *charge, struct unit *guard)
struct unit * aiguard_charge_unit(struct ai_type *ait, struct unit *guard)
void aiguard_clear_guard(struct ai_type *ait, struct unit *charge)
struct unit * aiguard_guard_of(struct ai_type *ait, struct unit *charge)
bool aiguard_has_charge(struct ai_type *ait, struct unit *guard)
void aiguard_update_charge(struct ai_type *ait, struct unit *guard)
#define CHECK_GUARD(ait, guard)
bool dai_hunter_qualify(struct player *pplayer, struct unit *punit)
int dai_hunter_manage(struct ai_type *ait, struct player *pplayer, struct unit *punit)
#define BODYGUARD_LOG(ait, loglevel, punit, msg,...)
void dai_manage_paratrooper(struct ai_type *ait, struct player *pplayer, struct unit *punit)
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
void dai_unit_save(struct ai_type *ait, const char *aitstr, struct section_file *file, const struct unit *punit, const char *unitstr)
static void dai_military_findjob(struct ai_type *ait, const struct civ_map *nmap, struct player *pplayer, struct unit *punit)
static bool has_defense(struct city *pcity)
adv_want kill_desire(adv_want benefit, int attack, int loss, int vuln, int victim_count)
static bool search_homecity_for_caravan(struct ai_type *ait, struct unit *punit)
static void dai_caravan_goto(struct ai_type *ait, struct player *pplayer, struct unit *punit, const struct city *dest_city, bool help_wonder, bool required_boat, bool request_boat)
int unittype_def_rating_squared(const struct unit_type *att_type, const struct unit_type *def_type, struct player *def_player, struct tile *ptile, bool fortified, int veteran)
static bool unit_role_defender(const struct unit_type *punittype)
void dai_units_ruleset_init(struct ai_type *ait)
static int unit_att_rating_now(const struct unit *punit)
static void dai_military_attack_barbarian(struct ai_type *ait, struct player *pplayer, struct unit *punit)
static void invasion_funct(struct ai_type *ait, struct unit *punit, bool dest, int radius, int which)
static void update_simple_ai_types(void)
const struct impr_type * utype_needs_improvement(const struct unit_type *putype, const struct city *pcity)
void dai_switch_to_explore(struct ai_type *ait, struct unit *punit, struct tile *target, enum override_bool *allow)
void dai_manage_military(struct ai_type *ait, const struct civ_map *nmap, struct player *pplayer, struct unit *punit)
static bool dai_find_boat_for_unit(struct ai_type *ait, struct unit *punit)
static void reinforcements_cost_and_value(struct unit *punit, struct tile *ptile0, int *value, int *cost)
struct unit_type * simple_ai_types[U_LAST]
static void dai_airlift(struct ai_type *ait, struct player *pplayer)
int build_cost_balanced(const struct unit_type *punittype)
bool dai_unit_can_strike_my_unit(const struct unit *attacker, const struct unit *defender)
bool is_on_unit_upgrade_path(const struct unit_type *test, const struct unit_type *base)
static void dai_military_bodyguard(struct ai_type *ait, struct player *pplayer, struct unit *punit)
static void single_invader(struct ai_city *city_data, const struct unit_type *utype, int which)
void dai_manage_units(struct ai_type *ait, struct player *pplayer)
static void dai_manage_caravan(struct ai_type *ait, struct player *pplayer, struct unit *punit)
adv_want find_something_to_kill(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct tile **pdest_tile, struct pf_path **ppath, struct pf_map **pferrymap, struct unit **pferryboat, const struct unit_type **pboattype, int *pmove_time)
static void dai_set_defenders(struct ai_type *ait, struct player *pplayer)
void dai_manage_unit(struct ai_type *ait, struct player *pplayer, struct unit *punit)
adv_want look_for_charge(struct ai_type *ait, const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct unit **aunit, struct city **acity)
static bool role_unit_cb(struct unit_type *ptype, void *data)
static void dai_military_attack(struct ai_type *ait, struct player *pplayer, struct unit *punit)
void dai_unit_turn_end(struct ai_type *ait, struct unit *punit)
static void dai_manage_settler(struct ai_type *ait, struct player *pplayer, struct unit *punit)
static int avg_benefit(int benefit, int loss, double chance)
static struct city * find_neediest_airlift_city(struct ai_type *ait, const struct player *pplayer)
static int unit_def_rating(const struct unit *attacker, const struct unit *defender)
static bool dai_is_unit_tired_waiting_boat(struct ai_type *ait, struct unit *punit)
static int dai_rampage_want(struct unit *punit, struct tile *ptile)
bool dai_can_unit_type_follow_unit_type(const struct unit_type *follower, const struct unit_type *followee, struct ai_type *ait)
struct city * find_nearest_safe_city(struct unit *punit)
static void dai_manage_barbarian_leader(struct ai_type *ait, struct player *pplayer, struct unit *leader)
static void dai_manage_hitpoint_recovery(struct ai_type *ait, struct unit *punit)
static int unit_att_rating_squared(const struct unit *punit)
static struct pf_path * find_rampage_target(struct unit *punit, int thresh_adj, int thresh_move)
static bool is_my_turn(struct unit *punit, struct unit *pdef)
static int unit_def_rating_squared(const struct unit *punit, const struct unit *pdef)
void dai_unit_init(struct ai_type *ait, struct unit *punit)
void dai_consider_tile_dangerous(struct ai_type *ait, struct tile *ptile, struct unit *punit, enum override_bool *result)
bool uclass_need_trans_between(struct unit_class *pclass, struct tile *ctile, struct tile *ptile)
void dai_unit_load(struct ai_type *ait, const char *aitstr, const struct section_file *file, struct unit *punit, const char *unitstr)
static void caravan_optimize_callback(const struct caravan_result *result, void *data)
#define LOGLEVEL_RECOVERY
void dai_unit_close(struct ai_type *ait, struct unit *punit)
void dai_units_ruleset_close(struct ai_type *ait)
struct unit_type * dai_role_utype_for_terrain_class(struct city *pcity, int role, enum terrain_class tc)
bool find_beachhead(const struct player *pplayer, struct pf_map *ferry_map, struct tile *dest_tile, const struct unit_type *cargo_type, struct tile **ferry_dest, struct tile **beachhead_tile)
static void dai_military_defend(struct ai_type *ait, struct player *pplayer, struct unit *punit)
bool dai_military_rampage(struct unit *punit, int thresh_adj, int thresh_move)
static bool dai_caravan_can_trade_cities_diff_cont(struct player *pplayer, struct unit *punit)
#define POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer)
#define RAMPAGE_FREE_CITY_OR_BETTER
#define RAMPAGE_HUT_OR_BETTER
#define DEFENSE_POWER(ptype)
#define IS_ATTACKER(ptype)
#define BODYGUARD_RAMPAGE_THRESHOLD
#define ATTACK_POWER(ptype)
enum unit_move_result manage_auto_explorer(struct unit *punit)
void adv_unit_new_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile)
bool is_land_barbarian(struct player *pplayer)
void caravan_find_best_destination(const struct civ_map *nmap, const struct unit *caravan, const struct caravan_parameter *parameter, struct caravan_result *result, bool omniscient)
void caravan_parameter_init_from_unit(struct caravan_parameter *parameter, const struct unit *caravan)
bool city_production_gets_caravan_shields(const struct universal *tgt)
const char * city_name_get(const struct city *pcity)
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
bool can_city_build_unit_now(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
#define city_owner(_pcity_)
#define city_list_iterate_end
bool is_stack_vulnerable(const struct tile *ptile)
int get_virtual_defense_power(const struct civ_map *nmap, const struct unit_type *att_type, const struct unit_type *def_type, struct player *def_player, struct tile *ptile, bool fortified, int veteran)
enum unit_attack_result unit_attack_units_at_tile_result(const struct unit *punit, const struct action *paction, const struct tile *ptile)
int get_total_defense_power(const struct unit *attacker, const struct unit *defender)
enum unit_attack_result unit_attack_unit_at_tile_result(const struct unit *punit, const struct action *paction, const struct unit *pdefender, const struct tile *dest_tile)
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender)
bool can_unit_attack_tile(const struct unit *punit, const struct action *paction, const struct tile *dest_tile)
int base_get_defense_power(const struct unit *punit)
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile)
bool dai_can_requirement_be_met_in_city(const struct requirement *preq, const struct player *pplayer, const struct city *pcity)
struct unit_type * dai_choose_defender_versus(struct city *pcity, struct unit *attacker)
int assess_defense_quadratic(struct ai_type *ait, struct city *pcity)
int assess_defense_unit(struct ai_type *ait, struct city *pcity, struct unit *punit, bool igwall)
static void attack(QVariant data1, QVariant data2)
static void base(QVariant data1, QVariant data2)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
bool ai_fuzzy(const struct player *pplayer, bool normal_decision)
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
int get_unittype_bonus(const struct player *pplayer, const struct tile *ptile, const struct unit_type *punittype, const struct action *paction, enum effect_type effect_type)
signed short Continent_id
struct unit * game_unit_by_number(int id)
struct city * game_city_by_number(int id)
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_do_output_for_level(level)
#define log_base(level, message,...)
bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
int map_distance(const struct tile *tile0, const struct tile *tile1)
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
#define iterate_outward_end
static int index_to_map_pos_y(int mindex)
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define adjc_iterate(nmap, center_tile, itr_tile)
#define square_iterate_end
static int index_to_map_pos_x(int mindex)
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
#define fc_calloc(n, esz)
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
int unit_move_rate(const struct unit *punit)
bool can_attack_from_non_native(const struct unit_type *utype)
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
bool can_attack_non_native(const struct unit_type *utype)
static bool is_native_tile_to_class(const struct unit_class *punitclass, const struct tile *ptile)
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_unit(const struct unit *punit)
void pf_path_destroy(struct pf_path *path)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
struct pf_path * pf_map_path(struct pf_map *pfm, struct tile *ptile)
bool pf_map_position(struct pf_map *pfm, struct tile *ptile, struct pf_position *pos)
void pf_reverse_map_destroy(struct pf_reverse_map *pfrm)
int pf_reverse_map_unit_move_cost(struct pf_reverse_map *pfrm, const struct unit *punit)
void pf_map_destroy(struct pf_map *pfm)
struct pf_reverse_map * pf_reverse_map_new(const struct civ_map *nmap, const struct player *pplayer, struct tile *target_tile, int max_turns, bool omniscient)
int pf_map_move_cost(struct pf_map *pfm, struct tile *ptile)
#define pf_map_move_costs_iterate_end
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost, COND_from_start)
#define pf_map_tiles_iterate(ARG_pfm, NAME_tile, COND_from_start)
#define pf_map_tiles_iterate_end
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
#define secfile_insert_int(secfile, value, path,...)
bool is_req_active(const struct req_context *context, const struct player *other_player, const struct requirement *req, const enum req_problem_type prob_type)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
struct setting_list * level[OLEVELS_NUM]
int get_specialist_output(const struct city *pcity, Specialist_type_id sp, Output_type_id otype)
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
#define CITY_LOG(loglevel, pcity, msg,...)
#define UNIT_LOG(loglevel, punit, msg,...)
#define TIMING_LOG(timer, activity)
#define LOGLEVEL_BODYGUARD
struct ai_invasion invasion
unsigned int grave_danger
void(* callback)(const struct caravan_result *result, void *data)
enum foreign_trade_limit allow_foreign_trade
struct universal production
struct civ_game::@30::@34 server
struct packet_game_info info
struct city_list * cities
const struct player * player
struct unit_class_list * subset_movers
struct unit_class::@85 cache
enum move_level land_move
struct unit_class::@84 adv
struct unit_type_list * potential_charges
struct unit_type::@87 adv
struct requirement_vector build_reqs
struct veteran_system * veteran
enum unit_activity activity
struct unit::@80::@83 server
bool is_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
#define is_ocean_tile(ptile)
int tile_extras_defense_bonus(const struct tile *ptile, const struct unit_type *punittype)
struct city * tile_city(const struct tile *ptile)
#define tile_terrain(_tile)
#define tile_continent(_tile)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
void unit_set_ai_data(struct unit *punit, const struct ai_type *ai, void *data)
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
bool is_losing_hp(const struct unit *punit)
bool unit_can_airlift_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pdest_city)
struct unit * unit_transport_get(const struct unit *pcargo)
int unit_gain_hitpoints(const struct unit *punit)
bool is_military_unit(const struct unit *punit)
bool unit_is_cityfounder(const struct unit *punit)
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
bool unit_can_do_action_result(const struct unit *punit, enum action_result result)
int get_transporter_capacity(const struct unit *punit)
bool can_unit_do_activity(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity)
bool unit_transported(const struct unit *pcargo)
bool unit_has_orders(const struct unit *punit)
#define unit_cargo_iterate_end
#define unit_cargo_iterate(_ptrans, _pcargo)
#define CHECK_UNIT(punit)
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
void unit_do_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
bool unit_server_side_agent_set(struct player *pplayer, struct unit *punit, enum server_side_agent agent)
struct unit * unit_list_find(const struct unit_list *punitlist, int unit_id)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
bool utype_action_takes_all_mp(const struct unit_type *putype, struct action *paction)
const struct unit_type * unit_type_get(const struct unit *punit)
struct unit_type * role_units_iterate_backwards(int role, role_unit_callback cb, void *data)
struct unit_type * get_role_unit(int role, int role_index)
const char * unit_rule_name(const struct unit *punit)
bool utype_has_role(const struct unit_type *punittype, int role)
int utype_build_shield_cost_base(const struct unit_type *punittype)
int unit_build_shield_cost_base(const struct unit *punit)
struct unit_type * best_role_unit_for_player(const struct player *pplayer, int role)
struct unit_class * unit_class_get(const struct unit *punit)
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
bool unit_can_take_over(const struct unit *punit)
void * utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai)
bool utype_can_take_over(const struct unit_type *punittype)
void utype_set_ai_data(struct unit_type *ptype, const struct ai_type *ai, void *data)
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
bool utype_acts_hostile(const struct unit_type *putype)
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
#define utype_fuel(ptype)
#define combat_bonus_list_iterate_end
#define combat_bonus_list_iterate(bonuslist, pbonus)
#define unit_type_list_iterate(utype_list, ptype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define unit_class_list_iterate(uclass_list, pclass)
#define unit_type_iterate(_p)
#define unit_type_list_iterate_end
#define unit_type_iterate_end
#define unit_class_list_iterate_end