36 #define MAX_UNIT_ROLES L_LAST + ACTION_COUNT
126 int val = ut->
upkeep[otype], gold_upkeep_factor;
143 if (gold_upkeep_factor > 0) {
168 const struct player *pplayer)
177 enum unit_type_flag_id flag)
208 return unit_owner(punit)->ai_common.barbarian_type != ANIMAL_BARBARIAN
253 switch (paction->
result) {
254 case ACTRES_SPY_INVESTIGATE_CITY:
255 case ACTRES_SPY_POISON:
256 case ACTRES_SPY_STEAL_GOLD:
257 case ACTRES_SPY_SABOTAGE_CITY:
258 case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
259 case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION:
260 case ACTRES_SPY_STEAL_TECH:
261 case ACTRES_SPY_TARGETED_STEAL_TECH:
262 case ACTRES_SPY_INCITE_CITY:
263 case ACTRES_SPY_BRIBE_UNIT:
264 case ACTRES_SPY_SABOTAGE_UNIT:
265 case ACTRES_CAPTURE_UNITS:
266 case ACTRES_STEAL_MAPS:
268 case ACTRES_SPY_NUKE:
270 case ACTRES_NUKE_CITY:
271 case ACTRES_NUKE_UNITS:
272 case ACTRES_DESTROY_CITY:
273 case ACTRES_EXPEL_UNIT:
274 case ACTRES_STRIKE_BUILDING:
275 case ACTRES_STRIKE_PRODUCTION:
277 case ACTRES_CONQUER_CITY:
279 case ACTRES_SPY_ATTACK:
280 case ACTRES_SPY_SPREAD_PLAGUE:
282 case ACTRES_ESTABLISH_EMBASSY:
283 case ACTRES_TRADE_ROUTE:
284 case ACTRES_MARKETPLACE:
285 case ACTRES_HELP_WONDER:
286 case ACTRES_FOUND_CITY:
287 case ACTRES_JOIN_CITY:
288 case ACTRES_RECYCLE_UNIT:
289 case ACTRES_DISBAND_UNIT:
290 case ACTRES_HOME_CITY:
291 case ACTRES_UPGRADE_UNIT:
292 case ACTRES_PARADROP:
294 case ACTRES_HEAL_UNIT:
295 case ACTRES_TRANSFORM_TERRAIN:
296 case ACTRES_CULTIVATE:
298 case ACTRES_CLEAN_POLLUTION:
299 case ACTRES_CLEAN_FALLOUT:
305 case ACTRES_IRRIGATE:
306 case ACTRES_TRANSPORT_ALIGHT:
307 case ACTRES_TRANSPORT_UNLOAD:
308 case ACTRES_TRANSPORT_DISEMBARK:
309 case ACTRES_TRANSPORT_BOARD:
310 case ACTRES_TRANSPORT_EMBARK:
323 #define ACTION_HOSTILE ACTION_COUNT + 1
326 #define ACTION_AND_FAKES ACTION_HOSTILE + 1
357 &(enabler->actor_reqs))) {
403 enum action_result
result)
454 #define requirement_unit_state_ereq(_id_, _present_) \
455 requirement_kind_ereq(_id_, REQ_RANGE_LOCAL, _present_, USP_COUNT)
456 #define requirement_citytile_ereq(_id_, _present_) \
457 requirement_kind_ereq(_id_, REQ_RANGE_LOCAL, _present_, CITYT_LAST)
487 req.
range = REQ_RANGE_LOCAL;
555 tile_is_claimed.
range = REQ_RANGE_LOCAL;
558 tile_is_claimed.
present =
true;
562 req.
range = REQ_RANGE_LOCAL;
581 &enabler->target_reqs))) {
588 REQ_RANGE_LOCAL, req.
present));
592 REQ_RANGE_LOCAL, req.
present));
596 REQ_RANGE_LOCAL, req.
present));
629 req.
range = REQ_RANGE_LOCAL;
677 #define MOVES_LEFT_INFINITY -1
685 auto *prange =
new range;
692 if (preq->source.kind == VUT_MINMOVES) {
694 prange->min = preq->source.value.minmoves;
696 prange->max = preq->source.value.minmoves;
734 const enum ustate_prop prop,
748 const enum ustate_prop prop,
765 const enum citytile_type prop,
806 const int move_fragments)
808 struct range *ml_range;
841 &(enabler->actor_reqs))) {
847 if (ml_range->
min <= move_fragments
849 || ml_range->
max > move_fragments)) {
872 const enum citytile_type prop,
904 req.
range = REQ_RANGE_LOCAL;
917 &(enabler->actor_reqs))) {
996 case MAK_UNREPRESENTABLE:
1037 case MAK_UNREPRESENTABLE:
1106 const struct player *act_player,
1107 const struct tile *act_tile,
1108 const struct tile *tgt_tile)
1110 const struct tile *post_action_tile;
1114 post_action_tile = tgt_tile;
1118 post_action_tile = act_tile;
1131 nullptr, act_player,
nullptr,
tile_city(post_action_tile),
nullptr,
1132 tgt_tile,
nullptr, putype,
nullptr,
nullptr, paction,
1133 EFT_ACTION_SUCCESS_MOVE_COST);
1148 if (pcity !=
nullptr) {
1159 EFT_UNIT_BUILD_COST_PCT))
1177 const struct unit *punit)
1195 int shields_in_stock)
1204 cost = 2 * missing + (missing * missing) / 20;
1207 if (shields_in_stock == 0) {
1211 if (pcity !=
nullptr) {
1222 EFT_UNIT_BUY_COST_PCT))
1294 static char buffer[256];
1312 static char buffer[256];
1349 astr = QString(
_(
"%1 or similar units"))
1352 astr = QString(
_(
"%1 and similar units"))
1356 }
else if (0 < count) {
1360 for (
int i = 0; i < count; i++) {
1382 const struct unit_type *upgrade = punittype;
1383 const struct unit_type *best_upgrade =
nullptr;
1394 best_upgrade = upgrade;
1398 return best_upgrade;
1417 int base_cost = 2 * missing + (missing * missing) / 20;
1419 return base_cost * (100 +
get_player_bonus(pplayer, EFT_UPGRADE_PRICE_PCT))
1446 const char *qname =
Qn_(
name);
1465 const char *qs =
Qn_(s);
1494 const char *
name,
const char *helptxt)
1496 int ufid =
id - UCF_USER_FLAG_1;
1514 if (helptxt && helptxt[0] !=
'\0') {
1557 const char *
name,
const char *helptxt)
1559 int ufid =
id - UTYF_USER_FLAG_1;
1569 if (helptxt && helptxt[0] !=
'\0') {
1664 if (preq->source.kind == VUT_IMPROVEMENT && preq->range == REQ_RANGE_CITY
1681 p, preq->source.value.building)) {
1686 if (preq->range < REQ_RANGE_PLAYER) {
1690 if (!
is_req_active(p,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
1691 punittype,
nullptr,
nullptr,
nullptr, preq,
1792 bool (*func_has)(
const struct unit_type *,
int))
1800 if (func_has(u, i)) {
1811 if (func_has(u, i)) {
1907 if (role_index == -1) {
2022 if (
nullptr != punittype->
helptext) {
2025 requirement_vector_free(&(punittype->
build_reqs));
2035 combat_bonus_list_destroy(punittype->
bonuses);
2103 #ifndef uclass_index
2131 if (id < 0 || id >=
game.
control.num_unit_classes) {
2144 return punittype->
uclass;
2311 const char *vlist_name,
int vlist_power,
2312 int vlist_move,
int vlist_raise,
2376 bool subset_mover =
true;
2382 subset_mover =
false;
2392 subset_mover =
false;
2418 CBONUS_DEFENSE_MULTIPLIER_PCT)
2421 CBONUS_DEFENSE_MULTIPLIER);
2438 bool land_allowed =
true;
2439 bool sea_allowed =
true;
2442 return unit_move_type_invalid();
2445 return unit_move_type_invalid();
2451 sea_allowed =
false;
2456 if (preq->source.kind == VUT_TERRAINCLASS) {
2457 if (!preq->present) {
2458 if (preq->source.value.terrainclass == TC_LAND) {
2459 land_allowed =
false;
2460 }
else if (preq->source.value.terrainclass == TC_OCEAN) {
2461 sea_allowed =
false;
2464 if (preq->source.value.terrainclass == TC_LAND) {
2465 sea_allowed =
false;
2466 }
else if (preq->source.value.terrainclass == TC_OCEAN) {
2467 land_allowed =
false;
2470 }
else if (preq->source.kind == VUT_TERRAIN) {
2471 if (!preq->present) {
2472 if (preq->source.value.terrain->tclass == TC_LAND) {
2473 land_allowed =
false;
2474 }
else if (preq->source.value.terrain->tclass == TC_OCEAN) {
2475 sea_allowed =
false;
2478 if (preq->source.value.terrain->tclass == TC_LAND) {
2479 sea_allowed =
false;
2480 }
else if (preq->source.value.terrain->tclass == TC_OCEAN) {
2481 land_allowed =
false;
2488 if (land_allowed && sea_allowed) {
2491 if (land_allowed && !sea_allowed) {
2494 if (!land_allowed && sea_allowed) {
2498 return unit_move_type_invalid();
2506 bool land_moving =
false;
2507 bool sea_moving =
false;
2513 if (eut == UMT_BOTH) {
2516 }
else if (eut == UMT_LAND) {
2518 }
else if (eut == UMT_SEA) {
2536 if (land_moving && sea_moving) {
2538 }
else if (sea_moving) {
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Get the actor kind of an action.
struct action * action_by_number(action_id act_id)
Return the action with the given id.
bool action_actor_utype_hard_reqs_ok(enum action_result result, const struct unit_type *actor_unittype)
Returns TRUE if the specified unit type can perform an action with the wanted result given that an ac...
bool action_id_exists(const action_id act_id)
Returns TRUE iff the specified action ID refers to a valid action.
bool action_has_result(const struct action *paction, enum action_result result)
Returns TRUE iff performing the specified action has the specified result.
const char * action_id_rule_name(action_id act_id)
Get the rule name of the action.
struct action_enabler_list * action_enablers_for_action(action_id action)
Get all enablers for an action in the current ruleset.
#define action_enablers_iterate_end
#define action_enabler_list_iterate_end
#define action_by_result_iterate_end
#define action_by_result_iterate(_paction_, _act_id_, _result_)
#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_)
#define action_id_get_target_kind(act_id)
int ai_type_number(const struct ai_type *ai)
Returns id of the given ai_type.
QString strvec_to_and_list(const QVector< QString > &psv)
QString strvec_to_or_list(const QVector< QString > &psv)
bool BV_ISSET(const BV &bv, int bit)
struct output_type * get_output_type(Output_type_id output)
Return the output type for this index.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit; returns FALSE if unit is obsolete.
int combat_bonus_against(const struct combat_bonus_list *list, const struct unit_type *enemy, enum combat_bonus_type type)
Get bonus value against given unit type from bonus list.
static void base(QVariant data1, QVariant data2)
Action "Build Base" for choice dialog.
int get_target_bonus_effects(struct effect_list *plist, const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, enum effect_type effect_type, enum vision_layer vision_layer, enum national_intelligence nintel)
Returns the effect bonus of a given type for any target.
int get_player_output_bonus(const struct player *pplayer, const struct output_type *poutput, enum effect_type effect_type)
Returns the player effect bonus of an output.
int get_unittype_bonus(const struct player *pplayer, const struct tile *ptile, const struct unit_type *punittype, enum effect_type effect_type, enum vision_layer vision_layer)
Returns the effect bonus that applies at a tile for a given unittype.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
enum output_type_id Output_type_id
void user_flag_init(struct user_flag *flag)
Initialize user flag.
void user_flag_free(struct user_flag *flag)
Free user flag.
bool can_player_build_improvement_direct(const struct player *p, const struct impr_type *pimprove)
Whether player can build given building somewhere, ignoring whether it is obsolete.
bool great_wonder_is_built(const struct impr_type *pimprove)
Returns whether this wonder is currently built.
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
Returns whether this wonder has been destroyed.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
struct player * great_wonder_owner(const struct impr_type *pimprove)
Get the player owning this small wonder.
#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)
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
This terrain is native to unit class.
const char * move_points_text(int mp, bool reduce)
Simple version of move_points_text_full() – render positive movement points as text without any prefi...
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)
Returns TRUE iff the requirement vector vec contains the requirement req.
bool is_req_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement *req, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement to see if it is active on the given target.
bool does_req_contradicts_reqs(const struct requirement *req, const struct requirement_vector *vec)
Returns TRUE if the given requirement contradicts the given requirement vector.
#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)
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Check if road provides effect.
bool road_provides_move_bonus(const struct road_type *proad)
Does road type provide move bonus.
struct setting_list * level[OLEVELS_NUM]
struct action::@10::@11 is_unit
bool actor_consuming_always
enum action_result result
struct packet_ruleset_control control
struct packet_game_info info
struct packet_scenario_info scenario
struct veteran_system * veteran
struct unit_class::@81 cache
Unit_Class_id item_number
enum unit_move_type move_type
struct unit_class_list * subset_movers
struct extra_type_list * native_tile_extras
struct extra_type_list * bonus_roads
QVector< QString > * helptext
struct extra_type_list * refuel_bases
struct name_translation name
struct unit_class * uclass
void * ais[FREECIV_AI_MOD_LAST]
struct requirement_vector build_reqs
QVector< QString > * helptext
struct veteran_system * veteran
const struct unit_type * obsoleted_by
struct advance * require_advance
struct unit_type::@83 cache
struct name_translation name
bv_unit_classes disembarks
int defense_mp_bonuses_pct[U_LAST]
struct combat_bonus_list * bonuses
const struct unit_type * utype
struct name_translation name
struct veteran_level * definitions
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
int cat_snprintf(char *str, size_t n, const char *format,...)
cat_snprintf is like a combination of fc_snprintf and fc_strlcat; it does snprintf to the end of an e...
Tech_type_id advance_index(const struct advance *padvance)
Return the advance index.
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
#define terrain_type_iterate(_p)
#define is_ocean(pterrain)
#define terrain_type_iterate_end
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
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)
Returns how many shields the unit (type) is worth.
#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)
Return TRUE iff the given (action enabler controlled) action may be performed by a unit of the given ...
int utype_buy_gold_cost(const struct city *pcity, const struct unit_type *punittype, int shields_in_stock)
Returns the amount of gold it takes to rush this unit.
bool can_unit_act_when_ustate_is(const struct unit_type *punit_type, const enum ustate_prop prop, const bool is_there)
Return TRUE iff there exists an (action enabler controlled) action that a unit of the type punit_type...
const struct unit_class * unit_class_array_last()
Return the last item of unit_classes.
const char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.
void set_unit_class_caches(struct unit_class *pclass)
Set caches for unit class.
static struct unit_type unit_types[U_LAST]
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
struct unit_type * best_role_unit(const struct city *pcity, int role)
Return "best" unit this city can build, with given role/flag.
int utype_pop_value(const struct unit_type *punittype)
How much city shrinks when it builds unit of this type.
const char * uclass_name_translation(const struct unit_class *pclass)
Return the (translated) name of the unit class.
int utype_pays_mp_for_action_base(const struct action *paction, const struct unit_type *putype)
Returns the amount of movement points successfully performing the specified action will consume in th...
const char * unit_type_flag_id_name_cb(enum unit_type_flag_id flag)
Unit type flag name callback, called from specenum code.
struct unit_type * utype_by_number(const Unit_type_id id)
Return a pointer for the unit type struct for the given unit type id.
bool utype_can_freely_unload(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
Return TRUE iff the given cargo type has no restrictions on when it can unload from the given transpo...
bool utype_pays_for_regular_move_to_tgt(const struct action *paction, const struct unit_type *utype)
Returns TRUE iff successfully performing the specified action always will cost the actor unit of the ...
static void unit_type_free(struct unit_type *punittype)
Frees the memory associated with this unit type.
const char * utype_values_translation(const struct unit_type *punittype)
Return string with translated unit name and list of its values.
static void precalc_one(int i, bool(*func_has)(const struct unit_type *, int))
Do the real work for role_unit_precalcs, for one role (or flag), given by i.
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]
int unit_build_shield_cost(const struct city *pcity, const struct unit *punit)
Returns the number of shields it takes to build this unit.
const char * unit_class_flag_helptxt(enum unit_class_flag_id id)
Return the (untranslated) help text of the user unit class flag.
BV_DEFINE(bv_ustate_act_cache, USP_COUNT *2)
struct unit_type * unit_type_array_first()
Return the first item of unit_types.
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
Returns TRUE iff successfully performing the specified action always will move the actor unit of the ...
const struct unit_type * unit_type_array_last()
Return the last item of unit_types.
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)
Returns the upkeep of a unit of this type under the given government.
enum unit_move_type utype_move_type(const struct unit_type *punittype)
Return move type of the unit type.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
struct unit_type * best_role_unit_for_player(const struct player *pplayer, int role)
Return "best" unit the player can build, with given role/flag.
bool utype_is_cityfounder(const struct unit_type *utype)
Is cityfounder type.
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Return whether this player can upgrade this unit type (to any other unit type).
void unit_classes_init()
Initialize unit_class structures.
void unit_class_flags_free()
Frees the memory associated with all unit class flags.
bool utype_has_role(const struct unit_type *punittype, int role)
Return whether the given unit type has the role.
static enum unit_move_type move_type_from_extra(struct extra_type *pextra, struct unit_class *puc)
What move types nativity of this extra will give?
void set_unit_move_type(struct unit_class *puclass)
Set move_type for unit class.
int utype_build_shield_cost(const struct city *pcity, const struct unit_type *punittype)
Returns the number of shields it takes to build this unit type.
static bool action_is_hostile(action_id act_id)
Returns TRUE iff the specified action is hostile.
Unit_type_id utype_count()
Return the number of unit types.
int utype_build_shield_cost_base(const struct unit_type *punittype)
Returns the number of shields this unit type represents.
void set_unit_type_caches(struct unit_type *ptype)
Set caches for unit types.
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
Return the (untranslated) helptxt of the user unit flag.
bool utype_may_act_move_frags(const struct unit_type *punit_type, const action_id act_id, const int move_fragments)
Return TRUE iff the given (action enabler controlled) action may be performed by a unit of the given ...
bool utype_is_consumed_by_action_result(enum action_result result, const struct unit_type *utype)
Returns TRUE iff performing an action with the specified action result will consume an actor unit of ...
static struct range * moves_left_range(struct requirement_vector *reqs)
Get the legal range of move fragments left of the specified requirement vector.
void user_unit_class_flags_init()
Initialize user unit class flags.
int num_role_units(int role)
How many unit types have specified role/flag.
static bool first_init
The following functions use static variables so we can quickly look up which unit types have given fl...
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Returns TRUE iff the unit type is unique and the player already has one.
static bool utype_can_do_action_role(const struct unit_type *putype, const int role)
Return TRUE iff the unit type can perform the action corresponding to the unit type role.
bool utype_may_act_at_all(const struct unit_type *putype)
Return TRUE iff units of this type can do actions controlled by generalized (ruleset defined) action ...
int unit_build_shield_cost_base(const struct unit *punit)
Returns the number of shields this unit represents.
struct unit_class * unit_class_by_rule_name(const char *s)
Returns the unit class that has the given (untranslated) rule name.
static void local_dipl_rel_action_cache_set(struct unit_type *putype)
Cache what actions may be possible for a unit of the type putype for each local DiplRel variation.
static void tgt_citytile_act_cache_set(struct unit_type *putype)
Cache if any action may be possible for a unit of the type putype for each target local city tile pro...
struct veteran_system * veteran_system_new(int count)
Allocate new veteran system structure with given veteran level count.
bool utype_can_freely_load(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
Return TRUE iff the given cargo type has no restrictions on when it can load onto the given transport...
void unit_classes_free()
Free resources allocated for unit classes.
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)
Fill veteran level in given veteran system with given information.
#define MOVES_LEFT_INFINITY
Unit_Class_id uclass_count()
Return the unit_class count.
struct unit_class * unit_class_get(const struct unit *punit)
Returns unit class pointer for a unit.
void unit_type_flags_free()
Frees the memory associated with all unit type flags.
const char * utype_values_string(const struct unit_type *punittype)
Return string describing unit type values.
#define requirement_citytile_ereq(_id_, _present_)
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype)
Whether player can build given unit somewhere, ignoring whether unit is obsolete and assuming the pla...
static void unit_state_action_cache_set(struct unit_type *putype)
Cache if any action may be possible for a unit of the type putype for each unit state property.
static bv_ustate_act_cache ustate_act_cache[U_LAST][ACTION_AND_FAKES]
void role_unit_precalcs_free()
Free memory allocated by role_unit_precalcs().
int utype_veteran_levels(const struct unit_type *punittype)
Return veteran levels of the given unit type.
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)
Return TRUE iff the unit type can do the specified (action enabler controlled) action while its unit ...
void veteran_system_destroy(struct veteran_system *vsystem)
Free veteran system.
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Return TRUE iff units of the given type can do any enabler controlled action with the specified actio...
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
Return whether the unit has the given role.
static void unit_can_act_cache_set(struct unit_type *putype)
Cache what generalized (ruleset defined) action enabler controlled actions a unit of the given type c...
bool role_units_translations(QString &astr, int flag, bool alts)
Return a string with all the names of units with this flag.
const struct veteran_system * utype_veteran_system(const struct unit_type *punittype)
Return veteran system used for this unit type.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
bool unit_can_take_over(const struct unit *punit)
Return whether the unit can take over enemy cities.
static bv_unit_types unit_can_act_cache[ACTION_AND_FAKES]
struct unit_type * unit_type_by_translated_name(const char *name)
Returns the unit type that has the given (translated) name.
void role_unit_precalcs()
Initialize; it is safe to call this multiple times (e.g., if units have changed due to rulesets in cl...
void unit_type_action_cache_set(struct unit_type *ptype)
Cache if any action may be possible for a unit of the type putype given the property tested for.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
void unit_types_init()
Inialize unit-type structures.
void user_unit_type_flags_init()
Initialize user unit type flags.
struct unit_class * uclass_by_number(const Unit_Class_id id)
Returns unit class pointer for an ID value.
int utype_pays_mp_for_action_estimate(const struct action *paction, const struct unit_type *putype, const struct player *act_player, const struct tile *act_tile, const struct tile *tgt_tile)
Returns an estimate of the amount of movement points successfully performing the specified action wil...
bool utype_is_consumed_by_action(const struct action *paction, const struct unit_type *utype)
Returns TRUE iff performing the specified action will consume an actor unit of the specified type.
struct unit_type * unit_type_by_rule_name(const char *name)
Returns the unit type that has the given (untranslated) rule name.
Unit_type_id utype_number(const struct unit_type *punittype)
Return the unit type index.
bool utype_veteran_has_power_bonus(const struct unit_type *punittype)
Return whether this unit type's veteran system, if any, confers a power factor bonus at any level (it...
const char * unit_class_flag_id_name_cb(enum unit_class_flag_id flag)
Unit class flag name callback, called from specenum code.
struct unit_type * get_role_unit(int role, int role_index)
Return index-th unit with specified role/flag.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
static struct user_flag user_type_flags[MAX_NUM_USER_UNIT_FLAGS]
bool utype_can_take_over(const struct unit_type *punittype)
Return whether the unit type can take over enemy cities.
void utype_set_ai_data(struct unit_type *ptype, const struct ai_type *ai, void *data)
Attach ai data to unit type.
struct unit_class * unit_class_array_first()
Return the first item of unit_classes.
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Sets user defined name for unit class flag.
const char * uclass_rule_name(const struct unit_class *pclass)
Return the (untranslated) rule name of the unit class.
const char * unit_name_translation(const struct unit *punit)
Return the (translated) name of the unit.
bool can_player_build_unit_later(const struct player *p, const struct unit_type *punittype)
Whether player can eventually build given unit somewhere – ie, returns TRUE if unit is available with...
static struct unit_class unit_classes[UCL_LAST]
int unit_pop_value(const struct unit *punit)
How much population is put to building this unit.
#define requirement_unit_state_ereq(_id_, _present_)
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Return translated name of the given veteran level.
Unit_Class_id uclass_number(const struct unit_class *pclass)
Return the unit_class index.
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
Whether player can build given unit somewhere; returns FALSE if unit is obsolete.
void unit_types_free()
Frees the memory associated with all unit types.
static struct unit_type ** with_role[MAX_UNIT_ROLES]
bool utype_is_unmoved_by_action(const struct action *paction, const struct unit_type *utype)
Returns TRUE iff successfully performing the specified action never will move the actor unit from its...
bool utype_acts_hostile(const struct unit_type *putype)
Return TRUE iff units of this type can do hostile actions controlled by generalized (ruleset defined)...
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)
Returns TRUE iff the unit type can do the specified (action enabler controlled) action while its targ...
struct unit_type * first_role_unit_for_player(const struct player *pplayer, int role)
Return first unit the player can build, with given role/flag.
void unit_type_action_cache_init()
Cache what unit types may be allowed do what actions, both at all and when certain properties are tru...
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)
Return TRUE iff the given (action enabler controlled) action can be performed by a unit of the given ...
struct unit_type * role_units_iterate_backwards(int role, role_unit_callback cb, void *data)
Iterate over all the role units and feed them to callback, starting from the last one.
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Sets user defined name for unit flag.
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Return veteran level properties of given unit in given veterancy level.
int utype_happy_cost(const struct unit_type *ut, const struct player *pplayer)
Return the "happy cost" (the number of citizens who are discontented) for this unit.
void * utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai)
Return pointer to ai data of given unit type and ai type.
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Return the cost (gold) of upgrading a single unit of the specified type to the new type.
#define UCF_LAST_USER_FLAG
#define utype_fuel(ptype)
#define combat_bonus_list_iterate_end
#define combat_bonus_list_iterate(bonuslist, pbonus)
#define unit_class_iterate(_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