Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/unit.h Source File

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. */
37 enum unit_orders {
38 /* Move without performing any action (dir) */
39 ORDER_MOVE = 0,
40 /* Perform activity (activity, extra) */
41 ORDER_ACTIVITY = 1,
42 /* Pause to regain movement points (no parameters) */
43 ORDER_FULL_MP = 2,
44 /* Move; if necessary prompt for action/target when order executed (dir) */
45 ORDER_ACTION_MOVE = 3,
46 /* Perform pre-specified action (action, target tile, sub target) */
47 ORDER_PERFORM_ACTION = 4,
48 /* and plenty more for later... */
49 ORDER_LAST
50};
51
52 enum unit_focus_status {
53 FOCUS_AVAIL, FOCUS_WAIT, FOCUS_DONE
54};
55
56 enum goto_route_type {
57 ROUTE_GOTO, ROUTE_PATROL
58};
59
60 enum unit_upgrade_result {
61 UU_OK,
62 UU_NO_UNITTYPE,
63 UU_NO_MONEY,
64 UU_NOT_IN_CITY,
65 UU_NOT_CITY_OWNER,
66 UU_NOT_ENOUGH_ROOM,
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
72 enum unit_airlift_result {
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
88 struct unit_adv {
89 enum adv_unit_task task;
90};
91
92 struct unit_order {
93 enum unit_orders 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;
98 int sub_target;
99 /* Only valid for ORDER_PERFORM_ACTION */
100 int action;
101 /* Valid for ORDER_MOVE and ORDER_ACTION_MOVE. */
102 enum direction8 dir;
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
138 struct unit {
139 const struct unit_type *utype; /* Cannot be NULL. */
140 struct tile *tile;
141 int refcount;
142 enum direction8 facing;
143 struct player *owner; /* Cannot be NULL. */
144 struct player *nationality;
145 int id;
146 int homecity;
147
148 int upkeep[O_LAST]; /* unit upkeep with regards to the homecity */
149
150 int moves_left;
151 int hp;
152 int veteran;
153 int fuel;
154
155 struct tile *goto_tile; /* May be NULL. */
156
157 enum unit_activity activity;
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). */
162 int activity_count;
163
164 struct extra_type *activity_target;
165
166 /* Previous activity, so it can be resumed without loss of progress
167 * if the user changes their mind during a turn. */
168 enum unit_activity changed_from;
169 int changed_from_count;
170 struct extra_type *changed_from_target;
171
172 enum server_side_agent ssa_controller;
173 bool moved;
174 bool paradropped;
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. */
181 bool done_moving;
182
183 struct unit *transporter; /* This unit is transported by ... */
184 struct unit_list *transporting; /* This unit transports ... */
185
186 struct goods_type *carrying;
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)
191 int battlegroup;
192
193 bool has_orders;
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. */
198 struct unit_order *list;
199 } orders;
200
201 /* The unit may want the player to choose an action. */
202 enum action_decision action_decision_want;
203 struct tile *action_decision_tile;
204
205 bool stay; /* Unit is prohibited from moving */
206
207 int birth_turn;
208 int current_form_turn;
209
210 union {
211 struct {
212 /* Only used at the client (the server is omniscient; ./client/). */
213
214 enum unit_focus_status focus_status;
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. */
222 bool colored;
223 int color_index;
224
225 bool asking_city_name;
226
227 /* Used in a follow up question about a selected action. */
228 struct act_prob *act_prob_cache;
229 } client;
230
231 struct {
232 /* Only used in the server (./ai/ and ./server/). */
233
234 bool debug;
235
236 struct unit_adv *adv;
237 void *ais[FREECIV_AI_MOD_LAST];
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 */
241 int ord_map;
242 int ord_city;
243
244 struct vision *vision;
245 time_t action_timestamp;
246 int action_turn;
247 struct unit_move_data *moving;
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];
257 } server;
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
293extern const Activity_type_id tile_changing_activities[];
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);
309bool unit_can_help_build_wonder_here(const struct unit *punit);
310bool unit_can_est_trade_route_here(const struct unit *punit);
311enum unit_airlift_result
312 test_unit_can_airlift_to(const struct civ_map *nmap,
313 const struct player *restriction,
314 const struct unit *punit,
315 const struct city *pdest_city);
316bool unit_can_airlift_to(const struct unit *punit, const struct city *pcity);
317bool unit_has_orders(const struct unit *punit);
318
319bool could_unit_be_in_transport(const struct unit *pcargo,
320 const struct unit *ptrans);
321bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans);
322bool can_unit_load(const struct unit *punit, const struct unit *ptrans);
323bool can_unit_unload(const struct unit *punit, const struct unit *ptrans);
324bool can_unit_deboard_or_be_unloaded(const struct unit *pcargo,
325 const struct unit *ptrans);
326bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit);
327bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit);
328bool can_unit_change_homecity_to(const struct unit *punit,
329 const struct city *pcity);
330bool can_unit_change_homecity(const struct unit *punit);
331const char *get_activity_text(enum unit_activity activity);
332bool can_unit_continue_current_activity(const struct civ_map *nmap,
333 struct unit *punit);
334bool can_unit_do_activity(const struct civ_map *nmap,
335 const struct unit *punit,
336 enum unit_activity activity);
337bool can_unit_do_activity_targeted(const struct civ_map *nmap,
338 const struct unit *punit,
339 enum unit_activity activity,
340 struct extra_type *target);
341bool can_unit_do_activity_targeted_at(const struct civ_map *nmap,
342 const struct unit *punit,
343 enum unit_activity activity,
344 struct extra_type *target,
345 const struct tile *ptile);
346void set_unit_activity(struct unit *punit, enum unit_activity new_activity);
347void set_unit_activity_targeted(struct unit *punit,
348 enum unit_activity new_activity,
349 struct extra_type *new_target);
350int get_activity_rate(const struct unit *punit);
351int get_activity_rate_this_turn(const struct unit *punit);
352int get_turns_for_activity_at(const struct unit *punit,
353 enum unit_activity activity,
354 const struct tile *ptile,
355 struct extra_type *tgt);
356bool activity_requires_target(enum unit_activity activity);
357bool can_unit_do_autosettlers(const struct unit *punit);
358bool is_unit_activity_on_tile(enum unit_activity activity,
359 const struct tile *ptile);
360 bv_extras get_unit_tile_pillage_set(const struct tile *ptile);
361bool is_attack_unit(const struct unit *punit);
362bool is_martial_law_unit(const struct unit *punit);
363bool is_occupying_unit(const struct unit *punit);
364bool is_enter_borders_unit(const struct unit *punit);
365bool is_guard_unit(const struct unit *punit);
366bool is_special_unit(const struct unit *punit);
367bool unit_can_do_action(const struct unit *punit,
368 const action_id act_id);
369bool unit_can_do_action_result(const struct unit *punit,
370 enum action_result result);
371bool unit_can_do_action_sub_result(const struct unit *punit,
372 enum action_sub_result sub_result);
373bool is_square_threatened(const struct civ_map *nmap,
374 const struct player *pplayer,
375 const struct tile *ptile, bool omniscient);
376bool is_field_unit(const struct unit *punit);
377bool is_hiding_unit(const struct unit *punit);
378bool unit_can_add_or_build_city(const struct unit *punit);
379
380struct astring; /* Forward declaration. */
381
382void unit_activity_astr(const struct unit *punit, struct astring *astr);
383void unit_upkeep_astr(const struct unit *punit, struct astring *astr);
384
385int get_transporter_capacity(const struct unit *punit);
386
387#define unit_home(_pu_) (game_city_by_number((_pu_)->homecity))
388#define is_unit_homeless(_pu_) (punit->homecity == IDENTITY_NUMBER_ZERO)
389#define unit_owner(_pu) ((_pu)->owner)
390#define unit_tile(_pu) ((_pu)->tile)
391struct player *unit_nationality(const struct unit *punit);
392void unit_tile_set(struct unit *punit, struct tile *ptile);
393
394
395struct unit *tile_allied_unit(const struct tile *ptile,
396 const struct player *pplayer);
397
398/**********************************************************************/
401 static inline bool is_allied_unit_tile(const struct tile *ptile,
402 const struct player *pplayer)
403{
404 return NULL != tile_allied_unit(ptile, pplayer);
405}
406
407struct unit *tile_enemy_unit(const struct tile *ptile,
408 const struct player *pplayer);
409
410/**********************************************************************/
413 static inline bool is_enemy_unit_tile(const struct tile *ptile,
414 const struct player *pplayer)
415{
416 return NULL != tile_enemy_unit(ptile, pplayer);
417}
418
419struct unit *tile_non_allied_unit(const struct tile *ptile,
420 const struct player *pplayer);
421
422/**********************************************************************/
425 static inline bool is_non_allied_unit_tile(const struct tile *ptile,
426 const struct player *pplayer)
427{
428 return NULL != tile_non_allied_unit(ptile, pplayer);
429}
430
431struct unit *tile_other_players_unit(const struct tile *ptile,
432 const struct player *pplayer);
433
434/**********************************************************************/
437 static inline bool is_other_players_unit_tile(const struct tile *ptile,
438 const struct player *pplayer)
439{
440 return NULL != tile_other_players_unit(ptile, pplayer);
441}
442
443struct unit *tile_non_attack_unit(const struct tile *ptile,
444 const struct player *pplayer);
445
446/**********************************************************************/
450 static inline bool is_non_attack_unit_tile(const struct tile *ptile,
451 const struct player *pplayer)
452{
453 return NULL != tile_non_attack_unit(ptile, pplayer);
454}
455
456struct unit *unit_occupies_tile(const struct tile *ptile,
457 const struct player *pplayer);
458
459bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile,
460 const struct civ_map *zmap);
461bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile,
462 const struct civ_map *zmap);
463
464/**********************************************************************/
471 static inline bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile,
472 const struct civ_map *zmap)
473{
474 return is_server()
475 ? is_plr_zoc_srv(unit_owner, ptile, zmap) : is_plr_zoc_client(unit_owner, ptile, zmap);
476}
477
478bool unit_being_aggressive(const struct unit *punit);
479bool unit_type_really_ignores_zoc(const struct unit_type *punittype);
480
481bool is_build_activity(enum unit_activity activity);
482bool is_clean_activity(enum unit_activity activity);
483bool is_terrain_change_activity(enum unit_activity activity);
484bool is_tile_activity(enum unit_activity activity);
485bool is_targeted_activity(enum unit_activity activity);
486
487struct unit *unit_virtual_create(struct player *pplayer, struct city *pcity,
488 const struct unit_type *punittype,
489 int veteran_level);
490void unit_virtual_destroy(struct unit *punit);
491bool unit_is_virtual(const struct unit *punit);
492void free_unit_orders(struct unit *punit);
493
494int get_transporter_occupancy(const struct unit *ptrans);
495struct unit *transporter_for_unit(const struct unit *pcargo);
496struct unit *transporter_for_unit_at(const struct unit *pcargo,
497 const struct tile *ptile);
498
499enum unit_upgrade_result
500 unit_transform_result(const struct civ_map *nmap,
501 const struct unit *punit,
502 const struct unit_type *to_unittype);
503enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap,
504 const struct unit *punit,
505 bool is_free);
506enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap,
507 const struct unit *punit,
508 char *buf, size_t bufsz);
509bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit);
510
511int unit_pays_mp_for_action(const struct action *paction,
512 const struct unit *punit);
513
514int hp_gain_coord(const struct unit *punit);
515int unit_gain_hitpoints(const struct unit *punit);
516bool is_losing_hp(const struct unit *punit);
517bool unit_type_is_losing_hp(const struct player *pplayer,
518 const struct unit_type *punittype);
519
520bool unit_is_alive(int id);
521
522void *unit_ai_data(const struct unit *punit, const struct ai_type *ai);
523void unit_set_ai_data(struct unit *punit, const struct ai_type *ai,
524 void *data);
525
526int unit_bribe_cost(struct unit *punit, struct player *briber);
527
528bool unit_transport_load(struct unit *pcargo, struct unit *ptrans,
529 bool force);
530bool unit_transport_unload(struct unit *pcargo);
531struct unit *unit_transport_get(const struct unit *pcargo);
532
533#define unit_transported_server(_pcargo_) ((_pcargo_)->transporter != NULL)
534
535/* Evaluates parameter twice! */
536#define unit_transported_client(_pcargo_) \
537 ((_pcargo_)->client.transported_by != -1 \
538 || (_pcargo_)->transporter != NULL)
539
540bool unit_transported(const struct unit *pcargo);
541struct unit_list *unit_transport_cargo(const struct unit *ptrans);
542bool unit_transport_check(const struct unit *pcargo,
543 const struct unit *ptrans);
544bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans);
545int unit_cargo_depth(const struct unit *pcargo);
546int unit_transport_depth(const struct unit *ptrans);
547
548bool unit_is_cityfounder(const struct unit *punit);
549
550/* Iterate all transporters carrying '_pcargo', directly or indirectly. */
551#define unit_transports_iterate(_pcargo, _ptrans) { \
552 struct unit *_ptrans; \
553 for (_ptrans = unit_transport_get(_pcargo); NULL != _ptrans; \
554 _ptrans = unit_transport_get(_ptrans)) {
555#define unit_transports_iterate_end }}
556
557struct cargo_iter;
558 size_t cargo_iter_sizeof(void) fc__attribute((const));
559
560struct iterator *cargo_iter_init(struct cargo_iter *iter,
561 const struct unit *ptrans);
562#define unit_cargo_iterate(_ptrans, _pcargo) \
563 generic_iterate(struct cargo_iter, struct unit *, _pcargo, \
564 cargo_iter_sizeof, cargo_iter_init, _ptrans)
565#define unit_cargo_iterate_end generic_iterate_end
566
567bool unit_order_list_is_sane(const struct civ_map *nmap,
568 int length, const struct unit_order *orders);
569struct unit_order *create_unit_orders(const struct civ_map *nmap,
570 int length,
571 const struct unit_order *orders);
572
573#ifdef __cplusplus
574}
575#endif /* __cplusplus */
576
577#endif /* FC__UNIT_H */
base.h
bitvector.h
incite_cost
char * incite_cost
Definition comments.c:74
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
fc_interface.h
is_server
static bool is_server(void)
Definition fc_interface.h:69
fc_types.h
Activity_type_id
enum unit_activity Activity_type_id
Definition fc_types.h:382
adv_unit_task
adv_unit_task
Definition fc_types.h:373
action_id
int action_id
Definition fc_types.h:392
O_LAST
@ O_LAST
Definition fc_types.h:101
bufsz
static const int bufsz
Definition helpdlg.c:70
map_types.h
specenum_gen.h
act_prob
Definition fc_types.h:1241
action
Definition actions.h:360
ai_type
Definition ai.h:50
astring
Definition astring.h:36
cargo_iter
Definition unit.c:49
city
Definition city.h:320
civ_map
Definition map_types.h:71
extra_type
Definition extras.h:88
goods_type
Definition traderoutes.h:183
iterator
Definition iterator.h:31
player
Definition player.h:247
road_type
Definition road.h:71
tile
Definition tile.h:50
unit_adv
Definition unit.h:88
unit_adv::task
enum adv_unit_task task
Definition unit.h:89
unit_move_data
Definition unittools.c:91
unit_order
Definition unit.h:92
unit_order::activity
enum unit_activity activity
Definition unit.h:94
unit_order::order
enum unit_orders order
Definition unit.h:93
unit_order::action
int action
Definition unit.h:100
unit_order::dir
enum direction8 dir
Definition unit.h:102
unit_order::target
int target
Definition unit.h:97
unit_order::sub_target
int sub_target
Definition unit.h:98
unit_type
Definition unittype.h:500
unit
Definition unit.h:138
unit::action_timestamp
time_t action_timestamp
Definition unit.h:245
unit::upkeep
int upkeep[O_LAST]
Definition unit.h:148
unit::has_orders
bool has_orders
Definition unit.h:193
unit::orders
struct unit::@80 orders
unit::occupied
bool occupied
Definition unit.h:219
unit::action_decision_want
enum action_decision action_decision_want
Definition unit.h:202
unit::battlegroup
int battlegroup
Definition unit.h:191
unit::activity
enum unit_activity activity
Definition unit.h:157
unit::moves_left
int moves_left
Definition unit.h:150
unit::refcount
int refcount
Definition unit.h:141
unit::client
struct unit::@81::@83 client
unit::id
int id
Definition unit.h:145
unit::transporting
struct unit_list * transporting
Definition unit.h:184
unit::ord_city
int ord_city
Definition unit.h:242
unit::moved
bool moved
Definition unit.h:173
unit::ord_map
int ord_map
Definition unit.h:241
unit::debug
bool debug
Definition unit.h:234
unit::index
int index
Definition unit.h:195
unit::vision
struct vision * vision
Definition unit.h:244
unit::vigilant
bool vigilant
Definition unit.h:197
unit::hp
int hp
Definition unit.h:151
unit::fuel
int fuel
Definition unit.h:153
unit::changed_from_target
struct extra_type * changed_from_target
Definition unit.h:170
unit::current_form_turn
int current_form_turn
Definition unit.h:208
unit::stay
bool stay
Definition unit.h:205
unit::colored
bool colored
Definition unit.h:222
unit::facing
enum direction8 facing
Definition unit.h:142
unit::server
struct unit::@81::@84 server
unit::asking_city_name
bool asking_city_name
Definition unit.h:225
unit::tile
struct tile * tile
Definition unit.h:140
unit::activity_target
struct extra_type * activity_target
Definition unit.h:164
unit::act_prob_cache
struct act_prob * act_prob_cache
Definition unit.h:228
unit::activity_count
int activity_count
Definition unit.h:162
unit::list
struct unit_order * list
Definition unit.h:198
unit::changed_from
enum unit_activity changed_from
Definition unit.h:168
unit::adv
struct unit_adv * adv
Definition unit.h:236
unit::nationality
struct player * nationality
Definition unit.h:144
unit::transported_by
int transported_by
Definition unit.h:216
unit::repeat
bool repeat
Definition unit.h:196
unit::color_index
int color_index
Definition unit.h:223
unit::moving
struct unit_move_data * moving
Definition unit.h:247
unit::action_turn
int action_turn
Definition unit.h:246
unit::homecity
int homecity
Definition unit.h:146
unit::paradropped
bool paradropped
Definition unit.h:174
unit::done_moving
bool done_moving
Definition unit.h:181
unit::transporter
struct unit * transporter
Definition unit.h:183
unit::birth_turn
int birth_turn
Definition unit.h:207
unit::carrying
struct goods_type * carrying
Definition unit.h:186
unit::goto_tile
struct tile * goto_tile
Definition unit.h:155
unit::action_decision_tile
struct tile * action_decision_tile
Definition unit.h:203
unit::utype
const struct unit_type * utype
Definition unit.h:139
unit::veteran
int veteran
Definition unit.h:152
unit::changed_from_count
int changed_from_count
Definition unit.h:169
unit::owner
struct player * owner
Definition unit.h:143
unit::dying
bool dying
Definition unit.h:250
unit::focus_status
enum unit_focus_status focus_status
Definition unit.h:214
unit::ssa_controller
enum server_side_agent ssa_controller
Definition unit.h:172
veteran_level
Definition unittype.h:486
vision
Definition vision.h:85
fc__attribute
#define fc__attribute(x)
Definition support.h:99
terrain.h
cargo_iter_sizeof
size_t cargo_iter_sizeof(void) fc__attribute((const))
unit_can_do_action_sub_result
bool unit_can_do_action_sub_result(const struct unit *punit, enum action_sub_result sub_result)
Definition unit.c:381
is_other_players_unit_tile
static bool is_other_players_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:437
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)
Definition unit.c:917
is_tile_activity
bool is_tile_activity(enum unit_activity activity)
Definition unit.c:1600
create_unit_orders
struct unit_order * create_unit_orders(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2830
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)
Definition unit.c:1952
unit_being_aggressive
bool unit_being_aggressive(const struct unit *punit)
Definition unit.c:1515
unit_type_really_ignores_zoc
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1501
unit_type_is_losing_hp
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
Definition unit.c:2236
is_terrain_change_activity
bool is_terrain_change_activity(enum unit_activity activity)
Definition unit.c:1585
tile_non_allied_unit
struct unit * tile_non_allied_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1303
unit_shield_value
int unit_shield_value(const struct unit *punit, const struct unit_type *punittype, const struct action *paction)
Definition unit.c:217
get_transporter_occupancy
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1779
goto_route_type
goto_route_type
Definition unit.h:56
ROUTE_GOTO
@ ROUTE_GOTO
Definition unit.h:57
ROUTE_PATROL
@ ROUTE_PATROL
Definition unit.h:57
unit_can_airlift_to
bool unit_can_airlift_to(const struct unit *punit, const struct city *pcity)
Definition unit.c:186
free_unit_orders
void free_unit_orders(struct unit *punit)
Definition unit.c:1765
can_unit_change_homecity
bool can_unit_change_homecity(const struct unit *punit)
Definition unit.c:481
unit_set_ai_data
void unit_set_ai_data(struct unit *punit, const struct ai_type *ai, void *data)
Definition unit.c:2286
unit_is_alive
bool unit_is_alive(int id)
Definition unit.c:2249
unit_can_est_trade_route_here
bool unit_can_est_trade_route_here(const struct unit *punit)
Definition unit.c:286
is_occupying_unit
bool is_occupying_unit(const struct unit *punit)
Definition unit.c:326
is_hiding_unit
bool is_hiding_unit(const struct unit *punit)
Definition unit.c:428
get_activity_rate_this_turn
int get_activity_rate_this_turn(const struct unit *punit)
Definition unit.c:522
unit_pays_mp_for_action
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2131
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)
Definition unit.c:538
is_enemy_unit_tile
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:413
unit_focus_status
unit_focus_status
Definition unit.h:52
FOCUS_AVAIL
@ FOCUS_AVAIL
Definition unit.h:53
FOCUS_DONE
@ FOCUS_DONE
Definition unit.h:53
FOCUS_WAIT
@ FOCUS_WAIT
Definition unit.h:53
unit_transport_load
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
Definition unit.c:2366
unit_can_add_or_build_city
bool unit_can_add_or_build_city(const struct unit *punit)
Definition unit.c:450
transporter_for_unit_at
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1918
cargo_iter_init
struct iterator * cargo_iter_init(struct cargo_iter *iter, const struct unit *ptrans)
Definition unit.c:2620
unit_cargo_depth
int unit_cargo_depth(const struct unit *pcargo)
Definition unit.c:2529
is_non_attack_unit_tile
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:450
unit_upgrade_info
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2047
unit_orders
unit_orders
Definition unit.h:37
ORDER_ACTION_MOVE
@ ORDER_ACTION_MOVE
Definition unit.h:45
ORDER_ACTIVITY
@ ORDER_ACTIVITY
Definition unit.h:41
ORDER_FULL_MP
@ ORDER_FULL_MP
Definition unit.h:43
ORDER_MOVE
@ ORDER_MOVE
Definition unit.h:39
ORDER_LAST
@ ORDER_LAST
Definition unit.h:49
ORDER_PERFORM_ACTION
@ ORDER_PERFORM_ACTION
Definition unit.h:47
set_unit_activity
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
Definition unit.c:1085
is_losing_hp
bool is_losing_hp(const struct unit *punit)
Definition unit.c:2224
is_targeted_activity
bool is_targeted_activity(enum unit_activity activity)
Definition unit.c:1610
can_unit_deboard_or_be_unloaded
bool can_unit_deboard_or_be_unloaded(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:773
can_unit_change_homecity_to
bool can_unit_change_homecity_to(const struct unit *punit, const struct city *pcity)
Definition unit.c:466
tile_non_attack_unit
struct unit * tile_non_attack_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1336
hp_gain_coord
int hp_gain_coord(const struct unit *punit)
Definition unit.c:2158
is_plr_zoc_client
bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.c:1453
unit_nationality
struct player * unit_nationality(const struct unit *punit)
Definition unit.c:1242
get_activity_rate
int get_activity_rate(const struct unit *punit)
Definition unit.c:494
unit_transport_check
bool unit_transport_check(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2475
is_attack_unit
bool is_attack_unit(const struct unit *punit)
Definition unit.c:307
is_allied_unit_tile
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:401
tile_changing_activities
const Activity_type_id tile_changing_activities[]
Definition unit.c:44
unit_transport_get
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2437
unit_transport_unload
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2386
is_build_activity
bool is_build_activity(enum unit_activity activity)
Definition unit.c:1555
unit_contained_in
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2516
unit_owner
#define unit_owner(_pu)
Definition unit.h:389
unit_gain_hitpoints
int unit_gain_hitpoints(const struct unit *punit)
Definition unit.c:2179
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)
Definition unit.c:81
is_plr_zoc_srv
bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.c:1384
can_unit_continue_current_activity
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
Definition unit.c:838
unit_bribe_cost
int unit_bribe_cost(struct unit *punit, struct player *briber)
Definition unit.c:2300
unit_upkeep_astr
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1228
could_unit_load
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:696
unit_is_cityfounder
bool unit_is_cityfounder(const struct unit *punit)
Definition unit.c:2637
is_unit_activity_on_tile
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
Definition unit.c:1120
can_unit_do_autosettlers
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:602
unit_upgrade_result
unit_upgrade_result
Definition unit.h:60
UU_NO_MONEY
@ UU_NO_MONEY
Definition unit.h:63
UU_NOT_IN_CITY
@ UU_NOT_IN_CITY
Definition unit.h:64
UU_NO_UNITTYPE
@ UU_NO_UNITTYPE
Definition unit.h:62
UU_NOT_TERRAIN
@ UU_NOT_TERRAIN
Definition unit.h:67
UU_UNSUITABLE_TRANSPORT
@ UU_UNSUITABLE_TRANSPORT
Definition unit.h:68
UU_NOT_CITY_OWNER
@ UU_NOT_CITY_OWNER
Definition unit.h:65
UU_NOT_ENOUGH_ROOM
@ UU_NOT_ENOUGH_ROOM
Definition unit.h:66
UU_OK
@ UU_OK
Definition unit.h:61
UU_NOT_ACTIVITY
@ UU_NOT_ACTIVITY
Definition unit.h:69
unit_can_help_build_wonder_here
bool unit_can_help_build_wonder_here(const struct unit *punit)
Definition unit.c:261
is_field_unit
bool is_field_unit(const struct unit *punit)
Definition unit.c:416
unit_can_do_action
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:361
unit_can_do_action_result
bool unit_can_do_action_result(const struct unit *punit, enum action_result result)
Definition unit.c:371
is_martial_law_unit
bool is_martial_law_unit(const struct unit *punit)
Definition unit.c:318
set_unit_activity_targeted
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
Definition unit.c:1102
unit_virtual_create
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1620
can_unit_teleport
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:803
unit_order_list_is_sane
bool unit_order_list_is_sane(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2645
get_activity_text
const char * get_activity_text(enum unit_activity activity)
Definition unit.c:610
get_unit_tile_pillage_set
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1135
get_transporter_capacity
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:299
can_unit_unload
bool can_unit_unload(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:748
is_enter_borders_unit
bool is_enter_borders_unit(const struct unit *punit)
Definition unit.c:334
is_clean_activity
bool is_clean_activity(enum unit_activity activity)
Definition unit.c:1571
unit_transport_depth
int unit_transport_depth(const struct unit *ptrans)
Definition unit.c:2547
can_unit_paradrop
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:819
unit_activity_astr
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1152
can_unit_do_activity
bool can_unit_do_activity(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity)
Definition unit.c:865
tile_other_players_unit
struct unit * tile_other_players_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1320
is_special_unit
bool is_special_unit(const struct unit *punit)
Definition unit.c:352
unit_virtual_destroy
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1725
tile_enemy_unit
struct unit * tile_enemy_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1288
unit_tile_set
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1252
unit_upgrade_test
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1984
can_unit_load
bool can_unit_load(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:721
unit_transported
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2421
are_unit_orders_equal
bool are_unit_orders_equal(const struct unit_order *order1, const struct unit_order *order2)
Definition unit.c:59
unit_is_virtual
bool unit_is_virtual(const struct unit *punit)
Definition unit.c:2266
is_square_threatened
bool is_square_threatened(const struct civ_map *nmap, const struct player *pplayer, const struct tile *ptile, bool omniscient)
Definition unit.c:390
is_guard_unit
bool is_guard_unit(const struct unit *punit)
Definition unit.c:342
unit_occupies_tile
struct unit * unit_occupies_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1357
unit_transport_cargo
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2447
unit_ai_data
void * unit_ai_data(const struct unit *punit, const struct ai_type *ai)
Definition unit.c:2278
unit_has_orders
bool unit_has_orders(const struct unit *punit)
Definition unit.c:205
tile_allied_unit
struct unit * tile_allied_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1265
transporter_for_unit
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1908
is_non_allied_unit_tile
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:425
unit_airlift_result
unit_airlift_result
Definition unit.h:72
AR_SRC_NO_FLIGHTS
@ AR_SRC_NO_FLIGHTS
Definition unit.h:84
AR_OK_SRC_UNKNOWN
@ AR_OK_SRC_UNKNOWN
Definition unit.h:75
AR_OK_DST_UNKNOWN
@ AR_OK_DST_UNKNOWN
Definition unit.h:76
AR_NO_MOVES
@ AR_NO_MOVES
Definition unit.h:78
AR_BAD_DST_CITY
@ AR_BAD_DST_CITY
Definition unit.h:83
AR_NOT_IN_CITY
@ AR_NOT_IN_CITY
Definition unit.h:81
AR_OCCUPIED
@ AR_OCCUPIED
Definition unit.h:80
AR_OK
@ AR_OK
Definition unit.h:74
AR_DST_NO_FLIGHTS
@ AR_DST_NO_FLIGHTS
Definition unit.h:85
AR_WRONG_UNITTYPE
@ AR_WRONG_UNITTYPE
Definition unit.h:79
AR_BAD_SRC_CITY
@ AR_BAD_SRC_CITY
Definition unit.h:82
is_my_zoc
static bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.h:471
unit_can_convert
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2031
activity_requires_target
bool activity_requires_target(enum unit_activity activity)
Definition unit.c:562
could_unit_be_in_transport
bool could_unit_be_in_transport(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:664
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)
Definition unit.c:904
unittype.h
vision.h