42#define MAX_UNIT_ROLES L_LAST + ACTION_COUNT
182 const struct player *pplayer)
308#define ACTION_HOSTILE ACTION_COUNT + 1
311#define ACTION_AND_FAKES ACTION_HOSTILE + 1
479 log_debug(
"unit_act_takes_all_mp_cache_set: %s takes all MP from %s",
527 log_debug(
"unit_act_takes_all_mp_cache_set: %s takes all MP from %s"
528 " when unit state is %s",
559#define requirement_unit_state_ereq(_id_, _present_) \
560 requirement_kind_ereq(_id_, REQ_RANGE_LOCAL, _present_, USP_COUNT)
561#define requirement_citytile_ereq(_id_, _present_) \
562 requirement_kind_ereq(_id_, REQ_RANGE_LOCAL, _present_, CITYT_LAST)
884#define MOVES_LEFT_INFINITY -1
1060 const int move_fragments)
1100 if (
ml_range->min <= move_fragments
1102 ||
ml_range->max > move_fragments)) {
1222 return paction->actor_consuming_always;
1254 if (
paction->actor_consuming_always) {
1258 switch (
paction->actor.is_unit.moves_actor) {
1293 if (
paction->actor_consuming_always) {
1298 switch (
paction->actor.is_unit.moves_actor) {
1439 const struct player *pplayer,
1444 const struct tile *ptile;
1446 if (pcity !=
NULL) {
1453 if (pplayer !=
NULL) {
1509 if (pcity !=
NULL) {
1535 return MAX(0, pop_cost);
1598 static char buffer[256];
1619 static char buffer[256];
1681 }
else if (0 < count) {
1682 const char *vec[count];
1685 for (
i = 0;
i < count;
i++) {
1786 const char *
qs =
Qn_(s);
1814 const char *helptxt)
1834 if (helptxt && helptxt[0] !=
'\0') {
1877 const char *helptxt)
1897 if (helptxt && helptxt[0] !=
'\0') {
2470 return pclass->item_number;
2650 sizeof(*
vsystem->definitions));
2815 ptype->cache.defense_mp_bonuses_pct[idx] = bonus;
2827 = (
ptype->cache.scramble_coeff[idx]
2829 ) / (100 +
emax) - 100;
2830 bonus =
MAX(bonus, 1);
2832 ptype->cache.scramble_coeff[idx] = 0;
2834 if (bonus >
ptype->cache.max_defense_mp_bonus_pct) {
2835 ptype->cache.max_defense_mp_bonus_pct = bonus;
2864 if (!
preq->present) {
2867 }
else if (
preq->source.value.terrainclass ==
TC_OCEAN) {
2873 }
else if (
preq->source.value.terrainclass ==
TC_OCEAN) {
2878 if (!
preq->present) {
2879 if (
preq->source.value.terrain->tclass ==
TC_LAND) {
2881 }
else if (
preq->source.value.terrain->tclass ==
TC_OCEAN) {
2885 if (
preq->source.value.terrain->tclass ==
TC_LAND) {
2887 }
else if (
preq->source.value.terrain->tclass ==
TC_OCEAN) {
enum action_actor_kind action_get_actor_kind(const struct action *paction)
bool action_actor_utype_hard_reqs_ok(const struct action *paction, const struct unit_type *actor_unittype)
const char * action_rule_name(const struct action *action)
bool action_id_exists(const action_id act_id)
enum action_target_kind action_get_target_kind(const struct action *paction)
struct action_enabler_list * action_enablers_for_action(action_id action)
#define action_by_result_iterate(_paction_, _result_)
#define action_enablers_iterate_end
#define enabler_get_action(_enabler_)
#define enabler_get_action_id(_enabler_)
static struct action * action_by_number(action_id act_id)
#define action_has_result(_act_, _res_)
#define action_enabler_list_iterate_end
#define action_by_result_iterate_end
#define action_iterate_end
#define action_id_get_actor_kind(act_id)
#define action_enablers_iterate(_enabler_)
#define action_enabler_list_iterate(action_enabler_list, aenabler)
#define action_iterate(_act_)
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)
bool actres_is_hostile(enum action_result result)
int ai_type_number(const struct ai_type *ai)
const char * astr_build_or_list(struct astring *astr, const char *const *items, size_t number)
void astr_set(struct astring *astr, const char *format,...)
const char * astr_build_and_list(struct astring *astr, const char *const *items, size_t number)
#define BV_DEFINE(name, bits)
#define BV_ISSET(bv, bit)
struct output_type * get_output_type(Output_type_id output)
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
#define city_tile(_pcity_)
#define city_owner(_pcity_)
int combat_bonus_against(const struct combat_bonus_list *list, const struct unit_type *enemy, enum combat_bonus_type type)
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 effect_universals_value_never_below(enum effect_type type, struct universal *unis, size_t n_unis, int min_value)
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct req_context *other_context, enum effect_type effect_type)
int effect_cumulative_max(enum effect_type type, struct universal *unis, size_t n_unis)
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)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
enum output_type_id Output_type_id
void user_flag_init(struct user_flag *flag)
void user_flag_free(struct user_flag *flag)
static bool is_ruleset_compat_mode(void)
bool can_player_build_improvement_direct(const struct player *p, const struct impr_type *pimprove)
bool great_wonder_is_built(const struct impr_type *pimprove)
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
struct city * city_from_wonder(const struct player *pplayer, const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
bool is_small_wonder(const struct impr_type *pimprove)
struct player * great_wonder_owner(const struct impr_type *pimprove)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
static int map_move_cost(const struct civ_map *nmap, const struct player *pplayer, const struct unit_type *punittype, const struct tile *src_tile, const struct tile *dst_tile)
#define fc_calloc(n, esz)
const char * move_points_text(int mp, bool reduce)
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
static void names_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name, const char *rule_name)
static bool is_barbarian(const struct player *pplayer)
bool is_req_in_vec(const struct requirement *req, const struct requirement_vector *vec)
bool is_req_active(const struct req_context *context, const struct req_context *other_context, const struct requirement *req, const enum req_problem_type prob_type)
bool does_req_contradicts_reqs(const struct requirement *req, const struct requirement_vector *vec)
void req_copy(struct requirement *dst, const struct requirement *src)
#define requirement_fulfilled_by_unit_type(_ut_, _rqs_)
#define requirement_diplrel_ereq(_id_, _range_, _present_)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
bool road_provides_move_bonus(const struct road_type *proad)
struct setting_list * level[OLEVELS_NUM]
#define CLIP(lower, current, upper)
void strvec_destroy(struct strvec *psv)
enum action_result result
struct packet_ruleset_control control
struct packet_game_info info
struct packet_scenario_info scenario
struct veteran_system * veteran
const struct player * player
Unit_Class_id item_number
struct unit_class_list * subset_movers
struct extra_type_list * refuel_extras
struct extra_type_list * native_tile_extras
struct unit_class::@86 cache
struct extra_type_list * native_bases
struct extra_type_list * bonus_roads
struct extra_type_list * hiding_extras
struct requirement_vector build_reqs
struct veteran_system * veteran
const struct unit_type * obsoleted_by
struct combat_bonus_list * bonuses
const struct unit_type * utype
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_strcasecmp(const char *str0, const char *str1)
int cat_snprintf(char *str, size_t n, const char *format,...)
struct advance * advance_by_number(const Tech_type_id atype)
#define terrain_type_iterate(_p)
#define is_ocean(pterrain)
#define terrain_type_iterate_end
struct city * tile_city(const struct tile *ptile)
enum citytile_type citytile
enum ustate_prop unit_state
int unit_shield_value(const struct unit *punit, const struct unit_type *punittype, const struct action *paction)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
bool utype_may_act_tgt_city_tile(const struct unit_type *punit_type, const action_id act_id, const enum citytile_type prop, const bool is_there)
int utype_buy_gold_cost(const struct city *pcity, const struct unit_type *punittype, int shields_in_stock)
void unit_types_init(void)
bool can_unit_act_when_ustate_is(const struct unit_type *punit_type, const enum ustate_prop prop, const bool is_there)
const char * uclass_name_translation(const struct unit_class *pclass)
void set_unit_class_caches(struct unit_class *pclass)
struct unit_type * best_role_unit(const struct city *pcity, int role)
static struct unit_type unit_types[U_LAST]
struct unit_type * role_units_iterate(int role, role_unit_callback cb, void *data)
bool utype_action_takes_all_mp(const struct unit_type *putype, struct action *paction)
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
const struct unit_type * unit_type_get(const struct unit *punit)
bool utype_has_class_flag(const struct unit_type *ptype, enum unit_class_flag_id flag)
void user_unit_type_flags_init(void)
int utype_pays_mp_for_action_base(const struct action *paction, const struct unit_type *putype)
bool utype_player_already_has_this(const struct player *pplayer, const struct unit_type *putype)
static struct range * moves_left_range(struct requirement_vector *reqs)
bool utype_can_freely_unload(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
const char * unit_class_flag_helptxt(enum unit_class_flag_id id)
bool utype_pays_for_regular_move_to_tgt(const struct action *paction, const struct unit_type *utype)
static void unit_type_free(struct unit_type *punittype)
struct unit_type * role_units_iterate_backwards(int role, role_unit_callback cb, void *data)
static void precalc_one(int i, bool(*func_has)(const struct unit_type *, int))
static struct user_flag user_class_flags[MAX_NUM_USER_UCLASS_FLAGS]
static bv_diplrel_all_reqs dipl_rel_action_cache[U_LAST][ACTION_AND_FAKES]
bool utype_can_remove_extra(const struct unit_type *putype, const struct extra_type *pextra)
int unit_build_shield_cost(const struct city *pcity, const struct unit *punit)
const char * unit_name_translation(const struct unit *punit)
static bv_unit_types utype_act_takes_all_mp_ustate_cache[ACTION_COUNT][USP_COUNT]
bool unit_has_class_flag(const struct unit *punit, enum unit_class_flag_id flag)
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype, bool consider_reg_impr_req)
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
bool is_tech_req_for_utype(const struct unit_type *ptype, struct advance *padv)
static bv_citytile_cache ctile_tgt_act_cache[U_LAST][ACTION_AND_FAKES]
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
enum unit_move_type utype_move_type(const struct unit_type *punittype)
struct unit_type * first_role_unit_for_player(const struct player *pplayer, int role)
Unit_Class_id uclass_count(void)
bool utype_is_cityfounder(const struct unit_type *utype)
const struct unit_class * unit_class_array_last(void)
struct unit_type * unit_type_by_rule_name(const char *name)
struct unit_type * get_role_unit(int role, int role_index)
struct unit_type * unit_type_array_first(void)
void unit_class_flags_free(void)
bool uclass_flag_is_in_use(enum unit_class_flag_id ucflag)
const char * unit_rule_name(const struct unit *punit)
bool utype_has_role(const struct unit_type *punittype, int role)
static enum unit_move_type move_type_from_extra(struct extra_type *pextra, struct unit_class *puc)
void set_unit_move_type(struct unit_class *puclass)
static bv_diplrel_all_reqs dipl_rel_tile_other_tgt_a_cache[U_LAST][ACTION_AND_FAKES]
void unit_type_action_cache_init(void)
static void local_dipl_rel_tile_other_tgt_action_cache_set(struct unit_type *putype)
int utype_build_shield_cost_base(const struct unit_type *punittype)
void set_unit_type_caches(struct unit_type *ptype)
const char * unit_type_flag_id_name_update_cb(const char *old_name)
bool utype_may_act_move_frags(const struct unit_type *punit_type, const action_id act_id, const int move_fragments)
const struct veteran_system * utype_veteran_system(const struct unit_type *punittype)
bool utype_is_consumed_by_action_result(enum action_result result, const struct unit_type *utype)
int num_role_units(int role)
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
static bv_unit_types utype_act_takes_all_mp_cache[ACTION_COUNT]
static bool utype_can_do_action_role(const struct unit_type *putype, const int role)
void unit_types_free(void)
bool utype_may_act_at_all(const struct unit_type *putype)
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)
struct unit_type * best_role_unit_for_player(const struct player *pplayer, int role)
void role_unit_precalcs(void)
struct unit_class * uclass_by_number(const Unit_Class_id id)
bool utype_can_create_extra(const struct unit_type *putype, const struct extra_type *pextra)
static void local_dipl_rel_action_cache_set(struct unit_type *putype)
static void tgt_citytile_act_cache_set(struct unit_type *putype)
struct advance * utype_primary_tech_req(const struct unit_type *ptype)
bool utype_can_freely_load(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
void veteran_system_definition(struct veteran_system *vsystem, int level, const char *vlist_name, int vlist_power, int vlist_move, int vlist_raise, int vlist_wraise)
#define MOVES_LEFT_INFINITY
#define requirement_citytile_ereq(_id_, _present_)
Unit_type_id utype_count(void)
static void unit_state_action_cache_set(struct unit_type *putype)
static bv_ustate_act_cache ustate_act_cache[U_LAST][ACTION_AND_FAKES]
int utype_veteran_levels(const struct unit_type *punittype)
int utype_pays_mp_for_action_estimate(const struct civ_map *nmap, const struct action *paction, const struct unit_type *putype, const struct player *act_player, const struct tile *act_tile, const struct tile *tgt_tile)
bool utype_can_do_act_when_ustate(const struct unit_type *punit_type, const action_id act_id, const enum ustate_prop prop, const bool is_there)
void veteran_system_destroy(struct veteran_system *vsystem)
const char * utype_rule_name(const struct unit_type *punittype)
struct unit_class * unit_class_get(const struct unit *punit)
bool utype_can_do_action_result_when_ustate(const struct unit_type *putype, enum action_result result, const enum ustate_prop prop, const bool is_there)
struct unit_type * utype_by_number(const Unit_type_id id)
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)
static void unit_can_act_cache_set(struct unit_type *putype)
bool utype_action_takes_all_mp_if_ustate_is(const struct unit_type *putype, struct action *paction, const enum ustate_prop prop)
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 unit_can_take_over(const struct unit *punit)
static bv_unit_types unit_can_act_cache[ACTION_AND_FAKES]
void unit_classes_free(void)
void unit_type_action_cache_set(struct unit_type *ptype)
const char * uclass_rule_name(const struct unit_class *pclass)
const char * unit_class_flag_id_name_cb(enum unit_class_flag_id flag)
bool utype_is_consumed_by_action(const struct action *paction, const struct unit_type *utype)
void unit_type_flags_free(void)
static void utype_act_takes_all_mp_cache_set(struct unit_type *putype)
static void utype_act_takes_all_mp_ustate_cache_set(struct unit_type *putype)
Unit_type_id utype_number(const struct unit_type *punittype)
const char * unit_type_flag_id_name_cb(enum unit_type_flag_id flag)
bool utype_veteran_has_power_bonus(const struct unit_type *punittype)
void user_unit_class_flags_init(void)
bool utype_can_act_if_tgt_diplrel_tile_other(const struct unit_type *punit_type, const action_id act_id, const int prop, const bool is_there)
struct unit_class * unit_class_by_rule_name(const char *s)
struct unit_type * unit_type_by_translated_name(const char *name)
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
const char * utype_values_string(const struct unit_type *punittype)
void * utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai)
struct unit_class * unit_class_array_first(void)
Unit_type_id utype_index(const struct unit_type *punittype)
void unit_classes_init(void)
bool utype_flag_is_in_use(enum unit_type_flag_id uflag)
static struct user_flag user_type_flags[MAX_NUM_USER_UNIT_FLAGS]
int utype_pop_value(const struct unit_type *punittype, const struct city *pcity)
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)
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
bool can_player_build_unit_later(const struct player *p, const struct unit_type *punittype)
static struct unit_class unit_classes[UCL_LAST]
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
int unit_pop_value(const struct unit *punit)
#define requirement_unit_state_ereq(_id_, _present_)
void role_unit_precalcs_free(void)
struct veteran_system * veteran_system_new(int count)
Unit_Class_id uclass_number(const struct unit_class *pclass)
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
bool utype_can_do_action_sub_result(const struct unit_type *putype, enum action_sub_result sub_result)
static struct unit_type ** with_role[MAX_UNIT_ROLES]
bool utype_is_unmoved_by_action(const struct action *paction, const struct unit_type *utype)
bool utype_acts_hostile(const struct unit_type *putype)
bool utype_can_do_act_if_tgt_citytile(const struct unit_type *punit_type, const action_id act_id, const enum citytile_type prop, const bool is_there)
const char * utype_name_translation(const struct unit_type *punittype)
static int n_with_role[MAX_UNIT_ROLES]
bool can_utype_do_act_if_tgt_diplrel(const struct unit_type *punit_type, const action_id act_id, const int prop, const bool is_there)
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
int utype_happy_cost(const struct unit_type *ut, const struct player *pplayer)
bool role_units_translations(struct astring *astr, int flag, bool alts)
const char * utype_values_translation(const struct unit_type *punittype)
const struct unit_type * unit_type_array_last(void)
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
#define UCF_LAST_USER_FLAG
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define utype_fuel(ptype)
#define combat_bonus_list_iterate_end
#define combat_bonus_list_iterate(bonuslist, pbonus)
#define unit_tech_reqs_iterate_end
#define unit_class_iterate(_p)
#define unit_tech_reqs_iterate(_utype_, _p)
#define MAX_NUM_USER_UNIT_FLAGS
static bool utype_has_flag(const struct unit_type *punittype, int flag)
#define UTYF_LAST_USER_FLAG
bool(* role_unit_callback)(struct unit_type *ptype, void *data)
#define unit_type_iterate(_p)
#define uclass_index(_c_)
#define unit_class_iterate_end
#define unit_type_iterate_end
#define MAX_NUM_USER_UCLASS_FLAGS