87#define LOGLEVEL_RECOVERY LOG_DEBUG
88#define LOG_CARAVAN LOG_DEBUG
89#define LOG_CARAVAN2 LOG_DEBUG
90#define LOG_CARAVAN3 LOG_DEBUG
139 const struct player *pplayer)
148 if (pcity->airlift) {
173 struct unit *transported;
231 if (
pclass->non_native_def_pct > 0
279 const struct unit *defender)
292 const struct unit *defender)
307 struct tile *ptile,
bool fortified,
312 ptile, fortified, veteran)
377 int *value,
int *
cost)
566 want = (want < 0 ? -want : want);
657 ptile =
aunit->goto_tile;
790 && 0 < data->urgency) {
796 && 0 == data->grave_danger))) {
1020 bool dest,
int radius,
int which)
1062 struct tile *dest_tile,
1299 if (
NULL == ferryboat) {
1310 if (
NULL != ferryboat) {
1375 if (dest !=
beach) {
1471 if (0 >= want && 0 ==
punit->
id && 0 >= best) {
1500 &&
NULL != ferryboat
1503 "%s(): with boat %s@(%d, %d) -> %s@(%d, %d)"
1646 if (move_cost > best) {
1749 struct tile *dest_tile;
1782 struct unit *ferryboat;
1806 if (
NULL != ferryboat) {
1909 if ((ferryboat <= 0)) {
1911 "in find_boat_for_unit cannot find any boats.");
2004 required_boat ?
"with a boat" :
"");
2005 if (required_boat) {
2082 "%s %s[%d](%d,%d) unable to trade with %s",
2099 const struct unit *caravan = data;
2261 const struct city *homecity;
2267 bool help_wonder =
FALSE;
2268 bool required_boat =
FALSE;
2297 if (homecity ==
NULL) {
2350 if (homecity ==
NULL) {
2357 if (homecity ==
NULL) {
2435 if (pcity !=
NULL) {
2543 }
else if (result >= 1) {
2698 }
else if (
ptype->adv.worker
2831 &&
btype->attack_strength >
btype->defense_strength)
2833 &&
btype->attack_strength ==
btype->defense_strength))) {
2841 UNIT_LOG(loglevel, best,
"Defending city");
2897 const struct city *pcity)
2964 if (
leader->moves_left == 0
3042 if (other_player == pplayer) {
3084 "Barbarian leader: safest is (%d, %d), safeness %d",
3095 "Barbarian leader: reached the safest position.");
3162 if ((a * a * 10) >= d) {
3237 if (
punittype->transport_capacity > 0) {
3444 const struct unit *defender)
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)
void dai_manage_paratrooper(struct ai_type *ait, struct player *pplayer, struct unit *punit)
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
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender, const struct action *paction)
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)
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile, const struct action *paction)
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)
bool dai_can_requirement_be_met_in_city(const struct requirement *preq, const struct player *pplayer, const struct city *pcity)
#define BODYGUARD_LOG(ait, loglevel, punit, msg,...)
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 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 bool has_defense(struct city *pcity)
adv_want kill_desire(adv_want benefit, int attack, int loss, int vuln, int victim_count)
void dai_manage_military(struct ai_type *ait, struct player *pplayer, struct unit *punit)
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)
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)
adv_want look_for_charge(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct unit **aunit, struct city **acity)
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)
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)
static void dai_military_findjob(struct ai_type *ait, struct player *pplayer, struct unit *punit)
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)
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
void(* callback)(const struct caravan_result *result, void *data)
enum foreign_trade_limit allow_foreign_trade
struct packet_game_info info
struct civ_game::@31::@35 server
struct city_list * cities
const struct player * player
struct veteran_system * veteran
enum unit_activity activity
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 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 is_special_unit(const struct unit *punit)
bool unit_transported(const struct unit *pcargo)
bool is_guard_unit(const struct unit *punit)
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