Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
unit.h File Reference
#include "bitvector.h"
#include "base.h"
#include "fc_interface.h"
#include "fc_types.h"
#include "map_types.h"
#include "terrain.h"
#include "unittype.h"
#include "vision.h"
#include "specenum_gen.h"

Go to the source code of this file.

Data Structures

struct  unit_adv
 
struct  unit_order
 
struct  unit
 

Macros

#define SPECENUM_NAME   unit_ss_data_type
 
#define SPECENUM_VALUE0   USSDT_QUEUE
 
#define SPECENUM_VALUE1   USSDT_UNQUEUE
 
#define SPECENUM_VALUE2   USSDT_BATTLE_GROUP
 
#define SPECENUM_VALUE3   USSDT_SENTRY
 
#define SPECENUM_NAME   server_side_agent
 
#define SPECENUM_VALUE0   SSA_NONE
 
#define SPECENUM_VALUE0NAME   N_("?serveragent:None")
 
#define SPECENUM_VALUE1   SSA_AUTOSETTLER
 
#define SPECENUM_VALUE1NAME   N_("Autosettlers")
 
#define SPECENUM_VALUE2   SSA_AUTOEXPLORE
 
#define SPECENUM_VALUE2NAME   N_("Autoexplore")
 
#define SPECENUM_COUNT   SSA_COUNT
 
#define MAX_NUM_BATTLEGROUPS   (4)
 
#define BATTLEGROUP_NONE   (-1)
 
#define CHECK_UNIT(punit)   /* Do nothing */
 
#define activity_type_list_iterate(_act_list_, _act_)
 
#define activity_type_list_iterate_end
 
#define activity_type_iterate(_act_)
 
#define activity_type_iterate_end
 
#define tile_changing_activities_iterate(_act_)
 
#define tile_changing_activities_iterate_end
 
#define unit_home(_pu_)   (game_city_by_number((_pu_)->homecity))
 
#define is_unit_homeless(_pu_)   (punit->homecity == IDENTITY_NUMBER_ZERO)
 
#define unit_owner(_pu)   ((_pu)->owner)
 
#define unit_tile(_pu)   ((_pu)->tile)
 
#define unit_transported_server(_pcargo_)   ((_pcargo_)->transporter != NULL)
 
#define unit_transported_client(_pcargo_)
 
#define unit_transports_iterate(_pcargo, _ptrans)
 
#define unit_transports_iterate_end   }}
 
#define unit_cargo_iterate(_ptrans, _pcargo)
 
#define unit_cargo_iterate_end   generic_iterate_end
 

Enumerations

enum  unit_orders {
  ORDER_MOVE = 0 , ORDER_ACTIVITY = 1 , ORDER_FULL_MP = 2 , ORDER_ACTION_MOVE = 3 ,
  ORDER_PERFORM_ACTION = 4 , ORDER_LAST
}
 
enum  unit_focus_status { FOCUS_AVAIL , FOCUS_WAIT , FOCUS_DONE }
 
enum  goto_route_type { ROUTE_GOTO , ROUTE_PATROL }
 
enum  unit_upgrade_result {
  UU_OK , UU_NO_UNITTYPE , UU_NO_MONEY , UU_NOT_IN_CITY ,
  UU_NOT_CITY_OWNER , UU_NOT_ENOUGH_ROOM , UU_NOT_TERRAIN , UU_UNSUITABLE_TRANSPORT ,
  UU_NOT_ACTIVITY
}
 
enum  unit_airlift_result {
  AR_OK , AR_OK_SRC_UNKNOWN , AR_OK_DST_UNKNOWN , AR_NO_MOVES ,
  AR_WRONG_UNITTYPE , AR_OCCUPIED , AR_NOT_IN_CITY , AR_BAD_SRC_CITY ,
  AR_BAD_DST_CITY , AR_SRC_NO_FLIGHTS , AR_DST_NO_FLIGHTS
}
 

Functions

bool are_unit_orders_equal (const struct unit_order *order1, const struct unit_order *order2)
 
int unit_shield_value (const struct unit *punit, const struct unit_type *punittype, const struct action *paction)
 
bool unit_can_help_build_wonder_here (const struct civ_map *nmap, const struct unit *punit)
 
