Freeciv-3.2
Loading...
Searching...
No Matches
unit.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__UNIT_H
14#define FC__UNIT_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "bitvector.h"
22
23/* common */
24#include "base.h"
25#include "fc_interface.h"
26#include "fc_types.h"
27#include "map_types.h"
28#include "terrain.h" /* enum tile_special_type */
29#include "unittype.h"
30#include "vision.h"
31
32struct road_type;
33struct unit_move_data; /* Actually defined in "server/unittools.c". */
34
35/* Changing this enum will break network compatibility.
36 * Different orders take different parameters; see struct unit_order. */
38 /* Move without performing any action (dir) */
40 /* Perform activity (activity, extra) */
42 /* Pause to regain movement points (no parameters) */
44 /* Move; if necessary prompt for action/target when order executed (dir) */
46 /* Perform pre-specified action (action, target tile, sub target) */
48 /* and plenty more for later... */
50};
51
55
59
67 UU_NOT_TERRAIN, /* The upgraded unit could not survive. */
68 UU_UNSUITABLE_TRANSPORT, /* Can't upgrade inside current transport. */
69 UU_NOT_ACTIVITY /* Can't upgrade during this activity (e.g., CONVERT) */
70};
71
73 /* Codes treated as success: */
74 AR_OK, /* This will definitely work */
75 AR_OK_SRC_UNKNOWN, /* Source city's airlift capability is unknown */
76 AR_OK_DST_UNKNOWN, /* Dest city's airlift capability is unknown */
77 /* Codes treated as failure: */
78 AR_NO_MOVES, /* Unit has no moves left */
79 AR_WRONG_UNITTYPE, /* Can't airlift this type of unit */
80 AR_OCCUPIED, /* Can't airlift units with passengers */
81 AR_NOT_IN_CITY, /* Unit not in a city */
82 AR_BAD_SRC_CITY, /* Can't airlift from this src city */
83 AR_BAD_DST_CITY, /* Can't airlift to this dst city */
84 AR_SRC_NO_FLIGHTS, /* No flights available from src */
85 AR_DST_NO_FLIGHTS /* No flights available to dst */
86};
87
88struct unit_adv {
90};
91
92struct unit_order {
94 enum unit_activity activity; /* Only valid for ORDER_ACTIVITY. */
95 /* Only valid for ORDER_PERFORM_ACTION. Validity and meaning depend on
96 * 'action'. See action_target_kind and action_sub_target_kind */
97 int target;
99 /* Only valid for ORDER_PERFORM_ACTION */
101 /* Valid for ORDER_MOVE and ORDER_ACTION_MOVE. */
103};
104
105/* Used in the network protocol */
106#define SPECENUM_NAME unit_ss_data_type
107/* The player wants to be reminded to ask what actions the unit can perform
108 * to a certain target tile. */
109#define SPECENUM_VALUE0 USSDT_QUEUE
110/* The player no longer wants the reminder to ask what actions the unit can
111 * perform to a certain target tile. */
112#define SPECENUM_VALUE1 USSDT_UNQUEUE
113/* The player wants to record that the unit now belongs to the specified
114 * battle group. */
115#define SPECENUM_VALUE2 USSDT_BATTLE_GROUP
116/* The player wants the unit to stop bothering them unless:
117 * - a hostile units comes within 3 tiles
118 * - the unit has its hitpoints restored
119 * - the unit is bounced
120 * if 1, 0 to still be bothered. */
121#define SPECENUM_VALUE3 USSDT_SENTRY
122#include "specenum_gen.h"
123
124/* Used in the network protocol */
125#define SPECENUM_NAME server_side_agent
126#define SPECENUM_VALUE0 SSA_NONE
127#define SPECENUM_VALUE0NAME N_("?serveragent:None")
128#define SPECENUM_VALUE1 SSA_AUTOSETTLER
129#define SPECENUM_VALUE1NAME N_("Autosettlers")
130#define SPECENUM_VALUE2 SSA_AUTOEXPLORE
131#define SPECENUM_VALUE2NAME N_("Autoexplore")
132#define SPECENUM_COUNT SSA_COUNT
133#include "specenum_gen.h"
134
135struct unit;
136struct unit_list;
137
138struct unit {
139 const struct unit_type *utype; /* Cannot be NULL. */
140 struct tile *tile;
143 struct player *owner; /* Cannot be NULL. */
145 int id;
147
148 int upkeep[O_LAST]; /* unit upkeep with regards to the homecity */
149
151 int hp;
153 int fuel;
154
155 struct tile *goto_tile; /* May be NULL. */
156
158
159 /* The amount of work that has been done on the current activity. This
160 * is counted in turns but is multiplied by ACTIVITY_FACTOR (which allows
161 * fractional values in some cases). */
163
165
166 /* Previous activity, so it can be resumed without loss of progress
167 * if the user changes their mind during a turn. */
171
173 bool moved;
175
176 /* This value is set if the unit is done moving for this turn. This
177 * information is used by the client. The invariant is:
178 * - If the unit has no more moves, it's done moving.
179 * - If the unit is on a goto but is waiting, it's done moving.
180 * - Otherwise the unit is not done moving. */
182
183 struct unit *transporter; /* This unit is transported by ... */
184 struct unit_list *transporting; /* This unit transports ... */
185
187
188 /* The battlegroup ID: defined by the client but stored by the server. */
189#define MAX_NUM_BATTLEGROUPS (4)
190#define BATTLEGROUP_NONE (-1)
192
194 struct {
195 int length, index;
196 bool repeat; /* The path is to be repeated on completion. */
197 bool vigilant; /* Orders should be cleared if an enemy is met. */
200
201 /* The unit may want the player to choose an action. */
204
205 bool stay; /* Unit is prohibited from moving */
206
209
210 union {
211 struct {
212 /* Only used at the client (the server is omniscient; ./client/). */
213
215
216 int transported_by; /* Used for unit_short_info packets where we can't
217 * be sure that the information about the
218 * transporter is known. */
219 bool occupied; /* TRUE if at least one cargo on the transporter. */
220
221 /* Equivalent to pcity->client.color. Only for cityfounder units. */
224
226
227 /* Used in a follow up question about a selected action. */
230
231 struct {
232 /* Only used in the server (./ai/ and ./server/). */
233
234 bool debug;
235
236 struct unit_adv *adv;
238
239 /* ord_map and ord_city are the order index of this unit in tile.units
240 * and city.units_supported; they are only used for save/reload */
243
244 struct vision *vision;
248
249 /* The unit is in the process of dying. */
250 bool dying;
251
252 /* Call back to run on unit removal. */
253 void (*removal_callback)(struct unit *punit);
254
255 /* The upkeep that actually was paid. */
256 int upkeep_paid[O_LAST];
258 };
259};
260
261#ifdef FREECIV_DEBUG
262#define CHECK_UNIT(punit) \
263 (fc_assert(punit != NULL), \
264 fc_assert(unit_type_get(punit) != NULL), \
265 fc_assert(unit_owner(punit) != NULL), \
266 fc_assert(player_by_number(player_index(unit_owner(punit))) \
267 == unit_owner(punit)), \
268 fc_assert(game_unit_by_number(punit->id) != NULL))
269#else /* FREECIV_DEBUG */
270#define CHECK_UNIT(punit) /* Do nothing */
271#endif /* FREECIV_DEBUG */
272
273#define activity_type_list_iterate(_act_list_, _act_) \
274{ \
275 int _act_i_; \
276 for (_act_i_ = 0; _act_list_[_act_i_] != ACTIVITY_LAST; _act_i_++) { \
277 Activity_type_id _act_ = _act_list_[_act_i_];
278
279#define activity_type_list_iterate_end \
280 } \
281}
282
283/* Iterates over the types of unit activity. */
284#define activity_type_iterate(_act_) \
285{ \
286 Activity_type_id _act_; \
287 for (_act_ = 0; _act_ != ACTIVITY_LAST; _act_++) { \
288
289#define activity_type_iterate_end \
290 } \
291}
292
294
295#define tile_changing_activities_iterate(_act_) \
296{ \
297 activity_type_list_iterate(tile_changing_activities, _act_)
298
299#define tile_changing_activities_iterate_end \
300 activity_type_list_iterate_end \
301}
302
303bool are_unit_orders_equal(const struct unit_order *order1,
304 const struct unit_order *order2);
305
306int unit_shield_value(const struct unit *punit,
307 const struct unit_type *punittype,
308 const struct action *paction);
310 const struct unit *punit);
311bool unit_can_est_trade_route_here(const struct unit *punit);
314 const struct player *restriction,
315 const struct unit *punit,
316 const struct city *pdest_city);
317bool unit_can_airlift_to(const struct civ_map *nmap,
318 const struct unit *punit, const struct city *pcity)
319 fc__attribute((nonnull (3)));
320bool unit_has_orders(const struct unit *punit);
321
322bool could_unit_be_in_transport(const struct unit *pcargo,
323 const struct unit *ptrans);
324bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans);
325bool can_unit_load(const struct unit *punit, const struct unit *ptrans);
326bool can_unit_unload(const struct unit *punit, const struct unit *ptrans);
328 const struct unit *pcargo,
329 const struct unit *ptrans);
330bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit);
331bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit);
332bool can_unit_change_homecity_to(const struct civ_map *nmap,
333 const struct unit *punit,
334 const struct city *pcity);
335bool can_unit_change_homecity(const struct civ_map *nmap,
336 const struct unit *punit);
339 struct unit *punit);
340bool can_unit_do_activity(const struct civ_map *nmap,
341 const struct unit *punit,
344 const struct unit *punit,
346 struct extra_type *target);
348 const struct unit *punit,
350 struct extra_type *target,
351 const struct tile *ptile);
355 struct extra_type *new_target);
356int get_activity_rate(const struct unit *punit);
357int get_activity_rate_this_turn(const struct unit *punit);
358int get_turns_for_activity_at(const struct unit *punit,
360 const struct tile *ptile,
361 struct extra_type *tgt);
363bool can_unit_do_autosettlers(const struct unit *punit);
365 const struct tile *ptile);
366bv_extras get_unit_tile_pillage_set(const struct tile *ptile);
367bool is_attack_unit(const struct unit *punit);
368bool is_martial_law_unit(const struct unit *punit);
369bool is_occupying_unit(const struct unit *punit);
370bool is_enter_borders_unit(const struct unit *punit);
371bool is_guard_unit(const struct unit *punit);
372bool is_special_unit(const struct unit *punit);
373bool unit_can_do_action(const struct unit *punit,
374 const action_id act_id);
375bool unit_can_do_action_result(const struct unit *punit,
376 enum action_result result);
377bool unit_can_do_action_sub_result(const struct unit *punit,
379bool is_square_threatened(const struct civ_map *nmap,
380 const struct player *pplayer,
381 const struct tile *ptile, bool omniscient);
382bool is_field_unit(const struct unit *punit);
383bool is_hiding_unit(const struct unit *punit);
384bool unit_can_add_or_build_city(const struct civ_map *nmap,
385 const struct unit *punit);
386
387struct astring; /* Forward declaration. */
388
389void unit_activity_astr(const struct unit *punit, struct astring *astr);
390void unit_upkeep_astr(const struct unit *punit, struct astring *astr);
391
392int get_transporter_capacity(const struct unit *punit);
393
394#define unit_home(_pu_) (game_city_by_number((_pu_)->homecity))
395#define is_unit_homeless(_pu_) (punit->homecity == IDENTITY_NUMBER_ZERO)
396#define unit_owner(_pu) ((_pu)->owner)
397#define unit_tile(_pu) ((_pu)->tile)
398struct player *unit_nationality(const struct unit *punit);
399void unit_tile_set(struct unit *punit, struct tile *ptile);
400
401
402struct unit *tile_allied_unit(const struct tile *ptile,
403 const struct player *pplayer);
404
405/**********************************************************************/
408static inline bool is_allied_unit_tile(const struct tile *ptile,
409 const struct player *pplayer)
410{
411 return NULL != tile_allied_unit(ptile, pplayer);
412}
413
414struct unit *tile_enemy_unit(const struct tile *ptile,
415 const struct player *pplayer);
416
417/**********************************************************************/
420static inline bool is_enemy_unit_tile(const struct tile *ptile,
421 const struct player *pplayer)
422{
423 return NULL != tile_enemy_unit(ptile, pplayer);
424}
425
426struct unit *tile_non_allied_unit(const struct tile *ptile,
427 const struct player *pplayer);
428
429/**********************************************************************/
432static inline bool is_non_allied_unit_tile(const struct tile *ptile,
433 const struct player *pplayer)
434{
435 return NULL != tile_non_allied_unit(ptile, pplayer);
436}
437
438struct unit *tile_other_players_unit(const struct tile *ptile,
439 const struct player *pplayer);
440
441/**********************************************************************/
444static inline bool is_other_players_unit_tile(const struct tile *ptile,
445 const struct player *pplayer)
446{
447 return NULL != tile_other_players_unit(ptile, pplayer);
448}
449
450struct unit *tile_non_attack_unit(const struct tile *ptile,
451 const struct player *pplayer);
452
453/**********************************************************************/
457static inline bool is_non_attack_unit_tile(const struct tile *ptile,
458 const struct player *pplayer)
459{
460 return NULL != tile_non_attack_unit(ptile, pplayer);
461}
462
463struct unit *unit_occupies_tile(const struct tile *ptile,
464 const struct player *pplayer);
465
466bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile,
467 const struct civ_map *zmap);
468bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile,
469 const struct civ_map *zmap);
470
471/**********************************************************************/
478static inline bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile,
479 const struct civ_map *zmap)
480{
481 return is_server()
483}
484
485bool unit_being_aggressive(const struct civ_map *nmap,
486 const struct unit *punit);
488
494
495struct unit *unit_virtual_create(struct player *pplayer, struct city *pcity,
496 const struct unit_type *punittype,
497 int veteran_level);
498void unit_virtual_destroy(struct unit *punit);
499bool unit_is_virtual(const struct unit *punit);
500void free_unit_orders(struct unit *punit);
501
502int get_transporter_occupancy(const struct unit *ptrans);
503struct unit *transporter_for_unit(const struct unit *pcargo);
504struct unit *transporter_for_unit_at(const struct unit *pcargo,
505 const struct tile *ptile);
506
509 const struct unit *punit,
510 const struct unit_type *to_unittype);
512 const struct unit *punit,
513 bool is_free);
515 const struct unit *punit,
516 char *buf, size_t bufsz);
517bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit);
518
519int unit_pays_mp_for_action(const struct action *paction,
520 const struct unit *punit);
521
522int hp_gain_coord(const struct unit *punit);
523int unit_gain_hitpoints(const struct unit *punit);
524bool is_losing_hp(const struct unit *punit);
525bool unit_type_is_losing_hp(const struct player *pplayer,
526 const struct unit_type *punittype);
527
528bool unit_is_alive(int id);
529
530void *unit_ai_data(const struct unit *punit, const struct ai_type *ai);
531void unit_set_ai_data(struct unit *punit, const struct ai_type *ai,
532 void *data);
533
534int unit_bribe_cost(struct unit *punit, struct player *briber);
535
536bool unit_transport_load(struct unit *pcargo, struct unit *ptrans,
537 bool force);
538bool unit_transport_unload(struct unit *pcargo);
539struct unit *unit_transport_get(const struct unit *pcargo);
540
541#define unit_transported_server(_pcargo_) ((_pcargo_)->transporter != NULL)
542
543/* Evaluates parameter twice! */
544#define unit_transported_client(_pcargo_) \
545 ((_pcargo_)->client.transported_by != -1 \
546 || (_pcargo_)->transporter != NULL)
547
548bool unit_transported(const struct unit *pcargo);
549struct unit_list *unit_transport_cargo(const struct unit *ptrans);
550bool unit_transport_check(const struct unit *pcargo,
551 const struct unit *ptrans);
552bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans);
553int unit_cargo_depth(const struct unit *pcargo);
554int unit_transport_depth(const struct unit *ptrans);
555
556bool unit_is_cityfounder(const struct unit *punit);
557
558/* Iterate all transporters carrying '_pcargo', directly or indirectly. */
559#define unit_transports_iterate(_pcargo, _ptrans) { \
560 struct unit *_ptrans; \
561 for (_ptrans = unit_transport_get(_pcargo); NULL != _ptrans; \
562 _ptrans = unit_transport_get(_ptrans)) {
563#define unit_transports_iterate_end }}
564
565struct cargo_iter;
566size_t cargo_iter_sizeof(void) fc__attribute((const));
567
569 const struct unit *ptrans);
570#define unit_cargo_iterate(_ptrans, _pcargo) \
571 generic_iterate(struct cargo_iter, struct unit *, _pcargo, \
572 cargo_iter_sizeof, cargo_iter_init, _ptrans)
573#define unit_cargo_iterate_end generic_iterate_end
574
575bool unit_order_list_is_sane(const struct civ_map *nmap,
576 int length, const struct unit_order *orders);
577struct unit_order *create_unit_orders(const struct civ_map *nmap,
578 int length,
579 const struct unit_order *orders);
580
581#ifdef __cplusplus
582}
583#endif /* __cplusplus */
584
585#endif /* FC__UNIT_H */
char * incite_cost
Definition comments.c:75
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
static bool is_server(void)
enum unit_activity Activity_type_id
Definition fc_types.h:379
adv_unit_task
Definition fc_types.h:370
int action_id
Definition fc_types.h:389
@ O_LAST
Definition fc_types.h:101
static const int bufsz
Definition helpdlg.c:70
Definition ai.h:50
Definition city.h:320
Definition tile.h:50
enum adv_unit_task task
Definition unit.h:89
enum unit_activity activity
Definition unit.h:94
enum unit_orders order
Definition unit.h:93
int action
Definition unit.h:100
enum direction8 dir
Definition unit.h:102
int target
Definition unit.h:97
int sub_target
Definition unit.h:98
Definition unit.h:138
time_t action_timestamp
Definition unit.h:245
int upkeep[O_LAST]
Definition unit.h:148
bool has_orders
Definition unit.h:193
struct unit::@80 orders
bool occupied
Definition unit.h:219
enum action_decision action_decision_want
Definition unit.h:202
int battlegroup
Definition unit.h:191
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
int refcount
Definition unit.h:141
struct unit::@81::@83 client
int id
Definition unit.h:145
struct unit_list * transporting
Definition unit.h:184
int ord_city
Definition unit.h:242
bool moved
Definition unit.h:173
int ord_map
Definition unit.h:241
bool debug
Definition unit.h:234
int index
Definition unit.h:195
struct vision * vision
Definition unit.h:244
bool vigilant
Definition unit.h:197
int hp
Definition unit.h:151
int fuel
Definition unit.h:153
struct extra_type * changed_from_target
Definition unit.h:170
int current_form_turn
Definition unit.h:208
bool stay
Definition unit.h:205
bool colored
Definition unit.h:222
enum direction8 facing
Definition unit.h:142
struct unit::@81::@84 server
bool asking_city_name
Definition unit.h:225
struct tile * tile
Definition unit.h:140
struct extra_type * activity_target
Definition unit.h:164
struct act_prob * act_prob_cache
Definition unit.h:228
int activity_count
Definition unit.h:162
struct unit_order * list
Definition unit.h:198
enum unit_activity changed_from
Definition unit.h:168
struct unit_adv * adv
Definition unit.h:236
struct player * nationality
Definition unit.h:144
int transported_by
Definition unit.h:216
bool repeat
Definition unit.h:196
int color_index
Definition unit.h:223
struct unit_move_data * moving
Definition unit.h:247
int action_turn
Definition unit.h:246
int homecity
Definition unit.h:146
bool paradropped
Definition unit.h:174
bool done_moving
Definition unit.h:181
struct unit * transporter
Definition unit.h:183
int birth_turn
Definition unit.h:207
struct goods_type * carrying
Definition unit.h:186
struct tile * goto_tile
Definition unit.h:155
struct tile * action_decision_tile
Definition unit.h:203
const struct unit_type * utype
Definition unit.h:139
int veteran
Definition unit.h:152
int changed_from_count
Definition unit.h:169
struct player * owner
Definition unit.h:143
bool dying
Definition unit.h:250
enum unit_focus_status focus_status
Definition unit.h:214
enum server_side_agent ssa_controller
Definition unit.h:172
#define fc__attribute(x)
Definition support.h:99
size_t cargo_iter_sizeof(void) fc__attribute((const))
bool unit_can_do_action_sub_result(const struct unit *punit, enum action_sub_result sub_result)
Definition unit.c:379
static bool is_other_players_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:444
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)
Definition unit.c:920
bool is_tile_activity(enum unit_activity activity)
Definition unit.c:1604
struct unit_order * create_unit_orders(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2834
enum unit_upgrade_result unit_transform_result(const struct civ_map *nmap, const struct unit *punit, const struct unit_type *to_unittype)
Definition unit.c:1956
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1504
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
Definition unit.c:2240
bool is_terrain_change_activity(enum unit_activity activity)
Definition unit.c:1589
struct unit * tile_non_allied_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1306
int unit_shield_value(const struct unit *punit, const struct unit_type *punittype, const struct action *paction)
Definition unit.c:214
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1783
goto_route_type
Definition unit.h:56
@ ROUTE_GOTO
Definition unit.h:57
@ ROUTE_PATROL
Definition unit.h:57
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
Definition unit.c:465
void free_unit_orders(struct unit *punit)
Definition unit.c:1769
void unit_set_ai_data(struct unit *punit, const struct ai_type *ai, void *data)
Definition unit.c:2290
bool unit_is_alive(int id)
Definition unit.c:2253
bool unit_can_est_trade_route_here(const struct unit *punit)
Definition unit.c:284
bool is_occupying_unit(const struct unit *punit)
Definition unit.c:324
bool is_hiding_unit(const struct unit *punit)
Definition unit.c:426
int get_activity_rate_this_turn(const struct unit *punit)
Definition unit.c:526
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2135
int get_turns_for_activity_at(const struct unit *punit, enum unit_activity activity, const struct tile *ptile, struct extra_type *tgt)
Definition unit.c:542
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:420
unit_focus_status
Definition unit.h:52
@ FOCUS_AVAIL
Definition unit.h:53
@ FOCUS_DONE
Definition unit.h:53
@ FOCUS_WAIT
Definition unit.h:53
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
Definition unit.c:2370
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1922
struct iterator * cargo_iter_init(struct cargo_iter *iter, const struct unit *ptrans)
Definition unit.c:2624
int unit_cargo_depth(const struct unit *pcargo)
Definition unit.c:2533
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:457
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2051
unit_orders
Definition unit.h:37
@ ORDER_ACTION_MOVE
Definition unit.h:45
@ ORDER_ACTIVITY
Definition unit.h:41
@ ORDER_FULL_MP
Definition unit.h:43
@ ORDER_MOVE
Definition unit.h:39
@ ORDER_LAST
Definition unit.h:49
@ ORDER_PERFORM_ACTION
Definition unit.h:47
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
Definition unit.c:1088
bool is_losing_hp(const struct unit *punit)
Definition unit.c:2228
bool is_targeted_activity(enum unit_activity activity)
Definition unit.c:1614
bool unit_can_add_or_build_city(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:448
struct unit * tile_non_attack_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1339
int hp_gain_coord(const struct unit *punit)
Definition unit.c:2162
bool can_unit_change_homecity(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:481
bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.c:1456
struct player * unit_nationality(const struct unit *punit)
Definition unit.c:1245
bool unit_being_aggressive(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:1518
int get_activity_rate(const struct unit *punit)
Definition unit.c:495
bool can_unit_deboard_or_be_unloaded(const struct civ_map *nmap, const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:777
bool unit_transport_check(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2479
bool is_attack_unit(const struct unit *punit)
Definition unit.c:305
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:408
const Activity_type_id tile_changing_activities[]
Definition unit.c:44
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2441
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2390
bool is_build_activity(enum unit_activity activity)
Definition unit.c:1559
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2520
#define unit_owner(_pu)
Definition unit.h:396
int unit_gain_hitpoints(const struct unit *punit)
Definition unit.c:2183
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)
Definition unit.c:81
bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.c:1387
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
Definition unit.c:841
int unit_bribe_cost(struct unit *punit, struct player *briber)
Definition unit.c:2304
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1231
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:700
bool unit_is_cityfounder(const struct unit *punit)
Definition unit.c:2641
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
Definition unit.c:1123
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:606
unit_upgrade_result
Definition unit.h:60
@ UU_NO_MONEY
Definition unit.h:63
@ UU_NOT_IN_CITY
Definition unit.h:64
@ UU_NO_UNITTYPE
Definition unit.h:62
@ UU_NOT_TERRAIN
Definition unit.h:67
@ UU_UNSUITABLE_TRANSPORT
Definition unit.h:68
@ UU_NOT_CITY_OWNER
Definition unit.h:65
@ UU_NOT_ENOUGH_ROOM
Definition unit.h:66
@ UU_OK
Definition unit.h:61
@ UU_NOT_ACTIVITY
Definition unit.h:69
bool is_field_unit(const struct unit *punit)
Definition unit.c:414
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:359
bool unit_can_do_action_result(const struct unit *punit, enum action_result result)
Definition unit.c:369
bool is_martial_law_unit(const struct unit *punit)
Definition unit.c:316
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
Definition unit.c:1105
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1624
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:806
bool unit_order_list_is_sane(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2649
const char * get_activity_text(enum unit_activity activity)
Definition unit.c:614
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1138
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:297
bool can_unit_unload(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:752
bool is_enter_borders_unit(const struct unit *punit)
Definition unit.c:332
bool is_clean_activity(enum unit_activity activity)
Definition unit.c:1575
int unit_transport_depth(const struct unit *ptrans)
Definition unit.c:2551
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:822
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1155
bool unit_can_help_build_wonder_here(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:258
bool can_unit_do_activity(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity)
Definition unit.c:868
struct unit * tile_other_players_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1323
bool is_special_unit(const struct unit *punit)
Definition unit.c:350
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1729
struct unit * tile_enemy_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1291
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1255
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1988
bool unit_can_airlift_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity) fc__attribute((nonnull(3)))
Definition unit.c:186
bool can_unit_load(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:725
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2425
bool are_unit_orders_equal(const struct unit_order *order1, const struct unit_order *order2)
Definition unit.c:59
bool unit_is_virtual(const struct unit *punit)
Definition unit.c:2270
bool is_square_threatened(const struct civ_map *nmap, const struct player *pplayer, const struct tile *ptile, bool omniscient)
Definition unit.c:388
bool is_guard_unit(const struct unit *punit)
Definition unit.c:340
struct unit * unit_occupies_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1360
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2451
void * unit_ai_data(const struct unit *punit, const struct ai_type *ai)
Definition unit.c:2282
bool unit_has_orders(const struct unit *punit)
Definition unit.c:202
struct unit * tile_allied_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1268
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1912
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:432
unit_airlift_result
Definition unit.h:72
@ AR_SRC_NO_FLIGHTS
Definition unit.h:84
@ AR_OK_SRC_UNKNOWN
Definition unit.h:75
@ AR_OK_DST_UNKNOWN
Definition unit.h:76
@ AR_NO_MOVES
Definition unit.h:78
@ AR_BAD_DST_CITY
Definition unit.h:83
@ AR_NOT_IN_CITY
Definition unit.h:81
@ AR_OCCUPIED
Definition unit.h:80
@ AR_OK
Definition unit.h:74
@ AR_DST_NO_FLIGHTS
Definition unit.h:85
@ AR_WRONG_UNITTYPE
Definition unit.h:79
@ AR_BAD_SRC_CITY
Definition unit.h:82
static bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.h:478
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2035
bool activity_requires_target(enum unit_activity activity)
Definition unit.c:566
bool could_unit_be_in_transport(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:668
bool can_unit_do_activity_targeted(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, struct extra_type *target)
Definition unit.c:907