54#define CARGO_ITER(iter) ((struct cargo_iter *) (iter))
389 const struct player *pplayer,
390 const struct tile *ptile,
bool omniscient)
467 const struct city *pcity)
544 const struct tile *ptile,
626 return Q_(
"?act:Mine");
631 return _(
"Irrigate");
633 return _(
"Cultivate");
635 return _(
"Fortifying");
637 return _(
"Fortified");
647 return _(
"Transform");
886 if (
NULL == target) {
894 if (
NULL == target) {
924 const struct tile *ptile)
943#define RETURN_IS_ACTIVITY_ENABLED_UNIT_ON(paction) \
945 switch (action_get_target_kind(paction)) { \
947 return is_action_enabled_unit_on_tile(nmap, paction->id, \
948 punit, ptile, target); \
950 return is_action_enabled_unit_on_extras(nmap, paction->id, \
951 punit, ptile, target); \
960 fc_assert(action_target_kind_is_valid( \
961 action_get_target_kind(paction))); \
973 "Please use action_speculate_unit_on_tile()");
975 punit, ptile, target);
980 "Please use action_speculate_unit_on_tile()");
987 "Please use action_speculate_unit_on_tile()");
994 "Please use action_speculate_unit_on_tile()");
1001 "Please use action_speculate_unit_on_tile()");
1008 "Please use action_speculate_unit_on_self()");
1018 "Please use action_speculate_unit_on_tile()");
1020 punit, ptile, target);
1025 "Please use action_speculate_unit_on_tile()");
1027 punit, ptile, target);
1040 "Please use action_speculate_unit_on_tile()");
1049 "Please use action_speculate_unit_on_tile()");
1056 "Please use action_speculate_unit_on_self()");
1063 log_error(
"can_unit_do_activity_targeted_at() unknown activity %d",
1067#undef RETURN_IS_ACTIVITY_ENABLED_UNIT_ON
1124 const struct tile *ptile)
1221 log_error(
"Unknown unit activity %d for %s (nb %d) in %s()",
1269 const struct player *pplayer)
1292 const struct player *pplayer)
1307 const struct player *pplayer)
1324 const struct player *pplayer)
1340 const struct player *pplayer)
1361 const struct player *pplayer)
1402 if (pcity !=
NULL) {
1421 bool hidden =
FALSE;
1472 if (pcity !=
NULL) {
1794 const struct tile *ptile,
1815 cur.outermost_moves_left =
ptrans->moves_left;
1833 if (!
cur.has_orders && best.has_orders) {
1835 }
else if (
cur.has_orders && !best.has_orders) {
1845 if (
cur.is_idle && !best.is_idle) {
1847 }
else if (!
cur.is_idle && best.is_idle) {
1858 if (
cur.can_freely_unload && !best.can_freely_unload) {
1860 }
else if (!
cur.can_freely_unload && best.can_freely_unload) {
1868 if (
cur.depth < best.depth) {
1870 }
else if (
cur.depth > best.depth) {
1879 if (
cur.outermost_moves_left > best.outermost_moves_left) {
1881 }
else if (
cur.outermost_moves_left < best.outermost_moves_left) {
1893 if (
cur.total_moves > best.total_moves) {
1923 const struct tile *ptile)
2064 "Treasury contains %d gold.",
2074 "Upgrade %s to %s for %d gold?\n%s",
2082 _(
"Sorry, cannot upgrade %s (yet)."),
2089 "Upgrading %s to %s costs %d gold.\n%s",
2098 _(
"You can only upgrade units in your cities."));
2102 _(
"Upgrading this %s would strand units it transports."),
2107 _(
"Upgrading this %s would result in a %s which can not "
2108 "survive at this place."),
2114 _(
"Upgrading this %s would result in a %s which its "
2115 "current transport, %s, could not transport."),
2122 _(
"Cannot upgrade %s while doing '%s'."),
2407#ifndef FREECIV_NDEBUG
2445 return pcargo->transporter;
2456 return ptrans->transporting;
2541 if (
iter.depth > depth) {
2598 while (
iter->depth > 0) {
2654 for (
i = 0;
i < length;
i++) {
2659 log_error(
"invalid order %d at index %d", orders[
i].order,
i);
2662 switch (orders[
i].order) {
2666 log_error(
"in order %d, invalid move direction %d.",
i, orders[
i].dir);
2671 switch (orders[
i].activity) {
2673 if (
i != length - 1) {
2675 log_error(
"activity %d is not allowed at index %d.", orders[
i].activity,
2692 log_error(
"at index %d, use action rather than activity %d.",
2693 i, orders[
i].activity);
2703 log_error(
"at index %d, unsupported activity %d.",
i, orders[
i].activity);
2719 log_error(
"at index %d, invalid tile target %d for the action %d.",
2725 log_error(
"at index %d, the action %d sets the outdated target"
2726 " specification dir.",
2736 log_error(
"at index %d, cannot do %s without a target.",
i,
2743 if (orders[
i].sub_target ==
A_NONE
2747 log_error(
"at index %d, cannot do %s without a target.",
i,
2761 if (pextra ==
NULL) {
2764 log_error(
"at index %d, cannot do %s without a target.",
i,
2772 log_error(
"at index %d, cannot do %s to %s.",
i,
2787 "Bad action %d in order number %d.", orders[
i].
action,
i);
2791 if (
i != length - 1) {
2802 log_error(
"action %d is not allowed at index %d.",
bool action_prob_possible(const struct act_prob probability)
struct act_prob action_prob_vs_tile(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
const char * action_id_rule_name(action_id act_id)
bool is_action_enabled_unit_on_tile(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
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)
bool is_action_enabled_unit_on_unit(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
struct act_prob action_prob_vs_city(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
bool action_maybe_possible_actor_unit(const struct civ_map *nmap, const action_id act_id, const struct unit *actor_unit)
bool action_id_exists(const action_id act_id)
bool is_action_enabled_unit_on_self(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit)
struct act_prob action_prob_vs_unit(const struct civ_map *nmap, const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
#define action_by_result_iterate(_paction_, _result_)
#define action_id_get_sub_target_kind(act_id)
static struct action * action_by_number(action_id act_id)
#define action_has_result(_act_, _res_)
#define action_by_result_iterate_end
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
int ai_type_number(const struct ai_type *ai)
#define CALL_FUNC_EACH_AI(_func,...)
void astr_add_line(struct astring *astr, const char *format,...)
void astr_add(struct astring *astr, const char *format,...)
bool is_capital(const struct city *pcity)
struct city * tile_non_allied_city(const struct tile *ptile, const struct player *pplayer)
bool is_unit_near_a_friendly_city(const struct civ_map *nmap, const struct unit *punit, int distance)
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
#define city_owner(_pcity_)
#define city_list_iterate_end
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
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct player *other_player, enum effect_type effect_type)
int get_unit_bonus(const struct unit *punit, 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)
static bool is_server(void)
enum unit_activity Activity_type_id
#define IDENTITY_NUMBER_ZERO
#define PL_(String1, String2, n)
struct unit * game_unit_by_number(int id)
struct city * game_city_by_number(int id)
#define GAME_UNIT_BRIBE_DIST_MAX
#define GAME_TRANSPORT_MAX_RECURSIVE
struct impr_type * improvement_by_number(const Impr_type_id id)
static bool iterator_valid(const struct iterator *it)
static void iterator_next(struct iterator *it)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_error(message,...)
#define fc_assert_ret_val_msg(condition, val, message,...)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
bool same_pos(const struct tile *tile1, const struct tile *tile2)
bool map_untrusted_dir_is_valid(enum direction8 dir)
enum direction8 rand_direction(void)
int map_distance(const struct tile *tile0, const struct tile *tile1)
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define square_iterate_end
#define fc_calloc(n, esz)
const char * move_points_text(int mp, bool reduce)
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
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)
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
int unit_move_rate(const struct unit *punit)
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, 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)
struct city_list * cities
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
struct setting_list * level[OLEVELS_NUM]
const struct unit_list_link * links[GAME_TRANSPORT_MAX_RECURSIVE]
struct city::@17::@20 client
struct packet_ruleset_control control
struct packet_game_info info
struct civ_game::@31::@35 server
bool(* valid)(const struct iterator *it)
void *(* get)(const struct iterator *it)
void(* next)(struct iterator *it)
enum borders_mode borders
enum happyborders_type happyborders
enum airlifting_style airlifting_style
bool airlift_from_always_enabled
bool airlift_to_always_enabled
struct player_economic economic
struct unit_type::@87 adv
const struct unit_type * converted_to
enum action_decision action_decision_want
enum unit_activity activity
struct unit::@81::@83 client
struct unit_list * transporting
struct extra_type * changed_from_target
struct unit::@81::@84 server
struct extra_type * activity_target
struct act_prob * act_prob_cache
enum unit_activity changed_from
struct player * nationality
void(* removal_callback)(struct unit *punit)
void * ais[FREECIV_AI_MOD_LAST]
struct unit * transporter
struct goods_type * carrying
struct tile * action_decision_tile
const struct unit_type * utype
enum unit_focus_status focus_status
enum server_side_agent ssa_controller
int fc_snprintf(char *str, size_t n, const char *format,...)
struct advance * valid_advance_by_number(const Tech_type_id id)
#define terrain_has_flag(terr, flag)
bool tile_is_placing(const struct tile *ptile)
int tile_activity_time(enum unit_activity activity, const struct tile *ptile, const struct extra_type *tgt)
bool tile_has_native_base(const struct tile *ptile, const struct unit_type *punittype)
int tile_has_not_aggressive_extra_for_unit(const struct tile *ptile, const struct unit_type *punittype)
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
struct city * tile_city(const struct tile *ptile)
#define tile_terrain(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
bool unit_can_do_action_sub_result(const struct unit *punit, enum action_sub_result sub_result)
size_t cargo_iter_sizeof(void)
bool can_unit_do_activity_targeted_at(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, struct extra_type *target, const struct tile *ptile)
bool is_tile_activity(enum unit_activity activity)
struct unit_order * create_unit_orders(const struct civ_map *nmap, int length, const struct unit_order *orders)
enum unit_upgrade_result unit_transform_result(const struct civ_map *nmap, const struct unit *punit, const struct unit_type *to_unittype)
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
bool is_terrain_change_activity(enum unit_activity activity)
struct unit * tile_non_allied_unit(const struct tile *ptile, const struct player *pplayer)
int unit_shield_value(const struct unit *punit, const struct unit_type *punittype, const struct action *paction)
int get_transporter_occupancy(const struct unit *ptrans)
static void cargo_iter_next(struct iterator *it)
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
void free_unit_orders(struct unit *punit)
void unit_set_ai_data(struct unit *punit, const struct ai_type *ai, void *data)
bool unit_is_alive(int id)
bool unit_can_est_trade_route_here(const struct unit *punit)
bool is_occupying_unit(const struct unit *punit)
bool is_hiding_unit(const struct unit *punit)
int get_activity_rate_this_turn(const struct unit *punit)
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
int get_turns_for_activity_at(const struct unit *punit, enum unit_activity activity, const struct tile *ptile, struct extra_type *tgt)
bool is_plr_zoc_client(const struct player *pplayer, const struct tile *ptile0, const struct civ_map *zmap)
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
struct iterator * cargo_iter_init(struct cargo_iter *iter, const struct unit *ptrans)
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
int unit_transport_depth(const struct unit *pcargo)
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
bool is_losing_hp(const struct unit *punit)
bool is_targeted_activity(enum unit_activity activity)
bool can_unit_load(const struct unit *pcargo, const struct unit *ptrans)
bool unit_can_add_or_build_city(const struct civ_map *nmap, const struct unit *punit)
struct unit * tile_non_attack_unit(const struct tile *ptile, const struct player *pplayer)
int hp_gain_coord(const struct unit *punit)
bool can_unit_change_homecity(const struct civ_map *nmap, const struct unit *punit)
static void * cargo_iter_get(const struct iterator *it)
struct player * unit_nationality(const struct unit *punit)
bool unit_being_aggressive(const struct civ_map *nmap, const struct unit *punit)
int get_activity_rate(const struct unit *punit)
bool can_unit_deboard_or_be_unloaded(const struct civ_map *nmap, const struct unit *pcargo, const struct unit *ptrans)
bool unit_transport_check(const struct unit *pcargo, const struct unit *ptrans)
bool is_attack_unit(const struct unit *punit)
bool unit_can_airlift_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pdest_city)
const Activity_type_id tile_changing_activities[]
struct unit * unit_transport_get(const struct unit *pcargo)
bool unit_transport_unload(struct unit *pcargo)
bool is_build_activity(enum unit_activity activity)
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
int unit_gain_hitpoints(const struct unit *punit)
enum unit_airlift_result test_unit_can_airlift_to(const struct civ_map *nmap, const struct player *restriction, const struct unit *punit, const struct city *pdest_city)
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
int unit_bribe_cost(struct unit *punit, struct player *briber)
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
bool unit_is_cityfounder(const struct unit *punit)
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
bool can_unit_do_autosettlers(const struct unit *punit)
bool is_field_unit(const struct unit *punit)
static bool cargo_iter_valid(const struct iterator *it)
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)
#define RETURN_IS_ACTIVITY_ENABLED_UNIT_ON(paction)
bool is_martial_law_unit(const struct unit *punit)
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
int unit_cargo_depth(const struct unit *ptrans)
static bool unit_transport_check_one(const struct unit_type *cargo_utype, const struct unit_type *trans_utype)
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit)
bool unit_order_list_is_sane(const struct civ_map *nmap, int length, const struct unit_order *orders)
const char * get_activity_text(enum unit_activity activity)
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
int get_transporter_capacity(const struct unit *punit)
bool is_plr_zoc_srv(const struct player *pplayer, const struct tile *ptile0, const struct civ_map *zmap)
bool is_enter_borders_unit(const struct unit *punit)
bool is_clean_activity(enum unit_activity activity)
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
void unit_activity_astr(const struct unit *punit, struct astring *astr)
bool unit_can_help_build_wonder_here(const struct civ_map *nmap, const struct unit *punit)
bool can_unit_do_activity(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity)
struct unit * tile_other_players_unit(const struct tile *ptile, const struct player *pplayer)
bool is_special_unit(const struct unit *punit)
void unit_virtual_destroy(struct unit *punit)
struct unit * tile_enemy_unit(const struct tile *ptile, const struct player *pplayer)
void unit_tile_set(struct unit *punit, struct tile *ptile)
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
bool unit_transported(const struct unit *pcargo)
bool are_unit_orders_equal(const struct unit_order *order1, const struct unit_order *order2)
bool unit_is_virtual(const struct unit *punit)
static void set_unit_activity_internal(struct unit *punit, enum unit_activity new_activity)
bool is_square_threatened(const struct civ_map *nmap, const struct player *pplayer, const struct tile *ptile, bool omniscient)
bool is_guard_unit(const struct unit *punit)
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
struct unit * unit_occupies_tile(const struct tile *ptile, const struct player *pplayer)
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
static bool can_type_transport_units_cargo(const struct unit_type *utype, const struct unit *punit)
void * unit_ai_data(const struct unit *punit, const struct ai_type *ai)
bool unit_has_orders(const struct unit *punit)
struct unit * tile_allied_unit(const struct tile *ptile, const struct player *pplayer)
struct unit * transporter_for_unit(const struct unit *pcargo)
static struct unit * base_transporter_for_unit(const struct unit *pcargo, const struct tile *ptile, bool(*unit_load_test)(const struct unit *pc, const struct unit *pt))
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
bool activity_requires_target(enum unit_activity activity)
bool could_unit_be_in_transport(const struct unit *pcargo, const struct unit *ptrans)
bool can_unit_do_activity_targeted(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, struct extra_type *target)
#define unit_transports_iterate_end
#define unit_cargo_iterate_end
#define unit_transported_server(_pcargo_)
#define unit_cargo_iterate(_ptrans, _pcargo)
#define unit_transports_iterate(_pcargo, _ptrans)
@ UU_UNSUITABLE_TRANSPORT
#define unit_transported_client(_pcargo_)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
const struct unit_type * unit_type_get(const struct unit *punit)
int utype_pays_mp_for_action_base(const struct action *paction, const struct unit_type *putype)
bool utype_can_freely_unload(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
const char * unit_name_translation(const struct unit *punit)
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
bool utype_is_cityfounder(const struct unit_type *utype)
const char * unit_rule_name(const struct unit *punit)
int utype_build_shield_cost_base(const struct unit_type *punittype)
bool utype_may_act_move_frags(const struct unit_type *punit_type, const action_id act_id, const int move_fragments)
int unit_build_shield_cost_base(const struct unit *punit)
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
bool utype_can_freely_load(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
int utype_veteran_levels(const struct unit_type *punittype)
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)
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
bool utype_is_consumed_by_action(const struct action *paction, const struct unit_type *utype)
bool utype_can_do_action_sub_result(const struct unit_type *putype, enum action_sub_result sub_result)
bool utype_is_unmoved_by_action(const struct action *paction, const struct unit_type *utype)
bool utype_acts_hostile(const struct unit_type *putype)
const char * utype_name_translation(const struct unit_type *punittype)
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define utype_fuel(ptype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)