93 #define SPECENUM_NAME unit_ss_data_type
96 #define SPECENUM_VALUE0 USSDT_QUEUE
99 #define SPECENUM_VALUE1 USSDT_UNQUEUE
102 #define SPECENUM_VALUE2 USSDT_BATTLE_GROUP
103 #include "specenum_gen.h"
106 #define SPECENUM_NAME server_side_agent
107 #define SPECENUM_VALUE0 SSA_NONE
108 #define SPECENUM_VALUE0NAME N_("None")
109 #define SPECENUM_VALUE1 SSA_AUTOSETTLER
110 #define SPECENUM_VALUE1NAME N_("Autosettlers")
111 #define SPECENUM_VALUE2 SSA_AUTOEXPLORE
112 #define SPECENUM_VALUE2NAME N_("Autoexplore")
113 #define SPECENUM_COUNT SSA_COUNT
114 #include "specenum_gen.h"
127 #define SPECLIST_TAG unit_wait
128 #define SPECLIST_TYPE struct unit_wait
130 #define unit_wait_list_link_iterate(unit_wait_list, plink) \
131 TYPED_LIST_LINK_ITERATE(struct unit_wait_list_link, unit_wait_list, plink)
132 #define unit_wait_list_link_iterate_end LIST_LINK_ITERATE_END
186 #define MAX_NUM_BATTLEGROUPS (4)
187 #define BATTLEGROUP_NONE (-1)
232 void *
ais[FREECIV_AI_MOD_LAST];
241 struct unit_wait_list_link *
wait;
257 #define CHECK_UNIT(punit) \
258 (fc_assert(punit != nullptr), fc_assert(unit_type_get(punit) != nullptr), \
259 fc_assert(unit_owner(punit) != nullptr), \
260 fc_assert(player_by_number(player_index(unit_owner(punit))) \
261 == unit_owner(punit)), \
262 fc_assert(game_unit_by_number(punit->id) != nullptr))
264 #define CHECK_UNIT(punit)
271 #define activity_type_list_iterate(_act_list_, _act_) \
274 for (_act_i_ = 0; _act_list_[_act_i_] != ACTIVITY_LAST; _act_i_++) { \
275 Activity_type_id _act_ = _act_list_[_act_i_];
277 #define activity_type_list_iterate_end \
282 #define activity_type_iterate(_act_) \
284 activity_type_list_iterate(real_activities, _act_)
286 #define activity_type_iterate_end \
287 activity_type_list_iterate_end \
292 #define tile_changing_activities_iterate(_act_) \
294 activity_type_list_iterate(tile_changing_activities, _act_)
296 #define tile_changing_activities_iterate_end \
297 activity_type_list_iterate_end \
306 const struct action *paction);
311 const struct unit *punit,
312 const struct city *pdest_city);
320 const struct unit *ptrans);
323 const struct city *pcity);
335 const struct tile *ptile);
338 enum unit_activity new_activity,
344 const struct tile *ptile,
349 const struct tile *ptile);
355 enum action_result result);
357 const struct tile *ptile,
bool omniscient);
369 #define unit_home(_pu_) (game_city_by_number((_pu_)->homecity))
370 #define unit_owner(_pu) ((_pu)->owner)
371 #define unit_tile(_pu) ((_pu)->tile)
376 const struct player *pplayer);
378 const struct player *pplayer);
380 const struct player *pplayer);
382 const struct player *pplayer);
384 const struct player *pplayer);
386 const struct player *pplayer);
394 const struct tile *ptile);
409 const struct tile *ptile);
414 char *buf,
size_t bufsz);
418 const struct unit *punit);
439 const struct unit *ptrans);
447 #define unit_transports_iterate(_pcargo, _ptrans) \
449 struct unit *_ptrans; \
450 for (_ptrans = unit_transport_get(_pcargo); nullptr != _ptrans; \
451 _ptrans = unit_transport_get(_ptrans)) {
452 #define unit_transports_iterate_end \
460 const struct
unit *ptrans);
461 #define unit_cargo_iterate(_ptrans, _pcargo) \
462 generic_iterate(struct cargo_iter, struct unit *, _pcargo, \
463 cargo_iter_sizeof, cargo_iter_init, _ptrans)
464 #define unit_cargo_iterate_end generic_iterate_end
enum unit_activity Activity_type_id
enum unit_activity activity
enum unit_activity activity
enum action_decision action_decision_want
enum unit_activity activity
struct unit::@76::@78 client
struct unit_list * transporting
struct extra_type * changed_from_target
struct unit::@76::@79 server
struct extra_type * activity_target
struct act_prob * act_prob_cache
enum unit_activity changed_from
struct player * nationality
void(* removal_callback)(struct unit *punit)
void * ais[FREECIV_AI_MOD_LAST]
struct unit_move_data * moving
struct unit * transporter
struct unit_wait_list_link * wait
struct goods_type * carrying
struct tile * action_decision_tile
const struct unit_type * utype
enum unit_focus_status focus_status
enum server_side_agent ssa_controller
int fc__attribute((nonnull(1, 3)))
void unit_upkeep_astr(const struct unit *punit, QString &astr)
Append a line of text describing the unit's upkeep to the astring.
Activity_type_id real_activities[ACTIVITY_LAST]
bool is_tile_activity(enum unit_activity activity)
Returns true if given activity affects tile.
bool unit_being_aggressive(const struct unit *punit)
An "aggressive" unit is a unit which may cause unhappiness under a Republic or Democracy.
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Takes into account unit class flag UCF_ZOC as well as IGZOC.
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
Does unit lose hitpoints each turn?
bool is_terrain_change_activity(enum unit_activity activity)
Returns true if given activity changes terrain.
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.
int get_transporter_occupancy(const struct unit *ptrans)
Return how many units are in the transport.
bool unit_can_airlift_to(const struct unit *punit, const struct city *pcity)
Determines if punit can be airlifted to dest_city now! So punit needs to be in a city now.
void free_unit_orders(struct unit *punit)
Free and reset the unit's goto route (punit->pgr).
bool can_unit_change_homecity(const struct unit *punit)
Return TRUE iff the unit can change homecity at its current location.
struct unit * transporter_for_unit(const struct unit *pcargo)
Find the best transporter at the given location for the unit.
enum unit_upgrade_result unit_upgrade_test(const struct unit *punit, bool is_free)
Tests if the unit could be updated.
void * unit_ai_data(const struct unit *punit, const struct ai_type *ai)
Return pointer to ai data of given unit and ai type.
void unit_set_ai_data(struct unit *punit, const struct ai_type *ai, void *data)
Attach ai data to unit.
bool unit_is_alive(int id)
Check if unit with given id is still alive.
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 ...
bool is_hiding_unit(const struct unit *punit)
Is the unit one that is invisible on the map.
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.
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 th...
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 gi...
bool can_unit_paradrop(const struct unit *punit)
Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airb...
struct unit * is_other_players_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an unit belonging to another player on this tile?
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
Load pcargo onto ptrans.
bool unit_can_add_or_build_city(const struct unit *punit)
Return TRUE iff this unit can add to a current city or build a new city at its current location.
int unit_cargo_depth(const struct unit *pcargo)
Returns the number of unit cargo layers within transport 'ptrans'.
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
Assign a new untargeted task to a unit.
bool is_losing_hp(const struct unit *punit)
Does unit lose hitpoints each turn?
bool can_unit_change_homecity_to(const struct unit *punit, const struct city *pcity)
Return TRUE iff the unit can change homecity to the given city.
struct unit * is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Returns true if the tile contains an allied unit and only allied units.
int get_activity_rate(const struct unit *punit)
Returns the speed of a unit doing an activity.
struct unit * is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non-allied unit on this tile?
bool unit_transport_check(const struct unit *pcargo, const struct unit *ptrans)
Returns whether 'pcargo' in 'ptrans' is a valid transport.
bool is_attack_unit(const struct unit *punit)
Is the unit capable of attacking?
const Activity_type_id tile_changing_activities[]
struct unit * unit_transport_get(const struct unit *pcargo)
Returns the transporter of the unit or nullptr if it is not transported.
bool unit_transport_unload(struct unit *pcargo)
Unload pcargo from ptrans.
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Returns whether 'pcargo' is transported by 'ptrans', either directly or indirectly.
bool can_unit_continue_current_activity(struct unit *punit)
Check if the unit's current activity is actually legal.
bool is_military_unit(const struct unit *punit)
Military units are capable of enforcing martial law.
struct unit * unit_occupies_tile(const struct tile *ptile, const struct player *pplayer)
Is there an occupying unit on this tile?
bool can_unit_do_activity_targeted_at(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.
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.
int unit_bribe_cost(struct unit *punit, struct player *briber)
Calculate how expensive it is to bribe the unit.
bool is_build_activity(enum unit_activity activity, const struct tile *ptile)
Returns true if given activity is some kind of building.
bool is_square_threatened(const struct player *pplayer, const struct tile *ptile, bool omniscient)
Return TRUE iff this tile is threatened from any unit within 2 tiles.
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.
bool unit_is_cityfounder(const struct unit *punit)
Is a cityfounder unit?
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.
bool can_unit_do_autosettlers(const struct unit *punit)
Return whether the unit can be put in auto-settler mode.
@ UU_UNSUITABLE_TRANSPORT
bool unit_can_help_build_wonder_here(const struct unit *punit)
Return TRUE unless it is known to be imposible to disband this unit at its current position to get fu...
bool can_unit_alight_or_be_unloaded(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 mo...
bool is_field_unit(const struct unit *punit)
This checks the "field unit" flag on the unit.
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Return TRUE iff this unit can do the specified generalized (ruleset defined) action enabler controlle...
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.
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.
bool unit_can_convert(const struct unit *punit)
Tests if unit can be converted to another type.
size_t cargo_iter_sizeof() fc__attribute((const))
bool can_unit_do_activity_targeted(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.
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Returns the list of cargo units.
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.
int get_transporter_capacity(const struct unit *punit)
Return the number of units the transporter can hold (or 0).
struct unit * is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an unit we have peace or ceasefire with on this tile?
bool can_unit_unload(const struct unit *punit, const struct unit *ptrans)
Return TRUE iff the given unit can be unloaded from its current transporter.
bool is_clean_activity(enum unit_activity activity)
Returns true if given activity is some kind of cleaning.
int unit_transport_depth(const struct unit *ptrans)
Returns the number of unit transport layers which carry unit 'pcargo'.
enum unit_upgrade_result unit_upgrade_info(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.
bool can_unit_do_activity(const struct unit *punit, enum unit_activity activity)
Return TRUE iff the unit can do the given untargeted activity at its current location.
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
const char * get_activity_text(enum unit_activity activity)
Return the name of the activity in a static buffer.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
void unit_tile_set(struct unit *punit, struct tile *ptile)
Set the tile location of the unit.
struct iterator * cargo_iter_init(struct cargo_iter *iter, const struct unit *ptrans)
Initialize the cargo iterator.
enum unit_airlift_result test_unit_can_airlift_to(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.
const QString unit_activity_text(const struct unit *punit)
Return text describing the unit's current activity as a static string.
bool kills_citizen_after_attack(const struct unit *punit)
Return TRUE iff an attack from this unit would kill a citizen in a city (city walls protect against t...
bool can_unit_load(const struct unit *punit, const struct unit *ptrans)
Return TRUE iff the given unit can be loaded into the transporter.
bool unit_transported(const struct unit *pcargo)
Returns TRUE iff the unit is transported.
bool are_unit_orders_equal(const struct unit_order *order1, const struct unit_order *order2)
Checks unit orders for equality.
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 ga...
bool unit_has_orders(const struct unit *punit)
Return TRUE iff the unit is following client-side orders.
struct player * unit_nationality(const struct unit *punit)
Return the nationality of the unit.
bool activity_requires_target(enum unit_activity activity)
Return TRUE if activity requires some sort of target to be specified.
bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Is this square controlled by the pplayer?
struct unit * is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an enemy unit on this tile? Returns the unit or nullptr if none.
void unit_activity_astr(const struct unit *punit, QString &astr)
Append text describing the unit's current activity to the given astring.
void setup_real_activities_array()
Setup array of real activities.