Freeciv-3.1
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 "terrain.h" /* enum tile_special_type */
28#include "unittype.h"
29#include "vision.h"
30#include "world_object.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. */
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
138struct unit {
139 const struct unit_type *utype; /* Cannot be NULL. */
140 struct tile *tile;
142 enum direction8 facing;
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
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). */
163
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;
171
172 enum server_side_agent ssa_controller;
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. */
202 enum action_decision action_decision_want;
204
205 bool stay; /* Unit is prohibited from moving */
206
207 union {
208 struct {
209 /* Only used at the client (the server is omniscient; ./client/). */
210
212
213 int transported_by; /* Used for unit_short_info packets where we can't
214 * be sure that the information about the
215 * transporter is known. */
216 bool occupied; /* TRUE if at least one cargo on the transporter. */
217
218 /* Equivalent to pcity->client.color. Only for cityfounder units. */
221
223
224 /* Used in a follow up question about a selected action. */
227
228 struct {
229 /* Only used in the server (./ai/ and ./server/). */
230
231 bool debug;
232
233 struct unit_adv *adv;
234 void *ais[FREECIV_AI_MOD_LAST];
236
237 /* ord_map and ord_city are the order index of this unit in tile.units
238 * and city.units_supported; they are only used for save/reload */
241
242 struct vision *vision;
246
247 /* The unit is in the process of dying. */
248 bool dying;
249
250 /* Call back to run on unit removal. */
251 void (*removal_callback)(struct unit *punit);
252
253 /* The upkeep that actually was paid. */
254 int upkeep_paid[O_LAST];
256 };
257};
258
259#ifdef FREECIV_DEBUG
260#define CHECK_UNIT(punit) \
261 (fc_assert(punit != NULL), \
262 fc_assert(unit_type_get(punit) != NULL), \
263 fc_assert(unit_owner(punit) != NULL), \
264 fc_assert(player_by_number(player_index(unit_owner(punit))) \
265 == unit_owner(punit)), \
266 fc_assert(game_unit_by_number(punit->id) != NULL))
267#else /* FREECIV_DEBUG */
268#define CHECK_UNIT(punit) /* Do nothing */
269#endif /* FREECIV_DEBUG */
270
272
273bool is_real_activity(enum unit_activity activity);
274
275extern Activity_type_id real_activities[ACTIVITY_LAST];
276
277#define activity_type_list_iterate(_act_list_, _act_) \
278{ \
279 int _act_i_; \
280 for (_act_i_ = 0; _act_list_[_act_i_] != ACTIVITY_LAST; _act_i_++) { \
281 Activity_type_id _act_ = _act_list_[_act_i_];
282
283#define activity_type_list_iterate_end \
284 } \
285}
286
287/* Iterates over the types of unit activity. */
288#define activity_type_iterate(_act_) \
289{ \
290 activity_type_list_iterate(real_activities, _act_)
291
292#define activity_type_iterate_end \
293 activity_type_list_iterate_end \
294}
295
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 civ_map *nmap,
313 const struct unit *punit);
314bool unit_can_est_trade_route_here(const struct unit *punit);
316 test_unit_can_airlift_to(const struct civ_map *nmap,
317 const struct player *restriction,
318 const struct unit *punit,
319 const struct city *pdest_city);
320bool unit_can_airlift_to(const struct civ_map *nmap,
321 const struct unit *punit, const struct city *pcity)
322 fc__attribute((nonnull (3)));
323bool unit_has_orders(const struct unit *punit);
324
325bool could_unit_be_in_transport(const struct unit *pcargo,
326 const struct unit *ptrans);
327bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans);
328bool can_unit_load(const struct unit *punit, const struct unit *ptrans);
329bool can_unit_unload(const struct unit *punit, const struct unit *ptrans);
330bool can_unit_alight_or_be_unloaded(const struct civ_map *nmap,
331 const struct unit *pcargo,
332 const struct unit *ptrans);
333bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit);
334bool can_unit_change_homecity_to(const struct civ_map *nmap,
335 const struct unit *punit,
336 const struct city *pcity);
337bool can_unit_change_homecity(const struct civ_map *nmap,
338 const struct unit *punit);
339const char *get_activity_text(enum unit_activity activity);
340bool can_unit_continue_current_activity(const struct civ_map *nmap,
341 struct unit *punit);
342bool can_unit_do_activity(const struct civ_map *nmap,
343 const struct unit *punit,
344 enum unit_activity activity);
345bool can_unit_do_activity_targeted(const struct civ_map *nmap,
346 const struct unit *punit,
347 enum unit_activity activity,
348 struct extra_type *target);
349bool can_unit_do_activity_targeted_at(const struct civ_map *nmap,
350 const struct unit *punit,
351 enum unit_activity activity,
352 struct extra_type *target,
353 const struct tile *ptile);
354void set_unit_activity(struct unit *punit, enum unit_activity new_activity);
356 enum unit_activity new_activity,
357 struct extra_type *new_target);
358int get_activity_rate(const struct unit *punit);
359int get_activity_rate_this_turn(const struct unit *punit);
360int get_turns_for_activity_at(const struct unit *punit,
361 enum unit_activity activity,
362 const struct tile *ptile,
363 struct extra_type *tgt);
364bool activity_requires_target(enum unit_activity activity);
365bool can_unit_do_autosettlers(const struct unit *punit);
366bool is_unit_activity_on_tile(enum unit_activity activity,
367 const struct tile *ptile);
368bv_extras get_unit_tile_pillage_set(const struct tile *ptile);
369bool is_attack_unit(const struct unit *punit);
370bool is_military_unit(const struct unit *punit); /* !set !dip !cara */
371bool unit_can_do_action(const struct unit *punit,
372 const action_id act_id);
373bool unit_can_do_action_result(const struct unit *punit,
374 enum action_result result);
375bool unit_can_do_action_sub_result(const struct unit *punit,
376 enum action_sub_result sub_result);
377bool is_square_threatened(const struct civ_map *nmap,
378 const struct player *pplayer,
379 const struct tile *ptile, bool omniscient);
380bool is_field_unit(const struct unit *punit);
381bool is_hiding_unit(const struct unit *punit);
382bool unit_can_add_or_build_city(const struct civ_map *nmap,
383 const struct unit *punit);
384
385bool kills_citizen_after_attack(const struct unit *punit);
386
387struct astring; /* Forward declaration. */
388void unit_activity_astr(const struct unit *punit, struct astring *astr);
389void unit_upkeep_astr(const struct unit *punit, struct astring *astr);
390
391int get_transporter_capacity(const struct unit *punit);
392
393#define unit_home(_pu_) (game_city_by_number((_pu_)->homecity))
394#define unit_owner(_pu) ((_pu)->owner)
395#define unit_tile(_pu) ((_pu)->tile)
396struct player *unit_nationality(const struct unit *punit);
397void unit_tile_set(struct unit *punit, struct tile *ptile);
398
399
400struct unit *tile_allied_unit(const struct tile *ptile,
401 const struct player *pplayer);
402
403/**********************************************************************/
406static inline bool is_allied_unit_tile(const struct tile *ptile,
407 const struct player *pplayer)
408{
409 return NULL != tile_allied_unit(ptile, pplayer);
410}
411
412struct unit *tile_enemy_unit(const struct tile *ptile,
413 const struct player *pplayer);
414
415/**********************************************************************/
418static inline bool is_enemy_unit_tile(const struct tile *ptile,
419 const struct player *pplayer)
420{
421 return NULL != tile_enemy_unit(ptile, pplayer);
422}
423
424struct unit *tile_non_allied_unit(const struct tile *ptile,
425 const struct player *pplayer);
426
427/**********************************************************************/
430static inline bool is_non_allied_unit_tile(const struct tile *ptile,
431 const struct player *pplayer)
432{
433 return NULL != tile_non_allied_unit(ptile, pplayer);
434}
435
436struct unit *tile_other_players_unit(const struct tile *ptile,
437 const struct player *pplayer);
438
439/**********************************************************************/
442static inline bool is_other_players_unit_tile(const struct tile *ptile,
443 const struct player *pplayer)
444{
445 return NULL != tile_other_players_unit(ptile, pplayer);
446}
447
448struct unit *tile_non_attack_unit(const struct tile *ptile,
449 const struct player *pplayer);
450
451/**********************************************************************/
455static inline bool is_non_attack_unit_tile(const struct tile *ptile,
456 const struct player *pplayer)
457{
458 return NULL != tile_non_attack_unit(ptile, pplayer);
459}
460
461struct unit *unit_occupies_tile(const struct tile *ptile,
462 const struct player *pplayer);
463
464bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile,
465 const struct civ_map *zmap);
466bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile,
467 const struct civ_map *zmap);
468
469/**********************************************************************/
476static inline bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile,
477 const struct civ_map *zmap)
478{
479 return is_server()
480 ? is_plr_zoc_srv(unit_owner, ptile, zmap) : is_plr_zoc_client(unit_owner, ptile, zmap);
481}
482
483bool unit_being_aggressive(const struct civ_map *nmap,
484 const struct unit *punit);
485bool unit_type_really_ignores_zoc(const struct unit_type *punittype);
486
487bool is_build_activity(enum unit_activity activity);
488bool is_clean_activity(enum unit_activity activity);
489bool is_terrain_change_activity(enum unit_activity activity);
490bool is_tile_activity(enum unit_activity activity);
491
492struct unit *unit_virtual_create(struct player *pplayer, struct city *pcity,
493 const struct unit_type *punittype,
494 int veteran_level);
495void unit_virtual_destroy(struct unit *punit);
496bool unit_is_virtual(const struct unit *punit);
497void free_unit_orders(struct unit *punit);
498
499int get_transporter_occupancy(const struct unit *ptrans);
500struct unit *transporter_for_unit(const struct unit *pcargo);
501struct unit *transporter_for_unit_at(const struct unit *pcargo,
502 const struct tile *ptile);
503
505unit_transform_result(const struct civ_map *nmap,
506 const struct unit *punit,
507 const struct unit_type *to_unittype);
508enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap,
509 const struct unit *punit,
510 bool is_free);
511enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap,
512 const struct unit *punit,
513 char *buf, size_t bufsz);
514bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit);
515
516int unit_pays_mp_for_action(const struct action *paction,
517 const struct unit *punit);
518
519int hp_gain_coord(const struct unit *punit);
520int unit_gain_hitpoints(const struct unit *punit);
521bool is_losing_hp(const struct unit *punit);
522bool unit_type_is_losing_hp(const struct player *pplayer,
523 const struct unit_type *punittype);
524
525bool unit_is_alive(int id);
526
527void *unit_ai_data(const struct unit *punit, const struct ai_type *ai);
528void unit_set_ai_data(struct unit *punit, const struct ai_type *ai,
529 void *data);
530
531int unit_bribe_cost(struct unit *punit, struct player *briber);
532
533bool unit_transport_load(struct unit *pcargo, struct unit *ptrans,
534 bool force);
535bool unit_transport_unload(struct unit *pcargo);
536struct unit *unit_transport_get(const struct unit *pcargo);
537
538#define unit_transported_server(_pcargo_) ((_pcargo_)->transporter != NULL)
539
540/* Evaluates parameter twice! */
541#define unit_transported_client(_pcargo_) \
542 ((_pcargo_)->client.transported_by != -1 \
543 || (_pcargo_)->transporter != NULL)
544
545bool unit_transported(const struct unit *pcargo);
546struct unit_list *unit_transport_cargo(const struct unit *ptrans);
547bool unit_transport_check(const struct unit *pcargo,
548 const struct unit *ptrans);
549bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans);
550int unit_cargo_depth(const struct unit *pcargo);
551int unit_transport_depth(const struct unit *ptrans);
552
553bool unit_is_cityfounder(const struct unit *punit);
554
555/* Iterate all transporters carrying '_pcargo', directly or indirectly. */
556#define unit_transports_iterate(_pcargo, _ptrans) { \
557 struct unit *_ptrans; \
558 for (_ptrans = unit_transport_get(_pcargo); NULL != _ptrans; \
559 _ptrans = unit_transport_get(_ptrans)) {
560#define unit_transports_iterate_end }}
561
562struct cargo_iter;
563size_t cargo_iter_sizeof(void) fc__attribute((const));
564
565struct iterator *cargo_iter_init(struct cargo_iter *iter,
566 const struct unit *ptrans);
567#define unit_cargo_iterate(_ptrans, _pcargo) \
568 generic_iterate(struct cargo_iter, struct unit *, _pcargo, \
569 cargo_iter_sizeof, cargo_iter_init, _ptrans)
570#define unit_cargo_iterate_end generic_iterate_end
571
572bool unit_order_list_is_sane(const struct civ_map *nmap,
573 int length, const struct unit_order *orders);
574struct unit_order *create_unit_orders(const struct civ_map *nmap,
575 int length,
576 const struct unit_order *orders);
577
578#ifdef __cplusplus
579}
580#endif /* __cplusplus */
581
582#endif /* FC__UNIT_H */
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:73
static bool is_server(void)
enum unit_activity Activity_type_id
Definition fc_types.h:349
adv_unit_task
Definition fc_types.h:340
int action_id
Definition fc_types.h:359
@ O_LAST
Definition fc_types.h:91
static const int bufsz
Definition helpdlg.c:70
Definition ai.h:50
Definition city.h:309
Definition tile.h:49
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:243
int upkeep[O_LAST]
Definition unit.h:148
bool has_orders
Definition unit.h:193
bool occupied
Definition unit.h:216
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
int id
Definition unit.h:145
struct unit_list * transporting
Definition unit.h:184
int ord_city
Definition unit.h:240
bool moved
Definition unit.h:173
int ord_map
Definition unit.h:239
bool debug
Definition unit.h:231
int index
Definition unit.h:195
struct vision * vision
Definition unit.h:242
bool vigilant
Definition unit.h:197
int hp
Definition unit.h:151
struct unit::@80::@82 client
struct unit::@79 orders
int fuel
Definition unit.h:153
struct extra_type * changed_from_target
Definition unit.h:170
bool stay
Definition unit.h:205
bool colored
Definition unit.h:219
enum direction8 facing
Definition unit.h:142
bool asking_city_name
Definition unit.h:222
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:225
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:233
struct player * nationality
Definition unit.h:144
int transported_by
Definition unit.h:213
bool repeat
Definition unit.h:196
int color_index
Definition unit.h:220
struct unit_move_data * moving
Definition unit.h:245
int action_turn
Definition unit.h:244
struct unit::@80::@83 server
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:235
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:248
enum unit_focus_status focus_status
Definition unit.h:211
enum server_side_agent ssa_controller
Definition unit.h:172
#define fc__attribute(x)
Definition support.h:89
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:348
static bool is_other_players_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:442
Activity_type_id real_activities[ACTIVITY_LAST]
Definition unit.c:44
bool is_real_activity(enum unit_activity activity)
Definition unit.c:609
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:924
bool is_tile_activity(enum unit_activity activity)
Definition unit.c:1606
struct unit_order * create_unit_orders(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2825
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:1940
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1510
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
Definition unit.c:2224
bool is_terrain_change_activity(enum unit_activity activity)
Definition unit.c:1591
struct unit * tile_non_allied_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1332
int unit_shield_value(const struct unit *punit, const struct unit_type *punittype, const struct action *paction)
Definition unit.c:216
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1767
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:444
void free_unit_orders(struct unit *punit)
Definition unit.c:1753
void unit_set_ai_data(struct unit *punit, const struct ai_type *ai, void *data)
Definition unit.c:2274
bool unit_is_alive(int id)
Definition unit.c:2237
bool unit_can_est_trade_route_here(const struct unit *punit)
Definition unit.c:286
bool is_hiding_unit(const struct unit *punit)
Definition unit.c:395
int get_activity_rate_this_turn(const struct unit *punit)
Definition unit.c:505
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2119
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:521
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:418
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:2354
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1906
struct iterator * cargo_iter_init(struct cargo_iter *iter, const struct unit *ptrans)
Definition unit.c:2606
int unit_cargo_depth(const struct unit *pcargo)
Definition unit.c:2517
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:455
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2035
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:1107
bool is_losing_hp(const struct unit *punit)
Definition unit.c:2212
bool unit_can_add_or_build_city(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:427
struct unit * tile_non_attack_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1365
int hp_gain_coord(const struct unit *punit)
Definition unit.c:2146
bool can_unit_change_homecity(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:460
bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.c:1472
struct player * unit_nationality(const struct unit *punit)
Definition unit.c:1271
bool unit_being_aggressive(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:1524
int get_activity_rate(const struct unit *punit)
Definition unit.c:474
bool unit_transport_check(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2463
bool is_attack_unit(const struct unit *punit)
Definition unit.c:307
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:406
const Activity_type_id tile_changing_activities[]
Definition unit.c:46
void setup_real_activities_array(void)
Definition unit.c:591
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2425
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2374
bool is_build_activity(enum unit_activity activity)
Definition unit.c:1560
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2504
#define unit_owner(_pu)
Definition unit.h:394
int unit_gain_hitpoints(const struct unit *punit)
Definition unit.c:2167
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:83
bool is_military_unit(const struct unit *punit)
Definition unit.c:319
bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.c:1413
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
Definition unit.c:845
int unit_bribe_cost(struct unit *punit, struct player *briber)
Definition unit.c:2288
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1257
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:719
bool unit_is_cityfounder(const struct unit *punit)
Definition unit.c:2623
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
Definition unit.c:1142
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:583
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:383
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:328
bool unit_can_do_action_result(const struct unit *punit, enum action_result result)
Definition unit.c:338
void set_unit_activity_targeted(struct unit *punit, enum unit_activity new_activity, struct extra_type *new_target)
Definition unit.c:1124
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1617
bool unit_order_list_is_sane(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2632
const char * get_activity_text(enum unit_activity activity)
Definition unit.c:625
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1157
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:299
bool can_unit_unload(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:771
bool is_clean_activity(enum unit_activity activity)
Definition unit.c:1576
int unit_transport_depth(const struct unit *ptrans)
Definition unit.c:2535
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:826
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1174
bool unit_can_help_build_wonder_here(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:260
bool can_unit_do_activity(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity)
Definition unit.c:872
struct unit * tile_other_players_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1349
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1713
struct unit * tile_enemy_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1317
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1281
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1972
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:188
bool kills_citizen_after_attack(const struct unit *punit)
Definition unit.c:417
bool can_unit_load(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:744
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2409
bool are_unit_orders_equal(const struct unit_order *order1, const struct unit_order *order2)
Definition unit.c:61
bool unit_is_virtual(const struct unit *punit)
Definition unit.c:2254
bool is_square_threatened(const struct civ_map *nmap, const struct player *pplayer, const struct tile *ptile, bool omniscient)
Definition unit.c:357
struct unit * unit_occupies_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1386
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2435
void * unit_ai_data(const struct unit *punit, const struct ai_type *ai)
Definition unit.c:2266
bool unit_has_orders(const struct unit *punit)
Definition unit.c:204
struct unit * tile_allied_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1294
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1896
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:430
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:476
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2019
bool activity_requires_target(enum unit_activity activity)
Definition unit.c:541
bool could_unit_be_in_transport(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:687
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:911
bool can_unit_alight_or_be_unloaded(const struct civ_map *nmap, const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:796