Freeciv-3.3: /fast/freeciv/nightly/main/common/unit.h Source File

Freeciv-3.3

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 "actions.h"
25#include "base.h"
26#include "fc_interface.h"
27#include "fc_types.h"
28#include "map_types.h"
29#include "terrain.h" /* enum tile_special_type */
30#include "unittype.h"
31#include "vision.h"
32
33struct road_type;
34struct unit_move_data; /* Actually defined in "server/unittools.c". */
35
36/* Changing this enum will break network compatibility.
37 * Different orders take different parameters; see struct unit_order. */
38 enum unit_orders {
39 /* Move without performing any action (dir) */
40 ORDER_MOVE = 0,
41 /* Perform activity (activity, extra) */
42 ORDER_ACTIVITY = 1,
43 /* Pause to regain movement points (no parameters) */
44 ORDER_FULL_MP = 2,
45 /* Move; if necessary prompt for action/target when order executed (dir) */
46 ORDER_ACTION_MOVE = 3,
47 /* Perform pre-specified action (action, target tile, sub target) */
48 ORDER_PERFORM_ACTION = 4,
49 /* and plenty more for later... */
50 ORDER_LAST
51};
52
53 enum unit_focus_status {
54 FOCUS_AVAIL, FOCUS_WAIT, FOCUS_DONE
55};
56
57 enum goto_route_type {
58 ROUTE_GOTO, ROUTE_PATROL
59};
60
61 enum unit_upgrade_result {
62 UU_OK,
63 UU_NO_UNITTYPE,
64 UU_NO_MONEY,
65 UU_NOT_IN_CITY,
66 UU_NOT_CITY_OWNER,
67 UU_NOT_ENOUGH_ROOM,
68 UU_NOT_TERRAIN, /* The upgraded unit could not survive. */
69 UU_UNSUITABLE_TRANSPORT, /* Can't upgrade inside current transport. */
70 UU_NOT_ACTIVITY /* Can't upgrade during this activity (e.g., CONVERT) */
71};
72
73 enum unit_airlift_result {
74 /* Codes treated as success: */
75 AR_OK, /* This will definitely work */
76 AR_OK_SRC_UNKNOWN, /* Source city's airlift capability is unknown */
77 AR_OK_DST_UNKNOWN, /* Dest city's airlift capability is unknown */
78 /* Codes treated as failure: */
79 AR_NO_MOVES, /* Unit has no moves left */
80 AR_WRONG_UNITTYPE, /* Can't airlift this type of unit */
81 AR_OCCUPIED, /* Can't airlift units with passengers */
82 AR_NOT_IN_CITY, /* Unit not in a city */
83 AR_BAD_SRC_CITY, /* Can't airlift from this src city */
84 AR_BAD_DST_CITY, /* Can't airlift to this dst city */
85 AR_SRC_NO_FLIGHTS, /* No flights available from src */
86 AR_DST_NO_FLIGHTS /* No flights available to dst */
87};
88
89 struct unit_adv {
90 enum adv_unit_task task;
91};
92
93 struct unit_order {
94 enum unit_orders order;
95 enum unit_activity activity; /* Only valid for ORDER_ACTIVITY. */
96 /* Only valid for ORDER_PERFORM_ACTION. Validity and meaning depend on
97 * 'action'. See action_target_kind and action_sub_target_kind */
98 int target;
99 int sub_target;
100 /* Only valid for ORDER_PERFORM_ACTION and ORDER_ACTIVITY
101 * TODO: Drop ORDER_ACTIVITY, always have activities as result of actions. */
102 int action;
103 /* Valid for ORDER_MOVE and ORDER_ACTION_MOVE. */
104 enum direction8 dir;
105};
106
107/* Used in the network protocol */
108#define SPECENUM_NAME unit_ss_data_type
109/* The player wants to be reminded to ask what actions the unit can perform
110 * to a certain target tile. */
111#define SPECENUM_VALUE0 USSDT_QUEUE
112/* The player no longer wants the reminder to ask what actions the unit can
113 * perform to a certain target tile. */
114#define SPECENUM_VALUE1 USSDT_UNQUEUE
115/* The player wants to record that the unit now belongs to the specified
116 * battle group. */
117#define SPECENUM_VALUE2 USSDT_BATTLE_GROUP
118/* The player wants the unit to stop bothering them unless:
119 * - a hostile units comes within 3 tiles
120 * - the unit has its hitpoints restored
121 * - the unit is bounced
122 * if 1, 0 to still be bothered. */
123#define SPECENUM_VALUE3 USSDT_SENTRY
124#include "specenum_gen.h"
125
126/* Used in the network protocol */
127#define SPECENUM_NAME server_side_agent
128#define SPECENUM_VALUE0 SSA_NONE
129#define SPECENUM_VALUE0NAME N_("?serveragent:None")
130#define SPECENUM_VALUE1 SSA_AUTOWORKER
131#define SPECENUM_VALUE1NAME N_("AutoWorker")
132#define SPECENUM_VALUE2 SSA_AUTOEXPLORE
133#define SPECENUM_VALUE2NAME N_("Autoexplore")
134#define SPECENUM_COUNT SSA_COUNT
135#include "specenum_gen.h"
136
137struct unit;
138struct unit_list;
139
140 struct unit {
141 const struct unit_type *utype; /* Cannot be NULL. */
142 struct tile *tile;
143 int refcount;
144 enum direction8 facing;
145 struct player *owner; /* Cannot be NULL. */
146 struct player *nationality;
147 int id;
148 int homecity;
149
150 int upkeep[O_LAST]; /* unit upkeep with regards to the homecity */
151
152 int moves_left;
153 int hp;
154 int veteran;
155 int fuel;
156
157 struct tile *goto_tile; /* May be NULL. */
158
159 enum unit_activity activity;
160 enum gen_action action;
161
162 /* The amount of work that has been done on the current activity. This
163 * is counted in turns but is multiplied by ACTIVITY_FACTOR (which allows
164 * fractional values in some cases). */
165 int activity_count;
166
167 struct extra_type *activity_target;
168
169 /* Previous activity, so it can be resumed without loss of progress
170 * if the user changes their mind during a turn. */
171 enum unit_activity changed_from;
172 int changed_from_count;
173 struct extra_type *changed_from_target;
174
175 enum server_side_agent ssa_controller;
176 bool moved;
177 bool paradropped;
178
179 /* This value is set if the unit is done moving for this turn. This
180 * information is used by the client. The invariant is:
181 * - If the unit has no more moves, it's done moving.
182 * - If the unit is on a goto but is waiting, it's done moving.
183 * - Otherwise the unit is not done moving. */
184 bool done_moving;
185
186 struct unit *transporter; /* This unit is transported by ... */
187 struct unit_list *transporting; /* This unit transports ... */
188
189 struct goods_type *carrying;
190
191 /* The battlegroup ID: defined by the client but stored by the server. */
192#define MAX_NUM_BATTLEGROUPS (4)
193#define BATTLEGROUP_NONE (-1)
194 int battlegroup;
195
196 bool has_orders;
197 struct {
198 int length, index;
199 bool repeat; /* The path is to be repeated on completion. */
200 bool vigilant; /* Orders should be cleared if an enemy is met. */
201 struct unit_order *list;
202 } orders;
203
204 /* The unit may want the player to choose an action. */
205 enum action_decision action_decision_want;
206 struct tile *action_decision_tile;
207
208 bool stay; /* Unit is prohibited from moving */
209
210 int birth_turn;
211 int current_form_turn;
212
213 union {
214 struct {
215 /* Only used at the client (the server is omniscient; ./client/). */
216
217 enum unit_focus_status focus_status;
218
219 int transported_by; /* Used for unit_short_info packets where we can't
220 * be sure that the information about the
221 * transporter is known. */
222 bool occupied; /* TRUE if at least one cargo on the transporter. */
223
224 /* Equivalent to pcity->client.color. Only for cityfounder units. */
225 bool colored;
226 int color_index;
227
228 bool asking_city_name;
229
230 /* Used in a follow up question about a selected action. */
231 struct act_prob *act_prob_cache;
232 } client;
233
234 struct {
235 /* Only used in the server (./ai/ and ./server/). */
236
237 bool debug;
238
239 struct unit_adv *adv;
240 void *ais[FREECIV_AI_MOD_LAST];
241
242 /* ord_map and ord_city are the order index of this unit in tile.units
243 * and city.units_supported; they are only used for save/reload */
244 int ord_map;
245 int ord_city;
246
247 struct vision *vision;
248 time_t action_timestamp;
249 int action_turn;
250 struct unit_move_data *moving;
251
252 /* The unit is in the process of dying. */
253 bool dying;
254
255 /* Call back to run on unit removal. */
256 void (*removal_callback)(struct unit *punit);
257
258 /* The upkeep that actually was paid. */
259 int upkeep_paid[O_LAST];
260 } server;
261 };
262};
263
264#ifdef FREECIV_DEBUG
265#define CHECK_UNIT(punit) \
266 (fc_assert(punit != NULL), \
267 fc_assert(unit_type_get(punit) != NULL), \
268 fc_assert(unit_owner(punit) != NULL), \
269 fc_assert(player_by_number(player_index(unit_owner(punit))) \
270 == unit_owner(punit)), \
271 fc_assert(game_unit_by_number(punit->id) != NULL))
272#else /* FREECIV_DEBUG */
273#define CHECK_UNIT(punit) /* Do nothing */
274#endif /* FREECIV_DEBUG */
275
276#define activity_type_list_iterate(_act_list_, _act_) \
277{ \
278 int _act_i_; \
279 for (_act_i_ = 0; _act_list_[_act_i_] != ACTIVITY_LAST; _act_i_++) { \
280 Activity_type_id _act_ = _act_list_[_act_i_];
281
282#define activity_type_list_iterate_end \
283 } \
284}
285
286/* Iterates over the types of unit activity. */
287#define activity_type_iterate(_act_) \
288{ \
289 Activity_type_id _act_; \
290 for (_act_ = 0; _act_ != ACTIVITY_LAST; _act_++) { \
291
292#define activity_type_iterate_end \
293 } \
294}
295
296extern const Activity_type_id tile_changing_activities[];
297
298#define tile_changing_activities_iterate(_act_) \
299{ \
300 activity_type_list_iterate(tile_changing_activities, _act_)
301
302#define tile_changing_activities_iterate_end \
303 activity_type_list_iterate_end \
304}
305
306bool are_unit_orders_equal(const struct unit_order *order1,
307 const struct unit_order *order2);
308
309int unit_shield_value(const struct unit *punit,
310 const struct unit_type *punittype,
311 const struct action *paction);
312bool unit_can_help_build_wonder_here(const struct unit *punit);
313bool unit_can_est_trade_route_here(const struct unit *punit);
314enum unit_airlift_result
315 test_unit_can_airlift_to(const struct civ_map *nmap,
316 const struct player *restriction,
317 const struct unit *punit,
318 const struct city *pdest_city);
319bool unit_can_airlift_to(const struct unit *punit, const struct city *pcity);
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);
327bool can_unit_deboard_or_be_unloaded(const struct unit *pcargo,
328 const struct unit *ptrans);
329bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit);
330bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit);
331bool can_unit_change_homecity_to(const struct unit *punit,
332 const struct city *pcity);
333bool can_unit_change_homecity(const struct unit *punit);
334const char *get_activity_text(enum unit_activity activity);
335bool can_unit_continue_current_activity(const struct civ_map *nmap,
336 struct unit *punit);
337bool can_unit_do_activity(const struct civ_map *nmap,
338 const struct unit *punit,
339 enum unit_activity activity);
340bool can_unit_do_activity_targeted(const struct civ_map *nmap,
341 const struct unit *punit,
342 enum unit_activity activity,
343 struct extra_type *target);
344bool can_unit_do_activity_targeted_at(const struct civ_map *nmap,
345 const struct unit *punit,
346 enum unit_activity activity,
347 struct extra_type *target,
348 const struct tile *ptile);
349void set_unit_activity(struct unit *punit, enum unit_activity new_activity,
350 enum gen_action trigger_action);
351void set_unit_activity_targeted(struct unit *punit,
352 enum unit_activity new_activity,
353 struct extra_type *new_target,
354 enum gen_action trigger_action);
355int get_activity_rate(const struct unit *punit);
356int get_activity_rate_this_turn(const struct unit *punit);
357int get_turns_for_activity_at(const struct unit *punit,
358 enum unit_activity activity,
359 const struct tile *ptile,
360 struct extra_type *tgt);
361bool activity_requires_target(enum unit_activity activity);
362bool can_unit_do_autoworker(const struct unit *punit);
363bool is_unit_activity_on_tile(enum unit_activity activity,
364 const struct tile *ptile);
365 bv_extras get_unit_tile_pillage_set(const struct tile *ptile);
366bool is_attack_unit(const struct unit *punit);
367bool is_martial_law_unit(const struct unit *punit);
368bool is_occupying_unit(const struct unit *punit);
369bool is_enter_borders_unit(const struct unit *punit);
370bool is_guard_unit(const struct unit *punit);
371bool is_special_unit(const struct unit *punit);
372bool is_flagless_to_player(const struct unit *punit,
373 const struct player *pplayer);
374bool unit_can_do_action(const struct unit *punit,
375 const action_id act_id);
376bool unit_can_do_action_result(const struct unit *punit,
377 enum action_result result);
378bool unit_can_do_action_sub_result(const struct unit *punit,
379 enum action_sub_result sub_result);
380bool is_square_threatened(const struct civ_map *nmap,
381 const struct player *pplayer,
382 const struct tile *ptile, bool omniscient);
383bool is_field_unit(const struct unit *punit);
384bool is_hiding_unit(const struct unit *punit);
385bool unit_can_add_or_build_city(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/**********************************************************************/
408 static 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/**********************************************************************/
420 static 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 bool everyone_non_allied);
429
430/**********************************************************************/
433 static inline bool is_non_allied_unit_tile(const struct tile *ptile,
434 const struct player *pplayer,
435 bool everyone_non_allied)
436{
437 return NULL != tile_non_allied_unit(ptile, pplayer, everyone_non_allied);
438}
439
440struct unit *tile_other_players_unit(const struct tile *ptile,
441 const struct player *pplayer);
442
443/**********************************************************************/
446 static inline bool is_other_players_unit_tile(const struct tile *ptile,
447 const struct player *pplayer)
448{
449 return NULL != tile_other_players_unit(ptile, pplayer);
450}
451
452struct unit *tile_non_attack_unit(const struct tile *ptile,
453 const struct player *pplayer);
454
455/**********************************************************************/
459 static inline bool is_non_attack_unit_tile(const struct tile *ptile,
460 const struct player *pplayer)
461{
462 return NULL != tile_non_attack_unit(ptile, pplayer);
463}
464
465struct unit *unit_occupies_tile(const struct tile *ptile,
466 const struct player *pplayer);
467
468bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile,
469 const struct civ_map *zmap);
470bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile,
471 const struct civ_map *zmap);
472
473/**********************************************************************/
480 static inline bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile,
481 const struct civ_map *zmap)
482{
483 return is_server()
484 ? is_plr_zoc_srv(unit_owner, ptile, zmap) : is_plr_zoc_client(unit_owner, ptile, zmap);
485}
486
487bool unit_being_aggressive(const struct unit *punit);
488bool unit_type_really_ignores_zoc(const struct unit_type *punittype);
489
490bool is_build_activity(enum unit_activity activity);
491bool is_clean_activity(enum unit_activity activity);
492bool is_terrain_change_activity(enum unit_activity activity);
493bool is_tile_activity(enum unit_activity activity);
494bool is_targeted_activity(enum unit_activity activity);
495
496struct unit *unit_virtual_create(struct player *pplayer, struct city *pcity,
497 const struct unit_type *punittype,
498 int veteran_level);
499void unit_virtual_destroy(struct unit *punit);
500bool unit_is_virtual(const struct unit *punit);
501void free_unit_orders(struct unit *punit);
502
503int get_transporter_occupancy(const struct unit *ptrans);
504struct unit *transporter_for_unit(const struct unit *pcargo);
505struct unit *transporter_for_unit_at(const struct unit *pcargo,
506 const struct tile *ptile);
507
508enum unit_upgrade_result
509 unit_transform_result(const struct civ_map *nmap,
510 const struct unit *punit,
511 const struct unit_type *to_unittype);
512enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap,
513 const struct unit *punit,
514 bool is_free);
515enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap,
516 const struct unit *punit,
517 char *buf, size_t bufsz);
518bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit);
519
520int unit_pays_mp_for_action(const struct action *paction,
521 const struct unit *punit);
522
523int hp_gain_coord(const struct unit *punit);
524int unit_gain_hitpoints(const struct unit *punit);
525bool is_losing_hp(const struct unit *punit);
526bool unit_type_is_losing_hp(const struct player *pplayer,
527 const struct unit_type *punittype);
528
529bool unit_is_alive(int id);
530
531void *unit_ai_data(const struct unit *punit, const struct ai_type *ai);
532void unit_set_ai_data(struct unit *punit, const struct ai_type *ai,
533 void *data);
534
535int unit_bribe_cost(const struct unit *punit, const struct player *briber,
536 const struct unit *briber_unit);
537
538bool unit_transport_load(struct unit *pcargo, struct unit *ptrans,
539 bool force);
540bool unit_transport_unload(struct unit *pcargo);
541struct unit *unit_transport_get(const struct unit *pcargo);
542
543#define unit_transported_server(_pcargo_) ((_pcargo_)->transporter != NULL)
544
545/* Evaluates parameter twice! */
546#define unit_transported_client(_pcargo_) \
547 ((_pcargo_)->client.transported_by != -1 \
548 || (_pcargo_)->transporter != NULL)
549
550bool unit_transported(const struct unit *pcargo);
551struct unit_list *unit_transport_cargo(const struct unit *ptrans);
552bool unit_transport_check(const struct unit *pcargo,
553 const struct unit *ptrans);
554bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans);
555int unit_cargo_depth(const struct unit *pcargo);
556int unit_transport_depth(const struct unit *ptrans);
557
558bool unit_is_cityfounder(const struct unit *punit);
559
560/* Iterate all transporters carrying '_pcargo', directly or indirectly. */
561#define unit_transports_iterate(_pcargo, _ptrans) { \
562 struct unit *_ptrans; \
563 for (_ptrans = unit_transport_get(_pcargo); NULL != _ptrans; \
564 _ptrans = unit_transport_get(_ptrans)) {
565#define unit_transports_iterate_end }}
566
567struct cargo_iter;
568 size_t cargo_iter_sizeof(void) fc__attribute((const));
569
570struct iterator *cargo_iter_init(struct cargo_iter *iter,
571 const struct unit *ptrans);
572#define unit_cargo_iterate(_ptrans, _pcargo) \
573 generic_iterate(struct cargo_iter, struct unit *, _pcargo, \
574 cargo_iter_sizeof, cargo_iter_init, _ptrans)
575#define unit_cargo_iterate_end generic_iterate_end
576
577bool unit_order_list_is_sane(const struct civ_map *nmap,
578 int length, const struct unit_order *orders);
579struct unit_order *create_unit_orders(const struct civ_map *nmap,
580 int length,
581 const struct unit_order *orders);
582
583enum gen_action activity_default_action(enum unit_activity act);
584
585#ifdef __cplusplus
586}
587#endif /* __cplusplus */
588
589#endif /* FC__UNIT_H */
actions.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:383
adv_unit_task
adv_unit_task
Definition fc_types.h:374
action_id
int action_id
Definition fc_types.h:393
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:1220
action
Definition actions.h:106
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:187
iterator
Definition iterator.h:31
player
Definition player.h:249
road_type
Definition road.h:71
tile
Definition tile.h:50
unit_adv
Definition unit.h:89
unit_adv::task
enum adv_unit_task task
Definition unit.h:90
unit_move_data
Definition unittools.c:91
unit_order
Definition unit.h:93
unit_order::activity
enum unit_activity activity
Definition unit.h:95
unit_order::order
enum unit_orders order
Definition unit.h:94
unit_order::action
int action
Definition unit.h:102
unit_order::dir
enum direction8 dir
Definition unit.h:104
unit_order::target
int target
Definition unit.h:98
unit_order::sub_target
int sub_target
Definition unit.h:99
unit_type
Definition unittype.h:507
unit
Definition unit.h:140
unit::action_timestamp
time_t action_timestamp
Definition unit.h:248
unit::upkeep
int upkeep[O_LAST]
Definition unit.h:150
unit::has_orders
bool has_orders
Definition unit.h:196
unit::orders
struct unit::@80 orders
unit::occupied
bool occupied
Definition unit.h:222
unit::action_decision_want
enum action_decision action_decision_want
Definition unit.h:205
unit::battlegroup
int battlegroup
Definition unit.h:194
unit::activity
enum unit_activity activity
Definition unit.h:159
unit::moves_left
int moves_left
Definition unit.h:152
unit::refcount
int refcount
Definition unit.h:143
unit::client
struct unit::@81::@83 client
unit::id
int id
Definition unit.h:147
unit::action
enum gen_action action
Definition unit.h:160
unit::transporting
struct unit_list * transporting
Definition unit.h:187
unit::ord_city
int ord_city
Definition unit.h:245
unit::moved
bool moved
Definition unit.h:176
unit::ord_map
int ord_map
Definition unit.h:244
unit::debug
bool debug
Definition unit.h:237
unit::index
int index
Definition unit.h:198
unit::vision
struct vision * vision
Definition unit.h:247
unit::vigilant
bool vigilant
Definition unit.h:200
unit::hp
int hp
Definition unit.h:153
unit::fuel
int fuel
Definition unit.h:155
unit::changed_from_target
struct extra_type * changed_from_target
Definition unit.h:173
unit::current_form_turn
int current_form_turn
Definition unit.h:211
unit::stay
bool stay
Definition unit.h:208
unit::colored
bool colored
Definition unit.h:225
unit::facing
enum direction8 facing
Definition unit.h:144
unit::server
struct unit::@81::@84 server
unit::asking_city_name
bool asking_city_name
Definition unit.h:228
unit::tile
struct tile * tile
Definition unit.h:142
unit::activity_target
struct extra_type * activity_target
Definition unit.h:167
unit::act_prob_cache
struct act_prob * act_prob_cache
Definition unit.h:231
unit::activity_count
int activity_count
Definition unit.h:165
unit::list
struct unit_order * list
Definition unit.h:201
unit::changed_from
enum unit_activity changed_from
Definition unit.h:171
unit::adv
struct unit_adv * adv
Definition unit.h:239
unit::nationality
struct player * nationality
Definition unit.h:146
unit::transported_by
int transported_by
Definition unit.h:219
unit::repeat
bool repeat
Definition unit.h:199
unit::color_index
int color_index
Definition unit.h:226
unit::moving
struct unit_move_data * moving
Definition unit.h:250
unit::action_turn
int action_turn
Definition unit.h:249
unit::homecity
int homecity
Definition unit.h:148
unit::paradropped
bool paradropped
Definition unit.h:177
unit::done_moving
bool done_moving
Definition unit.h:184
unit::transporter
struct unit * transporter
Definition unit.h:186
unit::birth_turn
int birth_turn
Definition unit.h:210
unit::carrying
struct goods_type * carrying
Definition unit.h:189
unit::goto_tile
struct tile * goto_tile
Definition unit.h:157
unit::action_decision_tile
struct tile * action_decision_tile
Definition unit.h:206
unit::utype
const struct unit_type * utype
Definition unit.h:141
unit::veteran
int veteran
Definition unit.h:154
unit::changed_from_count
int changed_from_count
Definition unit.h:172
unit::owner
struct player * owner
Definition unit.h:145
unit::dying
bool dying
Definition unit.h:253
unit::focus_status
enum unit_focus_status focus_status
Definition unit.h:217
unit::ssa_controller
enum server_side_agent ssa_controller
Definition unit.h:175
veteran_level
Definition unittype.h:493
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:406
is_other_players_unit_tile
static bool is_other_players_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:446
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:945
is_tile_activity
bool is_tile_activity(enum unit_activity activity)
Definition unit.c:1642
create_unit_orders
struct unit_order * create_unit_orders(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2892
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:1994
unit_being_aggressive
bool unit_being_aggressive(const struct unit *punit)
Definition unit.c:1556
unit_type_really_ignores_zoc
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1542
unit_type_is_losing_hp
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
Definition unit.c:2278
is_terrain_change_activity
bool is_terrain_change_activity(enum unit_activity activity)
Definition unit.c:1627
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:1821
goto_route_type
goto_route_type
Definition unit.h:57
ROUTE_GOTO
@ ROUTE_GOTO
Definition unit.h:58
ROUTE_PATROL
@ ROUTE_PATROL
Definition unit.h:58
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:1807
can_unit_change_homecity
bool can_unit_change_homecity(const struct unit *punit)
Definition unit.c:509
unit_set_ai_data
void unit_set_ai_data(struct unit *punit, const struct ai_type *ai, void *data)
Definition unit.c:2328
unit_is_alive
bool unit_is_alive(int id)
Definition unit.c:2291
unit_can_est_trade_route_here
bool unit_can_est_trade_route_here(const struct unit *punit)
Definition unit.c:287
is_occupying_unit
bool is_occupying_unit(const struct unit *punit)
Definition unit.c:327
is_hiding_unit
bool is_hiding_unit(const struct unit *punit)
Definition unit.c:453
get_activity_rate_this_turn
int get_activity_rate_this_turn(const struct unit *punit)
Definition unit.c:550
unit_pays_mp_for_action
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2173
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:566
is_enemy_unit_tile
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:420
unit_focus_status
unit_focus_status
Definition unit.h:53
FOCUS_AVAIL
@ FOCUS_AVAIL
Definition unit.h:54
FOCUS_DONE
@ FOCUS_DONE
Definition unit.h:54
FOCUS_WAIT
@ FOCUS_WAIT
Definition unit.h:54
unit_transport_load
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
Definition unit.c:2428
unit_can_add_or_build_city
bool unit_can_add_or_build_city(const struct unit *punit)
Definition unit.c:475
transporter_for_unit_at
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1960
cargo_iter_init
struct iterator * cargo_iter_init(struct cargo_iter *iter, const struct unit *ptrans)
Definition unit.c:2682
unit_cargo_depth
int unit_cargo_depth(const struct unit *pcargo)
Definition unit.c:2591
is_non_attack_unit_tile
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:459
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:2089
unit_orders
unit_orders
Definition unit.h:38
ORDER_ACTION_MOVE
@ ORDER_ACTION_MOVE
Definition unit.h:46
ORDER_ACTIVITY
@ ORDER_ACTIVITY
Definition unit.h:42
ORDER_FULL_MP
@ ORDER_FULL_MP
Definition unit.h:44
ORDER_MOVE
@ ORDER_MOVE
Definition unit.h:40
ORDER_LAST
@ ORDER_LAST
Definition unit.h:50
ORDER_PERFORM_ACTION
@ ORDER_PERFORM_ACTION
Definition unit.h:48
is_losing_hp
bool is_losing_hp(const struct unit *punit)
Definition unit.c:2266
is_targeted_activity
bool is_targeted_activity(enum unit_activity activity)
Definition unit.c:1652
can_unit_deboard_or_be_unloaded
bool can_unit_deboard_or_be_unloaded(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:801
can_unit_change_homecity_to
bool can_unit_change_homecity_to(const struct unit *punit, const struct city *pcity)
Definition unit.c:492
tile_non_attack_unit
struct unit * tile_non_attack_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1377
hp_gain_coord
int hp_gain_coord(const struct unit *punit)
Definition unit.c:2200
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:1494
unit_nationality
struct player * unit_nationality(const struct unit *punit)
Definition unit.c:1275
get_activity_rate
int get_activity_rate(const struct unit *punit)
Definition unit.c:522
unit_transport_check
bool unit_transport_check(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2537
is_attack_unit
bool is_attack_unit(const struct unit *punit)
Definition unit.c:308
is_allied_unit_tile
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:408
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:2499
unit_transport_unload
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2448
is_build_activity
bool is_build_activity(enum unit_activity activity)
Definition unit.c:1597
unit_contained_in
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2578
unit_owner
#define unit_owner(_pu)
Definition unit.h:396
unit_gain_hitpoints
int unit_gain_hitpoints(const struct unit *punit)
Definition unit.c:2221
unit_bribe_cost
int unit_bribe_cost(const struct unit *punit, const struct player *briber, const struct unit *briber_unit)
Definition unit.c:2345
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:1425
can_unit_continue_current_activity
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
Definition unit.c:866
unit_upkeep_astr
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1261
could_unit_load
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:724
unit_is_cityfounder
bool unit_is_cityfounder(const struct unit *punit)
Definition unit.c:2699
is_unit_activity_on_tile
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
Definition unit.c:1152
unit_upgrade_result
unit_upgrade_result
Definition unit.h:61
UU_NO_MONEY
@ UU_NO_MONEY
Definition unit.h:64
UU_NOT_IN_CITY
@ UU_NOT_IN_CITY
Definition unit.h:65
UU_NO_UNITTYPE
@ UU_NO_UNITTYPE
Definition unit.h:63
UU_NOT_TERRAIN
@ UU_NOT_TERRAIN
Definition unit.h:68
UU_UNSUITABLE_TRANSPORT
@ UU_UNSUITABLE_TRANSPORT
Definition unit.h:69
UU_NOT_CITY_OWNER
@ UU_NOT_CITY_OWNER
Definition unit.h:66
UU_NOT_ENOUGH_ROOM
@ UU_NOT_ENOUGH_ROOM
Definition unit.h:67
UU_OK
@ UU_OK
Definition unit.h:62
UU_NOT_ACTIVITY
@ UU_NOT_ACTIVITY
Definition unit.h:70
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:441
unit_can_do_action
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:386
unit_can_do_action_result
bool unit_can_do_action_result(const struct unit *punit, enum action_result result)
Definition unit.c:396
activity_default_action
enum gen_action activity_default_action(enum unit_activity act)
Definition unit.c:2911
is_martial_law_unit
bool is_martial_law_unit(const struct unit *punit)
Definition unit.c:319
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:1662
can_unit_do_autoworker
bool can_unit_do_autoworker(const struct unit *punit)
Definition unit.c:630
can_unit_teleport
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:831
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:2707
get_activity_text
const char * get_activity_text(enum unit_activity activity)
Definition unit.c:638
get_unit_tile_pillage_set
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1168
get_transporter_capacity
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:300
can_unit_unload
bool can_unit_unload(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:776
set_unit_activity_targeted
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target, enum gen_action trigger_action)
Definition unit.c:1133
is_enter_borders_unit
bool is_enter_borders_unit(const struct unit *punit)
Definition unit.c:335
is_clean_activity
bool is_clean_activity(enum unit_activity activity)
Definition unit.c:1613
unit_transport_depth
int unit_transport_depth(const struct unit *ptrans)
Definition unit.c:2609
can_unit_paradrop
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:847
unit_activity_astr
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1185
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:893
tile_other_players_unit
struct unit * tile_other_players_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1361
is_special_unit
bool is_special_unit(const struct unit *punit)
Definition unit.c:353
unit_virtual_destroy
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1767
tile_enemy_unit
struct unit * tile_enemy_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1321
unit_tile_set
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1285
set_unit_activity
void set_unit_activity(struct unit *punit, enum unit_activity new_activity, enum gen_action trigger_action)
Definition unit.c:1115
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:2026
can_unit_load
bool can_unit_load(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:749
unit_transported
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2483
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:2308
is_flagless_to_player
bool is_flagless_to_player(const struct unit *punit, const struct player *pplayer)
Definition unit.c:366
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:415
is_guard_unit
bool is_guard_unit(const struct unit *punit)
Definition unit.c:343
unit_occupies_tile
struct unit * unit_occupies_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1398
unit_transport_cargo
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2509
unit_ai_data
void * unit_ai_data(const struct unit *punit, const struct ai_type *ai)
Definition unit.c:2320
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:1298
transporter_for_unit
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1950
unit_airlift_result
unit_airlift_result
Definition unit.h:73
AR_SRC_NO_FLIGHTS
@ AR_SRC_NO_FLIGHTS
Definition unit.h:85
AR_OK_SRC_UNKNOWN
@ AR_OK_SRC_UNKNOWN
Definition unit.h:76
AR_OK_DST_UNKNOWN
@ AR_OK_DST_UNKNOWN
Definition unit.h:77
AR_NO_MOVES
@ AR_NO_MOVES
Definition unit.h:79
AR_BAD_DST_CITY
@ AR_BAD_DST_CITY
Definition unit.h:84
AR_NOT_IN_CITY
@ AR_NOT_IN_CITY
Definition unit.h:82
AR_OCCUPIED
@ AR_OCCUPIED
Definition unit.h:81
AR_OK
@ AR_OK
Definition unit.h:75
AR_DST_NO_FLIGHTS
@ AR_DST_NO_FLIGHTS
Definition unit.h:86
AR_WRONG_UNITTYPE
@ AR_WRONG_UNITTYPE
Definition unit.h:80
AR_BAD_SRC_CITY
@ AR_BAD_SRC_CITY
Definition unit.h:83
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:480
is_non_allied_unit_tile
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:433
unit_can_convert
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2073
activity_requires_target
bool activity_requires_target(enum unit_activity activity)
Definition unit.c:590
could_unit_be_in_transport
bool could_unit_be_in_transport(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:692
tile_non_allied_unit
struct unit * tile_non_allied_unit(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.c:1336
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:932
unittype.h
vision.h