bool unit_can_est_trade_route_here (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 unit_can_airlift_to (const struct civ_map *nmap, const struct unit *punit, const struct city *pcity) fc__attribute((nonnull(3)))
 
bool unit_has_orders (const struct unit *punit)
 
bool could_unit_be_in_transport (const struct unit *pcargo, const struct unit *ptrans)
 
bool could_unit_load (const struct unit *pcargo, const struct unit *ptrans)
 
bool can_unit_load (const struct unit *punit, const struct unit *ptrans)
 
bool can_unit_unload (const struct unit *punit, const struct unit *ptrans)
 
bool can_unit_deboard_or_be_unloaded (const struct civ_map *nmap, const struct unit *pcargo, const struct unit *ptrans)
 
bool can_unit_teleport (const struct civ_map *nmap, const struct unit *punit)
 
bool can_unit_paradrop (const struct civ_map *nmap, const struct unit *punit)
 
bool can_unit_change_homecity_to (const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
 
bool can_unit_change_homecity (const struct civ_map *nmap, const struct unit *punit)
 
const charget_activity_text (enum unit_activity activity)
 
bool can_unit_continue_current_activity (const struct civ_map *nmap, struct unit *punit)
 
bool can_unit_do_activity (const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity)
 
bool can_unit_do_activity_targeted (const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, struct extra_type *target)
 
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)
 
void set_unit_activity (struct unit *punit, enum unit_activity new_activity)
 
void set_unit_activity_targeted (struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
 
int get_activity_rate (const struct unit *punit)
 
int get_activity_rate_this_turn (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 activity_requires_target (enum unit_activity activity)
 
bool can_unit_do_autosettlers (const struct unit *punit)
 
bool is_unit_activity_on_tile (enum unit_activity activity, const struct tile *ptile)
 
bv_extras get_unit_tile_pillage_set (const struct tile *ptile)
 
bool is_attack_unit (const struct unit *punit)
 
bool is_martial_law_unit (const struct unit *punit)
 
bool is_occupying_unit (const struct unit *punit)
 
bool is_enter_borders_unit (const struct unit *punit)
 
bool is_guard_unit (const struct unit *punit)
 
bool is_special_unit (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)
 
bool unit_can_do_action_sub_result (const struct unit *punit, enum action_sub_result sub_result)
 
bool is_square_threatened (const struct civ_map *nmap, const struct player *pplayer, const struct tile *ptile, bool omniscient)
 
bool is_field_unit (const struct unit *punit)
 
bool is_hiding_unit (const struct unit *punit)
 
bool unit_can_add_or_build_city (const struct civ_map *nmap, const struct unit *punit)
 
void unit_activity_astr (const struct unit *punit, struct astring *astr)
 
void unit_upkeep_astr (const struct unit *punit, struct astring *astr)
 
int get_transporter_capacity (const struct unit *punit)
 
struct playerunit_nationality (const struct unit *punit)
 
void unit_tile_set (struct unit *punit, struct tile *ptile)
 
struct unittile_allied_unit (const struct tile *ptile, const struct player *pplayer)
 
static bool is_allied_unit_tile (const struct tile *ptile, const struct player *pplayer)
 
struct unittile_enemy_unit (const struct tile *ptile, const struct player *pplayer)
 
static bool is_enemy_unit_tile (const struct tile *ptile, const struct player *pplayer)
 
struct unittile_non_allied_unit (const struct tile *ptile, const struct player *pplayer)
 
static bool is_non_allied_unit_tile (const struct tile *ptile, const struct player *pplayer)
 
struct unittile_other_players_unit (const struct tile *ptile, const struct player *pplayer)
 
static bool is_other_players_unit_tile (const struct tile *ptile, const struct player *pplayer)
 
struct unittile_non_attack_unit (const struct tile *ptile, const struct player *pplayer)
 
static bool is_non_attack_unit_tile (const struct tile *ptile, const struct player *pplayer)
 
struct unitunit_occupies_tile (const struct tile *ptile, const struct player *pplayer)
 
bool is_plr_zoc_srv (const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
 
bool is_plr_zoc_client (const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
 
static bool is_my_zoc (const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
 
bool unit_being_aggressive (const struct civ_map *nmap, const struct unit *punit)
 
bool unit_type_really_ignores_zoc (const struct unit_type *punittype)
 
bool is_build_activity (enum unit_activity activity)
 
bool is_clean_activity (enum unit_activity activity)
 
bool is_terrain_change_activity (enum unit_activity activity)
 
bool is_tile_activity (enum unit_activity activity)
 
bool is_targeted_activity (enum unit_activity activity)
 
struct unitunit_virtual_create (struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
 
void unit_virtual_destroy (struct unit *punit)
 
bool unit_is_virtual (const struct unit *punit)
 
void free_unit_orders (struct unit *punit)
 
int get_transporter_occupancy (const struct unit *ptrans)
 
struct unittransporter_for_unit (const struct unit *pcargo)
 
struct unittransporter_for_unit_at (const struct unit *pcargo, const struct tile *ptile)
 
enum unit_upgrade_result unit_transform_result (const struct civ_map *nmap, const struct unit *punit, const struct unit_type *to_unittype)
 
enum unit_upgrade_result unit_upgrade_test (const struct civ_map *nmap, const struct unit *punit, bool is_free)
 
enum unit_upgrade_result unit_upgrade_info (const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
 
bool unit_can_convert (const struct civ_map *nmap, const struct unit *punit)
 
int unit_pays_mp_for_action (const struct action *paction, const struct unit *punit)
 
int hp_gain_coord (const struct unit *punit)
 
int unit_gain_hitpoints (const struct unit *punit)
 
bool is_losing_hp (const struct unit *punit)
 
bool unit_type_is_losing_hp (const struct player *pplayer, const struct unit_type *punittype)
 
bool unit_is_alive (int id)
 
voidunit_ai_data (const struct unit *punit, const struct ai_type *ai)
 
void unit_set_ai_data (struct unit *punit, const struct ai_type *ai, void *data)
 
int unit_bribe_cost (struct unit *punit, struct player *briber)
 
bool unit_transport_load (struct unit *pcargo, struct unit *ptrans, bool force)
 
bool unit_transport_unload (struct unit *pcargo)
 
struct unitunit_transport_get (const struct unit *pcargo)
 
bool unit_transported (const struct unit *pcargo)
 
struct unit_list * unit_transport_cargo (const struct unit *ptrans)
 
bool unit_transport_check (const struct unit *pcargo, const struct unit *ptrans)
 
bool unit_contained_in (const struct unit *pcargo, const struct unit *ptrans)
 
int unit_cargo_depth (const struct unit *pcargo)
 
int unit_transport_depth (const struct unit *ptrans)
 
bool unit_is_cityfounder (const struct unit *punit)
 
size_t cargo_iter_sizeof (void) fc__attribute((const))
 
struct iteratorcargo_iter_init (struct cargo_iter *iter, const struct unit *ptrans)
 
bool unit_order_list_is_sane (const struct civ_map *nmap, int length, const struct unit_order *orders)
 
struct unit_ordercreate_unit_orders (const struct civ_map *nmap, int length, const struct unit_order *orders)
 

Variables

const Activity_type_id tile_changing_activities []
 

Macro Definition Documentation

◆ activity_type_iterate

#define activity_type_iterate (   _act_)
Value:
{ \
char * incite_cost
Definition comments.c:75
enum unit_activity Activity_type_id
Definition fc_types.h:379

Definition at line 284 of file unit.h.

◆ activity_type_iterate_end

#define activity_type_iterate_end
Value:
} \
}

Definition at line 289 of file unit.h.

◆ activity_type_list_iterate

#define activity_type_list_iterate (   _act_list_,
  _act_ 
)
Value:

Definition at line 273 of file unit.h.

◆ activity_type_list_iterate_end

#define activity_type_list_iterate_end
Value:
} \
}

Definition at line 279 of file unit.h.

◆ BATTLEGROUP_NONE

#define BATTLEGROUP_NONE   (-1)

Definition at line 190 of file unit.h.

◆ CHECK_UNIT

#define CHECK_UNIT (   punit)    /* Do nothing */

Definition at line 270 of file unit.h.

◆ is_unit_homeless

#define is_unit_homeless (   _pu_)    (punit->homecity == IDENTITY_NUMBER_ZERO)

Definition at line 395 of file unit.h.

◆ MAX_NUM_BATTLEGROUPS

#define MAX_NUM_BATTLEGROUPS   (4)

Definition at line 189 of file unit.h.

◆ SPECENUM_COUNT

#define SPECENUM_COUNT   SSA_COUNT

Definition at line 132 of file unit.h.

◆ SPECENUM_NAME [1/2]

Definition at line 106 of file unit.h.

◆ SPECENUM_NAME [2/2]

Definition at line 106 of file unit.h.

◆ SPECENUM_VALUE0 [1/2]

#define SPECENUM_VALUE0   USSDT_QUEUE

Definition at line 109 of file unit.h.

◆ SPECENUM_VALUE0 [2/2]

#define SPECENUM_VALUE0   SSA_NONE

Definition at line 109 of file unit.h.

◆ SPECENUM_VALUE0NAME

#define SPECENUM_VALUE0NAME   N_("?serveragent:None")

Definition at line 127 of file unit.h.

◆ SPECENUM_VALUE1 [1/2]

#define SPECENUM_VALUE1   USSDT_UNQUEUE

Definition at line 112 of file unit.h.

◆ SPECENUM_VALUE1 [2/2]

#define SPECENUM_VALUE1   SSA_AUTOSETTLER

Definition at line 112 of file unit.h.

◆ SPECENUM_VALUE1NAME

#define SPECENUM_VALUE1NAME   N_("Autosettlers")

Definition at line 129 of file unit.h.

◆ SPECENUM_VALUE2 [1/2]

#define SPECENUM_VALUE2   USSDT_BATTLE_GROUP

Definition at line 115 of file unit.h.

◆ SPECENUM_VALUE2 [2/2]

#define SPECENUM_VALUE2   SSA_AUTOEXPLORE

Definition at line 115 of file unit.h.

◆ SPECENUM_VALUE2NAME

#define SPECENUM_VALUE2NAME   N_("Autoexplore")

Definition at line 131 of file unit.h.

◆ SPECENUM_VALUE3

#define SPECENUM_VALUE3   USSDT_SENTRY

Definition at line 121 of file unit.h.

◆ tile_changing_activities_iterate

#define tile_changing_activities_iterate (   _act_)
Value:
{ \
const Activity_type_id tile_changing_activities[]
Definition unit.c:44

Definition at line 295 of file unit.h.

◆ tile_changing_activities_iterate_end

#define tile_changing_activities_iterate_end
Value:
}
#define activity_type_list_iterate_end
Definition unit.h:279

Definition at line 299 of file unit.h.

◆ unit_cargo_iterate

#define unit_cargo_iterate (   _ptrans,
  _pcargo 
)
Value:
generic_iterate(struct cargo_iter, struct unit *, _pcargo, \
#define generic_iterate(TYPE_it, TYPE_a, NAME_a, FUNC_size, FUNC_init,...)
Definition iterator.h:117
Definition unit.h:138
size_t cargo_iter_sizeof(void) fc__attribute((const))
struct iterator * cargo_iter_init(struct cargo_iter *iter, const struct unit *ptrans)
Definition unit.c:2624

Definition at line 570 of file unit.h.

◆ unit_cargo_iterate_end

#define unit_cargo_iterate_end   generic_iterate_end

Definition at line 573 of file unit.h.

◆ unit_home

#define unit_home (   _pu_)    (game_city_by_number((_pu_)->homecity))

Definition at line 394 of file unit.h.

◆ unit_owner

#define unit_owner (   _pu)    ((_pu)->owner)

Definition at line 396 of file unit.h.

◆ unit_tile

#define unit_tile (   _pu)    ((_pu)->tile)

Definition at line 397 of file unit.h.

◆ unit_transported_client

#define unit_transported_client (   _pcargo_)
Value:
((_pcargo_)->client.transported_by != -1 \
|| (_pcargo_)->transporter != NULL)
struct civclient client

Definition at line 544 of file unit.h.

◆ unit_transported_server

#define unit_transported_server (   _pcargo_)    ((_pcargo_)->transporter != NULL)

Definition at line 541 of file unit.h.

◆ unit_transports_iterate

#define unit_transports_iterate (   _pcargo,
  _ptrans 
)
Value:
{ \
struct unit *_ptrans; \
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2441

Definition at line 559 of file unit.h.

◆ unit_transports_iterate_end

#define unit_transports_iterate_end   }}

Definition at line 563 of file unit.h.

Enumeration Type Documentation

◆ goto_route_type

Enumerator
ROUTE_GOTO 
ROUTE_PATROL 

Definition at line 56 of file unit.h.

◆ unit_airlift_result

Enumerator
AR_OK 
AR_OK_SRC_UNKNOWN 
AR_OK_DST_UNKNOWN 
AR_NO_MOVES 
AR_WRONG_UNITTYPE 
AR_OCCUPIED 
AR_NOT_IN_CITY 
AR_BAD_SRC_CITY 
AR_BAD_DST_CITY 
AR_SRC_NO_FLIGHTS 
AR_DST_NO_FLIGHTS 

Definition at line 72 of file unit.h.

◆ unit_focus_status

Enumerator
FOCUS_AVAIL 
FOCUS_WAIT 
FOCUS_DONE 

Definition at line 52 of file unit.h.

◆ unit_orders

Enumerator
ORDER_MOVE 
ORDER_ACTIVITY 
ORDER_FULL_MP 
ORDER_ACTION_MOVE 
ORDER_PERFORM_ACTION 
ORDER_LAST 

Definition at line 37 of file unit.h.

◆ unit_upgrade_result

Enumerator
UU_OK 
UU_NO_UNITTYPE 
UU_NO_MONEY 
UU_NOT_IN_CITY 
UU_NOT_CITY_OWNER 
UU_NOT_ENOUGH_ROOM 
UU_NOT_TERRAIN 
UU_UNSUITABLE_TRANSPORT 
UU_NOT_ACTIVITY 

Definition at line 60 of file unit.h.

Function Documentation

◆ activity_requires_target()

bool activity_requires_target ( enum unit_activity  activity)

◆ are_unit_orders_equal()

bool are_unit_orders_equal ( const struct unit_order order1,
const struct unit_order order2 
)

Checks unit orders for equality.

Definition at line 59 of file unit.c.

Referenced by send_packet_city_rally_point_100(), send_packet_unit_info_100(), and send_packet_unit_orders_100().

◆ can_unit_change_homecity()

bool can_unit_change_homecity ( const struct civ_map nmap,
const struct unit punit 
)

Return TRUE iff the unit can change homecity at its current location.

Definition at line 481 of file unit.c.

Referenced by unit_item::create_actions(), mr_menu::menus_sensitive(), and real_menus_update().

◆ can_unit_change_homecity_to()

bool can_unit_change_homecity_to ( const struct civ_map nmap,
const struct unit punit,
const struct city pcity 
)

Return TRUE iff the unit can change homecity to the given city.

Definition at line 465 of file unit.c.

Referenced by can_unit_change_homecity(), create_unit_menu(), present_unit_callback(), and unit_actions::update_actions().

◆ can_unit_continue_current_activity()

bool can_unit_continue_current_activity ( const struct civ_map nmap,
struct unit punit 
)

◆ can_unit_deboard_or_be_unloaded()

bool can_unit_deboard_or_be_unloaded ( const struct civ_map nmap,
const struct unit pcargo,
const struct unit ptrans 
)

Return TRUE iff the given unit can leave its current transporter without doing any other action or move.

Definition at line 777 of file unit.c.

Referenced by unit_can_defend_here().

◆ can_unit_do_activity()

bool can_unit_do_activity ( const struct civ_map nmap,
const struct unit punit,
enum unit_activity  activity 
)

Return TRUE iff the unit can do the given untargeted activity at its current location.

Note that some activities must be targeted; see can_unit_do_activity_targeted().

Definition at line 868 of file unit.c.

Referenced by can_units_do_activity(), dai_military_findjob(), execute_orders(), handle_unit_sscs_set(), place_partisans(), unit_activity_handling(), unit_activity_internal(), and unit_server_side_agent_set().

◆ can_unit_do_activity_targeted()

bool can_unit_do_activity_targeted ( const struct civ_map nmap,
const struct unit punit,
enum unit_activity  activity,
struct extra_type target 
)

Return whether the unit can do the targeted activity at its current location.

Definition at line 907 of file unit.c.

Referenced by can_unit_continue_current_activity(), can_unit_do_activity(), can_units_do_activity_targeted(), unit_activity_handling_targeted(), unit_activity_targeted_internal(), and unit_assign_specific_activity_target().

◆ can_unit_do_activity_targeted_at()

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 
)

Return TRUE if the unit can do the targeted activity at the given location.

Definition at line 920 of file unit.c.

Referenced by can_unit_do_activity_targeted().

◆ can_unit_do_autosettlers()

bool can_unit_do_autosettlers ( const struct unit punit)

Return whether the unit can be put in auto-settler mode.

NOTE: we used to have "auto" mode including autosettlers and auto-attack. This was bad because the two were indestinguishable even though they are very different. Now auto-attack is done differently so we just have auto-settlers. If any new auto modes are introduced they should be handled separately.

Definition at line 606 of file unit.c.

Referenced by key_unit_auto_settle(), mr_menu::menus_sensitive(), real_menus_update(), request_unit_autosettlers(), unit_server_side_agent_set(), and unit_actions::update_actions().

◆ can_unit_load()

bool can_unit_load ( const struct unit pcargo,
const struct unit ptrans 
)

Return TRUE iff the given unit can be loaded into the transporter.

Definition at line 725 of file unit.c.

Referenced by dai_unit_new_task(), transporter_for_unit(), and unit_transport_load().

◆ can_unit_paradrop()

bool can_unit_paradrop ( const struct civ_map nmap,
const struct unit punit 
)

Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airbase special, has enough movepoints left, and has not paradropped yet this turn.

Definition at line 822 of file unit.c.

Referenced by dai_manage_paratrooper(), mr_menu::menus_sensitive(), popup_advanced_terrain_dialog(), real_menus_update(), request_unit_paradrop(), mr_menu::slot_paradrop(), and unit_actions::update_actions().

◆ can_unit_teleport()

bool can_unit_teleport ( const struct civ_map nmap,
const struct unit punit 
)

Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airbase special, has enough movepoints left, and has not paradropped yet this turn.

Definition at line 806 of file unit.c.

Referenced by real_menus_update(), and request_unit_teleport().

◆ can_unit_unload()

bool can_unit_unload ( const struct unit pcargo,
const struct unit ptrans 
)

Return TRUE iff the given unit can be unloaded from its current transporter.

This function checks everything except the legality of the position after the unloading. The caller may also want to call can_unit_exist_at_tile() to check this, unless the unit is unloading and moving at the same time.

Definition at line 752 of file unit.c.

Referenced by action_hard_reqs_actor(), actres_possible(), create_unit_menu(), present_unit_callback(), request_unit_unload(), unit_can_load(), unit_move_to_tile_test(), units_can_unload(), unit_actions::update_actions(), and wipe_unit_full().

◆ cargo_iter_init()

struct iterator * cargo_iter_init ( struct cargo_iter iter,
const struct unit ptrans 
)

Initialize the cargo iterator.

Definition at line 2624 of file unit.c.

Referenced by unit_cargo_depth().

◆ cargo_iter_sizeof()

size_t cargo_iter_sizeof ( void  ) const

◆ could_unit_be_in_transport()

bool could_unit_be_in_transport ( const struct unit pcargo,
const struct unit ptrans 
)

Tells whether pcargo could possibly be in ptrans, disregarding unit positions and ownership and load actions possibility, but regarding number and types of their current cargo. pcargo and ptrans must be valid unit pointers, pcargo not loaded anywhere

Definition at line 668 of file unit.c.

Referenced by api_edit_create_unit_full(), and could_unit_load().

◆ could_unit_load()

bool could_unit_load ( const struct unit pcargo,
const struct unit ptrans 
)

Return TRUE iff the given unit could be loaded into the transporter if we moved there.

Definition at line 700 of file unit.c.

Referenced by actres_possible(), can_unit_load(), qtg_request_transport(), request_transport(), request_unit_load(), transporter_for_unit_at(), unit_can_load(), unit_could_load_at(), unit_move_to_tile_test(), and unit_teleport_to_tile_test().

◆ create_unit_orders()

struct unit_order * create_unit_orders ( const struct civ_map nmap,
int  length,
const struct unit_order orders 
)

Sanity-check unit order arrays from a packet and create a unit_order array from their contents if valid.

Definition at line 2834 of file unit.c.

Referenced by city_rally_point_receive(), and handle_unit_orders().

◆ free_unit_orders()

void free_unit_orders ( struct unit punit)

◆ get_activity_rate()

int get_activity_rate ( const struct unit punit)

Returns the speed of a unit doing an activity. This depends on the veteran level and the base move_rate of the unit (regardless of HP or effects). Usually this is just used for settlers but the value is also used for military units doing fortify/pillage activities.

The speed is multiplied by ACTIVITY_FACTOR.

Definition at line 495 of file unit.c.

Referenced by calc_activity(), get_activity_rate_this_turn(), get_turns_for_activity_at(), and goto_fill_parameter_full().

◆ get_activity_rate_this_turn()

int get_activity_rate_this_turn ( const struct unit punit)

Returns the amount of work a unit does (will do) on an activity this turn. Units that have no MP do no work.

The speed is multiplied by ACTIVITY_FACTOR.

Definition at line 526 of file unit.c.

Referenced by calc_activity(), and update_unit_activity().

◆ get_activity_text()

const char * get_activity_text ( enum unit_activity  activity)

Return the name of the activity in a static buffer.

Definition at line 614 of file unit.c.

Referenced by concat_tile_activity_text(), contemplate_terrain_improvements(), real_unit_log(), settler_evaluate_improvements(), unit_activity_astr(), and usdlg_tab_append_activity().

◆ get_transporter_capacity()

int get_transporter_capacity ( const struct unit punit)

◆ get_transporter_occupancy()

int get_transporter_occupancy ( const struct unit ptrans)

◆ get_turns_for_activity_at()

int get_turns_for_activity_at ( const struct unit punit,
enum unit_activity  activity,
const struct tile ptile,
struct extra_type tgt 
)

Return the estimated number of turns for the worker unit to start and complete the activity at the given location. This assumes no other worker units are helping out, and doesn't take account of any work already done by this unit.

Definition at line 542 of file unit.c.

Referenced by settler_evaluate_improvements().

◆ get_unit_tile_pillage_set()

bv_extras get_unit_tile_pillage_set ( const struct tile ptile)

Return a mask of the extras which are actively (currently) being pillaged on the given tile.

Definition at line 1138 of file unit.c.

Referenced by actres_possible().

◆ hp_gain_coord()

int hp_gain_coord ( const struct unit punit)

Returns how many hp's a unit will gain standing still on current tile.

Definition at line 2162 of file unit.c.

Referenced by dai_find_strategic_airbase(), regen_turns(), and unit_gain_hitpoints().

◆ is_allied_unit_tile()

static bool is_allied_unit_tile ( const struct tile ptile,
const struct player pplayer 
)
inlinestatic

Are there allied units, and only allied units, on the tile?

Definition at line 408 of file unit.h.

Referenced by can_step_taken_wrt_to_zoc(), kill_unit(), and send_goto_route().

◆ is_attack_unit()

bool is_attack_unit ( const struct unit punit)

Is the unit capable of attacking?

Definition at line 305 of file unit.c.

Referenced by can_units_attack_at(), and unit_being_aggressive().

◆ is_build_activity()

bool is_build_activity ( enum unit_activity  activity)

Returns true if given activity builds an extra.

Definition at line 1559 of file unit.c.

Referenced by calc_activity(), can_unit_do_activity_targeted_at(), concat_tile_activity_text(), is_targeted_activity(), is_tile_activity(), and turns_to_activity_done().

◆ is_clean_activity()

bool is_clean_activity ( enum unit_activity  activity)

Returns true if given activity is some kind of cleaning.

Definition at line 1575 of file unit.c.

Referenced by calc_activity(), concat_tile_activity_text(), is_targeted_activity(), is_tile_activity(), and turns_to_activity_done().

◆ is_enemy_unit_tile()

static bool is_enemy_unit_tile ( const struct tile ptile,
const struct player pplayer 
)
inlinestatic

◆ is_enter_borders_unit()

bool is_enter_borders_unit ( const struct unit punit)

Can this unit enter peaceful borders?

Definition at line 332 of file unit.c.

Referenced by notify_illegal_armistice_units(), and remove_illegal_armistice_units().

◆ is_field_unit()

bool is_field_unit ( const struct unit punit)

This checks the "field unit" flag on the unit. Field units cause unhappiness (under certain governments) even when they aren't abroad.

Definition at line 414 of file unit.c.

Referenced by city_unit_unhappiness(), and resolve_city_emergency().

◆ is_guard_unit()

bool is_guard_unit ( const struct unit punit)

Does it make sense for this unit to protect others?

Definition at line 340 of file unit.c.

Referenced by adv_settler_safe_tile(), and has_defense().

◆ is_hiding_unit()

bool is_hiding_unit ( const struct unit punit)

Is the unit one that is invisible on the map. A unit is invisible if it's vision layer is either V_INVIS or V_SUBSURFACE, or if it's transported by such unit.

FIXME: Should the transports recurse all the way?

Definition at line 426 of file unit.c.

Referenced by can_player_see_unit_at().

◆ is_losing_hp()

bool is_losing_hp ( const struct unit punit)

Does unit lose hitpoints each turn?

Definition at line 2228 of file unit.c.

Referenced by can_unit_do_activity_targeted_at(), can_unit_survive_at_tile(), dai_fill_unit_param(), and dai_manage_unit().

◆ is_martial_law_unit()

bool is_martial_law_unit ( const struct unit punit)

Is unit capable of enforcing martial law?

Definition at line 316 of file unit.c.

Referenced by city_support().

◆ is_my_zoc()

static bool is_my_zoc ( const struct player unit_owner,
const struct tile ptile,
const struct civ_map zmap 
)
inlinestatic

Is this square controlled by the unit_owner? This function can be used both by the server and the client side.

Here "is_my_zoc" means essentially a square which is not adjacent to an enemy unit (that has a ZOC) on a terrain that has zoc rules.

Definition at line 478 of file unit.h.

Referenced by can_step_taken_wrt_to_zoc().

◆ is_non_allied_unit_tile()

static bool is_non_allied_unit_tile ( const struct tile ptile,
const struct player pplayer 
)
inlinestatic

◆ is_non_attack_unit_tile()

static bool is_non_attack_unit_tile ( const struct tile ptile,
const struct player pplayer 
)
inlinestatic

Are there any unit(s) on tile preventing player's units from moving towards, either to attack enemy or to enter the tile with allies.

Definition at line 457 of file unit.h.

Referenced by popup_advanced_terrain_dialog(), unit_move_to_tile_test(), and unit_teleport_to_tile_test().

◆ is_occupying_unit()

bool is_occupying_unit ( const struct unit punit)

Does unit occupy the tile?

Definition at line 324 of file unit.c.

Referenced by unit_occupies_tile().

◆ is_other_players_unit_tile()

static bool is_other_players_unit_tile ( const struct tile ptile,
const struct player pplayer 
)
inlinestatic

Are there any unit(s) on tile owned by someone else than pplayer?

Definition at line 444 of file unit.h.

◆ is_plr_zoc_client()

bool is_plr_zoc_client ( const struct player pplayer,
const struct tile ptile0,
const struct civ_map zmap 
)

Is this square controlled by the pplayer? Function to be used on client side only.

Here "plr zoc" means essentially a square which is not adjacent to an enemy unit (that has a ZOC) on a terrain that has zoc rules.

Since this function is used in the client, it has to deal with some client-specific features, like FoW and the fact that the client cannot see units inside enemy cities.

Definition at line 1456 of file unit.c.

Referenced by is_my_zoc(), pft_fill_attack_param(), pft_fill_overlap_param(), and pft_fill_parameter().

◆ is_plr_zoc_srv()

bool is_plr_zoc_srv ( const struct player pplayer,
const struct tile ptile0,
const struct civ_map zmap 
)

Is this square controlled by the pplayer? Function to be used on server side only.

Here "plr zoc" means essentially a square which is not adjacent to an enemy unit (that has a ZOC) on a terrain that has zoc rules.

Definition at line 1387 of file unit.c.

Referenced by is_my_zoc(), pft_fill_attack_param(), pft_fill_overlap_param(), pft_fill_parameter(), and stack_risk().

◆ is_special_unit()

bool is_special_unit ( const struct unit punit)

Does it make sense to use this unit for some special role?

If yes, don't waste it as cannon fodder.

Definition at line 350 of file unit.c.

Referenced by base_assess_defense_unit(), calc_civ_score(), dai_manage_unit(), get_munits(), kill_something_with(), and quickselect().

◆ is_square_threatened()

bool is_square_threatened ( const struct civ_map nmap,
const struct player pplayer,
const struct tile ptile,
bool  omniscient 
)

Return TRUE iff this tile is threatened from any unit within 2 tiles.

Definition at line 388 of file unit.c.

Referenced by adv_settler_safe_tile().

◆ is_targeted_activity()

bool is_targeted_activity ( enum unit_activity  activity)

Returns true if given activity requires target

Definition at line 1614 of file unit.c.

Referenced by get_turns_for_activity_at(), and tile_activity_time().

◆ is_terrain_change_activity()

bool is_terrain_change_activity ( enum unit_activity  activity)

Returns true if given activity changes terrain.

Definition at line 1589 of file unit.c.

Referenced by is_tile_activity().

◆ is_tile_activity()

bool is_tile_activity ( enum unit_activity  activity)

Returns true if given activity affects tile.

Definition at line 1604 of file unit.c.

Referenced by concat_tile_activity_text().

◆ is_unit_activity_on_tile()

bool is_unit_activity_on_tile ( enum unit_activity  activity,
const struct tile ptile 
)

Return whether any units on the tile are doing this activity.

Definition at line 1123 of file unit.c.

Referenced by real_menus_update(), and units_have_activity_on_tile().

◆ set_unit_activity()

void set_unit_activity ( struct unit punit,
enum unit_activity  new_activity 
)

◆ set_unit_activity_targeted()

void set_unit_activity_targeted ( struct unit punit,
enum unit_activity  new_activity,
struct extra_type new_target 
)

assign a new targeted task to a unit.

Definition at line 1105 of file unit.c.

Referenced by set_unit_activity_base(), set_unit_activity_road(), sg_load_player_unit(), sg_load_player_unit(), and unit_activity_targeted_internal().

◆ test_unit_can_airlift_to()

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 
)

Determines if punit can be airlifted to dest_city now! So punit needs to be in a city now. If pdest_city is NULL, just indicate whether it's possible for the unit to be airlifted at all from its current position. The 'restriction' parameter specifies which player's knowledge this is based on – one player can't see whether another's cities are currently able to airlift. (Clients other than global observers should only call this with a non-NULL 'restriction'.)

Definition at line 81 of file unit.c.

Referenced by actres_possible(), expl_act_not_enabl(), and get_airlift_text().

◆ tile_allied_unit()

struct unit * tile_allied_unit ( const struct tile ptile,
const struct player pplayer 
)

Returns one of the units, if the tile contains an allied unit and only allied units. Returns NULL if there is no units, or some of them are not allied. (ie, if your nation A is allied with B, and B is allied with C, a tile containing units from B and C will return NULL)

Definition at line 1268 of file unit.c.

Referenced by is_allied_unit_tile().

◆ tile_enemy_unit()

struct unit * tile_enemy_unit ( const struct tile ptile,
const struct player pplayer 
)

Is there an enemy unit on this tile? Returns the unit or NULL if none.

This function is likely to fail if used at the client because the client doesn't see all units. (Maybe it should be moved into the server code.)

Definition at line 1291 of file unit.c.

Referenced by is_enemy_unit_tile().

◆ tile_non_allied_unit()

struct unit * tile_non_allied_unit ( const struct tile ptile,
const struct player pplayer 
)

Return one of the non-allied units on the tile, if there is any

Definition at line 1306 of file unit.c.

Referenced by is_non_allied_unit_tile(), and maybe_cancel_patrol_due_to_enemy().

◆ tile_non_attack_unit()

struct unit * tile_non_attack_unit ( const struct tile ptile,
const struct player pplayer 
)

Return an unit we have peace or ceasefire with on this tile, if any exist.

Definition at line 1339 of file unit.c.

Referenced by is_non_attack_unit_tile().

◆ tile_other_players_unit()

struct unit * tile_other_players_unit ( const struct tile ptile,
const struct player pplayer 
)

Return an unit belonging to any other player, if there are any on the tile.

Definition at line 1323 of file unit.c.

Referenced by dai_diplomat_bribe_nearby(), and is_other_players_unit_tile().

◆ transporter_for_unit()

struct unit * transporter_for_unit ( const struct unit pcargo)

Find the best transporter at the given location for the unit. See also unit_can_load() to test if there will be transport might be suitable for 'pcargo'.

Definition at line 1912 of file unit.c.

Referenced by api_find_transport_unit(), player_restore_units(), request_unit_load(), try_to_save_unit(), and unit_move().

◆ transporter_for_unit_at()

struct unit * transporter_for_unit_at ( const struct unit pcargo,
const struct tile ptile 
)

Find the best transporter at the given location for the unit. See also unit_could_load_at() to test if there will be transport might be suitable for 'pcargo'.

Definition at line 1922 of file unit.c.

Referenced by adv_unit_move(), dai_unit_attack(), dai_unit_move(), fill_parameter_part(), qtg_request_transport(), remove_city(), request_transport(), and unit_move_handling().

◆ unit_activity_astr()

void unit_activity_astr ( const struct unit punit,
struct astring astr 
)

Append text describing the unit's current activity to the given astring.

Definition at line 1155 of file unit.c.

Referenced by create_present_supported_units_widget_list(), get_unit_info_label_text2(), units_select::paint(), popup_advanced_terrain_dialog(), redraw_unit_info_label(), unit_description(), and unit_select_dialog_popup().

◆ unit_ai_data()

void * unit_ai_data ( const struct unit punit,
const struct ai_type ai 
)

Return pointer to ai data of given unit and ai type.

Definition at line 2282 of file unit.c.

Referenced by def_ai_unit_data().

◆ unit_being_aggressive()

bool unit_being_aggressive ( const struct civ_map nmap,
const struct unit punit 
)

An "aggressive" unit is a unit which may cause unhappiness under a Republic or Democracy. A unit is not aggressive if one or more of following is true:

  • zero attack strength
  • inside a city
  • near friendly city and in extra that provides "no aggressive"

Definition at line 1518 of file unit.c.

Referenced by city_unit_unhappiness(), and resolve_city_emergency().

◆ unit_bribe_cost()

int unit_bribe_cost ( struct unit punit,
struct player briber 
)

Calculate how expensive it is to bribe the unit. The cost depends on the distance to the capital, the owner's treasury, and the build cost of the unit. For a damaged unit the price is reduced. For a veteran unit, it is increased.

The bribe cost for settlers are halved.

Definition at line 2304 of file unit.c.

Referenced by dai_diplomat_bribe_nearby(), diplomat_bribe(), handle_unit_action_query(), and popup_info_text().

◆ unit_can_add_or_build_city()

bool unit_can_add_or_build_city ( const struct civ_map nmap,
const struct unit punit 
)

Return TRUE iff this unit can add to a current city or build a new city at its current location.

Definition at line 448 of file unit.c.

Referenced by build_city_callback(), build_city_callback(), mr_menu::menus_sensitive(), real_menus_update(), mr_menu::slot_build_city(), and unit_actions::update_actions().

◆ unit_can_airlift_to()

bool unit_can_airlift_to ( const struct civ_map nmap,
const struct unit punit,
const struct city pdest_city 
)

Determines if punit can be airlifted to dest_city now! So punit needs to be in a city now. On the server this gives correct information; on the client it errs on the side of saying airlifting is possible even if it's not certain given player knowledge.

Definition at line 186 of file unit.c.

Referenced by goto_dialog::airlift_to(), dai_airlift(), goto_cmd_callback(), goto_dialog::item_selected(), and refresh_airlift_button().

◆ unit_can_convert()

bool unit_can_convert ( const struct civ_map nmap,
const struct unit punit 
)

Tests if unit can be converted to another type.

Definition at line 2035 of file unit.c.

Referenced by action_hard_reqs_actor(), real_menus_update(), unit_convert(), and units_can_convert().

◆ unit_can_do_action()

bool unit_can_do_action ( const struct unit punit,
const action_id  act_id 
)

◆ unit_can_do_action_result()

bool unit_can_do_action_result ( const struct unit punit,
enum action_result  result 
)

Return TRUE iff this unit can do any enabler controlled action with the specified action result.

Definition at line 369 of file unit.c.

Referenced by dai_diplomat_bribe_nearby(), dai_manage_unit(), is_attack_unit(), unit_can_displace_hut(), unit_can_enter_hut(), and units_can_do_action_with_result().

◆ unit_can_do_action_sub_result()

bool unit_can_do_action_sub_result ( const struct unit punit,
enum action_sub_result  sub_result 
)

Return TRUE iff this unit can do any enabler controlled action with the specified action sub result.

Definition at line 379 of file unit.c.

Referenced by unit_can_displace_hut(), and unit_can_enter_hut().

◆ unit_can_est_trade_route_here()

bool unit_can_est_trade_route_here ( const struct unit punit)

Return TRUE iff this unit can be disbanded at its current location to provide a trade route from the homecity to the target city.

Definition at line 284 of file unit.c.

Referenced by build_road_callback(), build_road_callback(), mr_menu::menus_sensitive(), real_menus_update(), and mr_menu::slot_build_road().

◆ unit_can_help_build_wonder_here()

bool unit_can_help_build_wonder_here ( const struct civ_map nmap,
const struct unit punit 
)

Return TRUE unless it is known to be impossible to disband this unit at its current position to get full shields for building a wonder.

Definition at line 258 of file unit.c.

Referenced by mr_menu::menus_sensitive(), and real_menus_update().

◆ unit_cargo_depth()

int unit_cargo_depth ( const struct unit ptrans)

Returns the number of unit cargo layers within transport 'ptrans'.

Definition at line 2533 of file unit.c.

Referenced by could_unit_be_in_transport(), and pft_fill_unit_default_parameter().

◆ unit_contained_in()

bool unit_contained_in ( const struct unit pcargo,
const struct unit ptrans 
)

Returns whether 'pcargo' is transported by 'ptrans', either directly or indirectly.

Definition at line 2520 of file unit.c.

Referenced by actres_possible(), and mr_menu::find_last_unit_pos().

◆ unit_gain_hitpoints()

int unit_gain_hitpoints ( const struct unit punit)

How many hitpoints does unit recover?

Definition at line 2183 of file unit.c.

Referenced by dai_manage_hitpoint_recovery(), and unit_restore_hitpoints().

◆ unit_has_orders()

bool unit_has_orders ( const struct unit punit)

◆ unit_is_alive()

bool unit_is_alive ( int  id)

◆ unit_is_cityfounder()

bool unit_is_cityfounder ( const struct unit punit)

◆ unit_is_virtual()

bool unit_is_virtual ( const struct unit punit)

Return TRUE if this is a valid unit pointer but does not correspond to any unit that exists in the game.

NB: A return value of FALSE implies that either the pointer is NULL or that the unit exists in the game.

Definition at line 2270 of file unit.c.

Referenced by tile_virtual_destroy().

◆ unit_nationality()

struct player * unit_nationality ( const struct unit punit)

◆ unit_occupies_tile()

struct unit * unit_occupies_tile ( const struct tile ptile,
const struct player pplayer 
)

Is there an occupying unit on this tile?

Intended for both client and server; assumes that hiding units are not sent to client. First check tile for known and seen.

Called by city_can_work_tile().

Definition at line 1360 of file unit.c.

Referenced by base_city_can_work_tile().

◆ unit_order_list_is_sane()

bool unit_order_list_is_sane ( const struct civ_map nmap,
int  length,
const struct unit_order orders 
)

Returns TRUE iff the unit order array is sane.

Definition at line 2649 of file unit.c.

Referenced by create_unit_orders(), sg_load_sanitycheck(), and sg_load_sanitycheck().

◆ unit_pays_mp_for_action()

int unit_pays_mp_for_action ( const struct action paction,
const struct unit punit 
)

Returns the amount of movement points successfully performing the specified action will consume in the actor unit.

Definition at line 2135 of file unit.c.

Referenced by action_success_pay_mp(), adv_unit_move(), dai_action_value_unit_vs_city(), and dai_unit_move().

◆ unit_set_ai_data()

void unit_set_ai_data ( struct unit punit,
const struct ai_type ai,
void data 
)

Attach ai data to unit

Definition at line 2290 of file unit.c.

Referenced by dai_unit_close(), and dai_unit_init().

◆ unit_shield_value()

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.

Parameters
punitthe unit. Can be NULL if punittype is set.
punittypethe unit's type. Can be NULL iff punit is set.
pactionthe action the unit does when valued.
Returns
the unit's value in shields.

Definition at line 214 of file unit.c.

Referenced by city_gold_worth(), unit_do_help_build(), and unit_upgrade_price().

◆ unit_tile_set()

void unit_tile_set ( struct unit punit,
struct tile ptile 
)

◆ unit_transform_result()

enum unit_upgrade_result unit_transform_result ( const struct civ_map nmap,
const struct unit punit,
const struct unit_type to_unittype 
)

Tests if something prevents punit from being transformed to to_unittype where it is now, presuming its current position is valid.

FIXME: The transport stack may still fail unit_transport_check() in result.

Definition at line 1956 of file unit.c.

Referenced by api_methods_unit_transform_problem(), unit_can_convert(), unit_upgrade_test(), and ur_transform_unit().

◆ unit_transport_cargo()

struct unit_list * unit_transport_cargo ( const struct unit ptrans)

◆ unit_transport_check()

bool unit_transport_check ( const struct unit pcargo,
const struct unit ptrans 
)

Returns whether 'pcargo' in 'ptrans' is a valid transport. Note that 'pcargo' can already be (but doesn't need) loaded into 'ptrans'.

It may fail if one of the cargo unit has the same type of one of the transporter unit or if one of the cargo unit can transport one of the transporters.

Definition at line 2479 of file unit.c.

Referenced by could_unit_be_in_transport().

◆ unit_transport_depth()

int unit_transport_depth ( const struct unit pcargo)

Returns the number of unit transport layers which carry unit 'pcargo'.

Definition at line 2551 of file unit.c.

Referenced by base_transporter_for_unit(), could_unit_be_in_transport(), and pf_transport_check().

◆ unit_transport_get()

struct unit * unit_transport_get ( const struct unit pcargo)

◆ unit_transport_load()

bool unit_transport_load ( struct unit pcargo,
struct unit ptrans,
bool  force 
)

◆ unit_transport_unload()

bool unit_transport_unload ( struct unit pcargo)

◆ unit_transported()

bool unit_transported ( const struct unit pcargo)

◆ unit_type_is_losing_hp()

bool unit_type_is_losing_hp ( const struct player pplayer,
const struct unit_type punittype 
)

Does unit lose hitpoints each turn?

Definition at line 2240 of file unit.c.

Referenced by dai_choose_attacker_air().

◆ unit_type_really_ignores_zoc()

bool unit_type_really_ignores_zoc ( const struct unit_type punittype)

Takes into account unit class flag UCF_ZOC as well as IGZOC

Definition at line 1504 of file unit.c.

Referenced by can_step_taken_wrt_to_zoc(), pft_fill_attack_param(), pft_fill_overlap_param(), and pft_fill_parameter().

◆ unit_upgrade_info()

enum unit_upgrade_result unit_upgrade_info ( const struct civ_map nmap,
const struct unit punit,
char buf,
size_t  bufsz 
)

Find the result of trying to upgrade the unit, and a message that most callers can use directly.

Definition at line 2051 of file unit.c.

Referenced by get_units_upgrade_info(), and popup_unit_upgrade_dlg().

◆ unit_upgrade_test()

enum unit_upgrade_result unit_upgrade_test ( const struct civ_map nmap,
const struct unit punit,
bool  is_free 
)

Tests if the unit could be updated. Returns UU_OK if is this is possible.

is_free should be set if the unit upgrade is "free" (e.g., Leonardo's). Otherwise money is needed and the unit must be in an owned city.

Note that this function is strongly tied to unittools.c:transform_unit().

Definition at line 1988 of file unit.c.

Referenced by actres_possible(), api_methods_unit_can_upgrade(), do_upgrade_effects(), expl_act_not_enabl(), get_units_upgrade_info(), handle_unit_type_upgrade(), unit_upgrade_info(), units_can_upgrade(), and unit_actions::update_actions().

◆ unit_upkeep_astr()

void unit_upkeep_astr ( const struct unit punit,
struct astring astr 
)

Append a line of text describing the unit's upkeep to the astring.

NB: In the client it is assumed that this information is only available for units owned by the client's player; the caller must check this.

Definition at line 1231 of file unit.c.

Referenced by unit_description().

◆ unit_virtual_create()

struct unit * unit_virtual_create ( struct player pplayer,
struct city pcity,
const struct unit_type punittype,
int  veteran_level 
)

◆ unit_virtual_destroy()

void unit_virtual_destroy ( struct unit punit)

Variable Documentation

◆ tile_changing_activities

const Activity_type_id tile_changing_activities[]
extern

Definition at line 44 of file unit.c.