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. */
39 /* Move without performing any action (dir) */
41 /* Perform activity (activity, extra) */
43 /* Pause to regain movement points (no parameters) */
45 /* Move; if necessary prompt for action/target when order executed (dir) */
47 /* Perform pre-specified action (action, target tile, sub target) */
49 /* and plenty more for later... */
51};
52
56
60
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
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
89struct unit_adv {
91};
92
93struct unit_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;
100 /* Only valid for ORDER_PERFORM_ACTION and ORDER_ACTIVITY
101 * TODO: Drop ORDER_ACTIVITY, always have activities as result of actions. */
103 /* Valid for ORDER_MOVE and ORDER_ACTION_MOVE. */
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
140struct unit {
141 const struct unit_type *utype; /* Cannot be NULL. */
142 struct tile *tile;
145 struct player *owner; /* Cannot be NULL. */
147 int id;
149
150 int upkeep[O_LAST]; /* unit upkeep with regards to the homecity */
151
153 int hp;
155 int fuel;
156
157 struct tile *goto_tile; /* May be NULL. */
158
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). */
166
168
169 /* Previous activity, so it can be resumed without loss of progress
170 * if the user changes their mind during a turn. */
174
176 bool moved;
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. */
185
186 struct unit *transporter; /* This unit is transported by ... */
187 struct unit_list *transporting; /* This unit transports ... */
188
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)
195
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. */
203
204 /* The unit may want the player to choose an action. */
207
208 bool stay; /* Unit is prohibited from moving */
209
212
213 union {
214 struct {
215 /* Only used at the client (the server is omniscient; ./client/). */
216
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. */
227
229
230 /* Used in a follow up question about a selected action. */
233
234 struct {
235 /* Only used in the server (./ai/ and ./server/). */
236
237 bool debug;
238
239 struct unit_adv *adv;
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 */
246
247 struct vision *vision;
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];
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
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);
313 const struct unit *punit);
314bool unit_can_est_trade_route_here(const struct unit *punit);
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);
331 const struct unit *pcargo,
332 const struct unit *ptrans);
333bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit);
334bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit);
335bool can_unit_change_homecity_to(const struct civ_map *nmap,
336 const struct unit *punit,
337 const struct city *pcity);
338bool can_unit_change_homecity(const struct civ_map *nmap,
339 const struct unit *punit);
342 struct unit *punit);
343bool can_unit_do_activity(const struct civ_map *nmap,
344 const struct unit *punit,
347 const struct unit *punit,
349 struct extra_type *target);
351 const struct unit *punit,
353 struct extra_type *target,
354 const struct tile *ptile);
359 struct extra_type *new_target,
361int get_activity_rate(const struct unit *punit);
362int get_activity_rate_this_turn(const struct unit *punit);
363int get_turns_for_activity_at(const struct unit *punit,
365 const struct tile *ptile,
366 struct extra_type *tgt);
368bool can_unit_do_autoworker(const struct unit *punit);
370 const struct tile *ptile);
371bv_extras get_unit_tile_pillage_set(const struct tile *ptile);
372bool is_attack_unit(const struct unit *punit);
373bool is_martial_law_unit(const struct unit *punit);
374bool is_occupying_unit(const struct unit *punit);
375bool is_enter_borders_unit(const struct unit *punit);
376bool is_guard_unit(const struct unit *punit);
377bool is_special_unit(const struct unit *punit);
378bool is_flagless_to_player(const struct unit *punit,
379 const struct player *pplayer);
380bool unit_can_do_action(const struct unit *punit,
381 const action_id act_id);
382bool unit_can_do_action_result(const struct unit *punit,
383 enum action_result result);
384bool unit_can_do_action_sub_result(const struct unit *punit,
386bool is_square_threatened(const struct civ_map *nmap,
387 const struct player *pplayer,
388 const struct tile *ptile, bool omniscient);
389bool is_field_unit(const struct unit *punit);
390bool is_hiding_unit(const struct unit *punit);
391bool unit_can_add_or_build_city(const struct civ_map *nmap,
392 const struct unit *punit);
393
394struct astring; /* Forward declaration. */
395
396void unit_activity_astr(const struct unit *punit, struct astring *astr);
397void unit_upkeep_astr(const struct unit *punit, struct astring *astr);
398
399int get_transporter_capacity(const struct unit *punit);
400
401#define unit_home(_pu_) (game_city_by_number((_pu_)->homecity))
402#define is_unit_homeless(_pu_) (punit->homecity == IDENTITY_NUMBER_ZERO)
403#define unit_owner(_pu) ((_pu)->owner)
404#define unit_tile(_pu) ((_pu)->tile)
405struct player *unit_nationality(const struct unit *punit);
406void unit_tile_set(struct unit *punit, struct tile *ptile);
407
408
409struct unit *tile_allied_unit(const struct tile *ptile,
410 const struct player *pplayer);
411
412/**********************************************************************/
415static inline bool is_allied_unit_tile(const struct tile *ptile,
416 const struct player *pplayer)
417{
418 return NULL != tile_allied_unit(ptile, pplayer);
419}
420
421struct unit *tile_enemy_unit(const struct tile *ptile,
422 const struct player *pplayer);
423
424/**********************************************************************/
427static inline bool is_enemy_unit_tile(const struct tile *ptile,
428 const struct player *pplayer)
429{
430 return NULL != tile_enemy_unit(ptile, pplayer);
431}
432
433struct unit *tile_non_allied_unit(const struct tile *ptile,
434 const struct player *pplayer,
436
437/**********************************************************************/
440static inline bool is_non_allied_unit_tile(const struct tile *ptile,
441 const struct player *pplayer,
443{
444 return NULL != tile_non_allied_unit(ptile, pplayer, everyone_non_allied);
445}
446
447struct unit *tile_other_players_unit(const struct tile *ptile,
448 const struct player *pplayer);
449
450/**********************************************************************/
453static inline bool is_other_players_unit_tile(const struct tile *ptile,
454 const struct player *pplayer)
455{
456 return NULL != tile_other_players_unit(ptile, pplayer);
457}
458
459struct unit *tile_non_attack_unit(const struct tile *ptile,
460 const struct player *pplayer);
461
462/**********************************************************************/
466static inline bool is_non_attack_unit_tile(const struct tile *ptile,
467 const struct player *pplayer)
468{
469 return NULL != tile_non_attack_unit(ptile, pplayer);
470}
471
472struct unit *unit_occupies_tile(const struct tile *ptile,
473 const struct player *pplayer);
474
475bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile,
476 const struct civ_map *zmap);
477bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile,
478 const struct civ_map *zmap);
479
480/**********************************************************************/
487static inline bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile,
488 const struct civ_map *zmap)
489{
490 return is_server()
492}
493
494bool unit_being_aggressive(const struct civ_map *nmap,
495 const struct unit *punit);
497
503
504struct unit *unit_virtual_create(struct player *pplayer, struct city *pcity,
505 const struct unit_type *punittype,
506 int veteran_level);
507void unit_virtual_destroy(struct unit *punit);
508bool unit_is_virtual(const struct unit *punit);
509void free_unit_orders(struct unit *punit);
510
511int get_transporter_occupancy(const struct unit *ptrans);
512struct unit *transporter_for_unit(const struct unit *pcargo);
513struct unit *transporter_for_unit_at(const struct unit *pcargo,
514 const struct tile *ptile);
515
518 const struct unit *punit,
519 const struct unit_type *to_unittype);
521 const struct unit *punit,
522 bool is_free);
524 const struct unit *punit,
525 char *buf, size_t bufsz);
526bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit);
527
528int unit_pays_mp_for_action(const struct action *paction,
529 const struct unit *punit);
530
531int hp_gain_coord(const struct unit *punit);
532int unit_gain_hitpoints(const struct unit *punit);
533bool is_losing_hp(const struct unit *punit);
534bool unit_type_is_losing_hp(const struct player *pplayer,
535 const struct unit_type *punittype);
536
537bool unit_is_alive(int id);
538
539void *unit_ai_data(const struct unit *punit, const struct ai_type *ai);
540void unit_set_ai_data(struct unit *punit, const struct ai_type *ai,
541 void *data);
542
543int unit_bribe_cost(const struct unit *punit, const struct player *briber,
544 const struct unit *briber_unit);
545int stack_bribe_cost(const struct tile *ptile, const struct player *briber,
546 const struct unit *briber_unit);
547
548bool unit_transport_load(struct unit *pcargo, struct unit *ptrans,
549 bool force);
550bool unit_transport_unload(struct unit *pcargo);
551struct unit *unit_transport_get(const struct unit *pcargo);
552
553#define unit_transported_server(_pcargo_) ((_pcargo_)->transporter != NULL)
554
555/* Evaluates parameter twice! */
556#define unit_transported_client(_pcargo_) \
557 ((_pcargo_)->client.transported_by != -1 \
558 || (_pcargo_)->transporter != NULL)
559
560bool unit_transported(const struct unit *pcargo);
561struct unit_list *unit_transport_cargo(const struct unit *ptrans);
562bool unit_transport_check(const struct unit *pcargo,
563 const struct unit *ptrans);
564bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans);
565int unit_cargo_depth(const struct unit *pcargo);
566int unit_transport_depth(const struct unit *ptrans);
567
568bool unit_is_cityfounder(const struct unit *punit);
569
570/* Iterate all transporters carrying '_pcargo', directly or indirectly. */
571#define unit_transports_iterate(_pcargo, _ptrans) { \
572 struct unit *_ptrans; \
573 for (_ptrans = unit_transport_get(_pcargo); NULL != _ptrans; \
574 _ptrans = unit_transport_get(_ptrans)) {
575#define unit_transports_iterate_end }}
576
577struct cargo_iter;
578size_t cargo_iter_sizeof(void) fc__attribute((const));
579
581 const struct unit *ptrans);
582#define unit_cargo_iterate(_ptrans, _pcargo) \
583 generic_iterate(struct cargo_iter, struct unit *, _pcargo, \
584 cargo_iter_sizeof, cargo_iter_init, _ptrans)
585#define unit_cargo_iterate_end generic_iterate_end
586
587bool unit_order_list_is_sane(const struct civ_map *nmap,
588 int length, const struct unit_order *orders);
589struct unit_order *create_unit_orders(const struct civ_map *nmap,
590 int length,
591 const struct unit_order *orders);
592
594
595#ifdef __cplusplus
596}
597#endif /* __cplusplus */
598
599#endif /* FC__UNIT_H */
char * incite_cost
Definition comments.c:76
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
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
static bool is_server(void)
enum unit_activity Activity_type_id
Definition fc_types.h:238
adv_unit_task
Definition fc_types.h:229
int action_id
Definition fc_types.h:248
@ O_LAST
Definition fc_types.h:101
static const int bufsz
Definition helpdlg.c:70
Definition ai.h:50
Definition city.h:317
Definition tile.h:50
enum adv_unit_task task
Definition unit.h:90
enum unit_activity activity
Definition unit.h:95
enum unit_orders order
Definition unit.h:94
int action
Definition unit.h:102
enum direction8 dir
Definition unit.h:104
int target
Definition unit.h:98
int sub_target
Definition unit.h:99
Definition unit.h:140
time_t action_timestamp
Definition unit.h:248
int upkeep[O_LAST]
Definition unit.h:150
bool has_orders
Definition unit.h:196
bool occupied
Definition unit.h:222
enum action_decision action_decision_want
Definition unit.h:205
int battlegroup
Definition unit.h:194
enum unit_activity activity
Definition unit.h:159
int moves_left
Definition unit.h:152
int refcount
Definition unit.h:143
int id
Definition unit.h:147
enum gen_action action
Definition unit.h:160
struct unit_list * transporting
Definition unit.h:187
int ord_city
Definition unit.h:245
struct unit::@83 orders
bool moved
Definition unit.h:176
int ord_map
Definition unit.h:244
bool debug
Definition unit.h:237
int index
Definition unit.h:198
struct vision * vision
Definition unit.h:247
bool vigilant
Definition unit.h:200
int hp
Definition unit.h:153
int fuel
Definition unit.h:155
struct extra_type * changed_from_target
Definition unit.h:173
int current_form_turn
Definition unit.h:211
bool stay
Definition unit.h:208
bool colored
Definition unit.h:225
enum direction8 facing
Definition unit.h:144
bool asking_city_name
Definition unit.h:228
struct unit::@84::@87 server
struct tile * tile
Definition unit.h:142
struct unit::@84::@86 client
struct extra_type * activity_target
Definition unit.h:167
struct act_prob * act_prob_cache
Definition unit.h:231
int activity_count
Definition unit.h:165
struct unit_order * list
Definition unit.h:201
enum unit_activity changed_from
Definition unit.h:171
struct unit_adv * adv
Definition unit.h:239
struct player * nationality
Definition unit.h:146
int transported_by
Definition unit.h:219
bool repeat
Definition unit.h:199
int color_index
Definition unit.h:226
struct unit_move_data * moving
Definition unit.h:250
int action_turn
Definition unit.h:249
int homecity
Definition unit.h:148
bool paradropped
Definition unit.h:177
bool done_moving
Definition unit.h:184
struct unit * transporter
Definition unit.h:186
int birth_turn
Definition unit.h:210
struct goods_type * carrying
Definition unit.h:189
struct tile * goto_tile
Definition unit.h:157
struct tile * action_decision_tile
Definition unit.h:206
const struct unit_type * utype
Definition unit.h:141
int veteran
Definition unit.h:154
int changed_from_count
Definition unit.h:172
struct player * owner
Definition unit.h:145
bool dying
Definition unit.h:253
enum unit_focus_status focus_status
Definition unit.h:217
enum server_side_agent ssa_controller
Definition unit.h:175
#define fc__attribute(x)
Definition support.h:99
size_t cargo_iter_sizeof(void) fc__attribute((const))
bool unit_can_do_action_sub_result(const struct unit *punit, enum action_sub_result sub_result)
Definition unit.c:403
static bool is_other_players_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:453
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:944
bool is_tile_activity(enum unit_activity activity)
Definition unit.c:1641
struct unit_order * create_unit_orders(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2911
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:1993
bool unit_type_really_ignores_zoc(const struct unit_type *punittype)
Definition unit.c:1541
bool unit_type_is_losing_hp(const struct player *pplayer, const struct unit_type *punittype)
Definition unit.c:2277
bool is_terrain_change_activity(enum unit_activity activity)
Definition unit.c:1626
int unit_shield_value(const struct unit *punit, const struct unit_type *punittype, const struct action *paction)
Definition unit.c:214
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1820
goto_route_type
Definition unit.h:57
@ ROUTE_GOTO
Definition unit.h:58
@ ROUTE_PATROL
Definition unit.h:58
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
Definition unit.c:489
void free_unit_orders(struct unit *punit)
Definition unit.c:1806
void unit_set_ai_data(struct unit *punit, const struct ai_type *ai, void *data)
Definition unit.c:2327
bool unit_is_alive(int id)
Definition unit.c:2290
bool unit_can_est_trade_route_here(const struct unit *punit)
Definition unit.c:284
bool is_occupying_unit(const struct unit *punit)
Definition unit.c:324
bool is_hiding_unit(const struct unit *punit)
Definition unit.c:450
int get_activity_rate_this_turn(const struct unit *punit)
Definition unit.c:550
int unit_pays_mp_for_action(const struct action *paction, const struct unit *punit)
Definition unit.c:2172
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
static bool is_enemy_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:427
unit_focus_status
Definition unit.h:53
@ FOCUS_AVAIL
Definition unit.h:54
@ FOCUS_DONE
Definition unit.h:54
@ FOCUS_WAIT
Definition unit.h:54
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
Definition unit.c:2447
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1959
struct iterator * cargo_iter_init(struct cargo_iter *iter, const struct unit *ptrans)
Definition unit.c:2701
int unit_cargo_depth(const struct unit *pcargo)
Definition unit.c:2610
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:466
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2088
unit_orders
Definition unit.h:38
@ ORDER_ACTION_MOVE
Definition unit.h:46
@ ORDER_ACTIVITY
Definition unit.h:42
@ ORDER_FULL_MP
Definition unit.h:44
@ ORDER_MOVE
Definition unit.h:40
@ ORDER_LAST
Definition unit.h:50
@ ORDER_PERFORM_ACTION
Definition unit.h:48
bool is_losing_hp(const struct unit *punit)
Definition unit.c:2265
bool is_targeted_activity(enum unit_activity activity)
Definition unit.c:1651
bool unit_can_add_or_build_city(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:472
struct unit * tile_non_attack_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1376
int hp_gain_coord(const struct unit *punit)
Definition unit.c:2199
bool can_unit_change_homecity(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:505
bool is_plr_zoc_client(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.c:1493
struct player * unit_nationality(const struct unit *punit)
Definition unit.c:1274
bool unit_being_aggressive(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:1555
int get_activity_rate(const struct unit *punit)
Definition unit.c:519
bool can_unit_deboard_or_be_unloaded(const struct civ_map *nmap, const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:801
bool unit_transport_check(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2556
bool is_attack_unit(const struct unit *punit)
Definition unit.c:305
static bool is_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:415
const Activity_type_id tile_changing_activities[]
Definition unit.c:44
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2518
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2467
bool is_build_activity(enum unit_activity activity)
Definition unit.c:1596
bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:2597
#define unit_owner(_pu)
Definition unit.h:403
int unit_gain_hitpoints(const struct unit *punit)
Definition unit.c:2220
int unit_bribe_cost(const struct unit *punit, const struct player *briber, const struct unit *briber_unit)
Definition unit.c:2344
enum unit_airlift_result test_unit_can_airlift_to(const struct civ_map *nmap, const struct player *restriction, const struct unit *punit, const struct city *pdest_city)
Definition unit.c:81
bool is_plr_zoc_srv(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.c:1424
bool can_unit_continue_current_activity(const struct civ_map *nmap, struct unit *punit)
Definition unit.c:865
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1260
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:724
bool unit_is_cityfounder(const struct unit *punit)
Definition unit.c:2718
bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile)
Definition unit.c:1151
unit_upgrade_result
Definition unit.h:61
@ UU_NO_MONEY
Definition unit.h:64
@ UU_NOT_IN_CITY
Definition unit.h:65
@ UU_NO_UNITTYPE
Definition unit.h:63
@ UU_NOT_TERRAIN
Definition unit.h:68
@ UU_UNSUITABLE_TRANSPORT
Definition unit.h:69
@ UU_NOT_CITY_OWNER
Definition unit.h:66
@ UU_NOT_ENOUGH_ROOM
Definition unit.h:67
@ UU_OK
Definition unit.h:62
@ UU_NOT_ACTIVITY
Definition unit.h:70
bool is_field_unit(const struct unit *punit)
Definition unit.c:438
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:383
bool unit_can_do_action_result(const struct unit *punit, enum action_result result)
Definition unit.c:393
enum gen_action activity_default_action(enum unit_activity act)
Definition unit.c:2930
bool is_martial_law_unit(const struct unit *punit)
Definition unit.c:316
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1661
bool can_unit_do_autoworker(const struct unit *punit)
Definition unit.c:630
bool can_unit_teleport(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:830
bool unit_order_list_is_sane(const struct civ_map *nmap, int length, const struct unit_order *orders)
Definition unit.c:2726
const char * get_activity_text(enum unit_activity activity)
Definition unit.c:638
bv_extras get_unit_tile_pillage_set(const struct tile *ptile)
Definition unit.c:1167
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:297
bool can_unit_unload(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:776
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:1132
bool is_enter_borders_unit(const struct unit *punit)
Definition unit.c:332
bool is_clean_activity(enum unit_activity activity)
Definition unit.c:1612
int unit_transport_depth(const struct unit *ptrans)
Definition unit.c:2628
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:846
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1184
bool unit_can_help_build_wonder_here(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:258
bool can_unit_do_activity(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity)
Definition unit.c:892
struct unit * tile_other_players_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1360
bool is_special_unit(const struct unit *punit)
Definition unit.c:350
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1766
int stack_bribe_cost(const struct tile *ptile, const struct player *briber, const struct unit *briber_unit)
Definition unit.c:2432
struct unit * tile_enemy_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1320
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1284
void set_unit_activity(struct unit *punit, enum unit_activity new_activity, enum gen_action trigger_action)
Definition unit.c:1114
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:2025
bool unit_can_airlift_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity) fc__attribute((nonnull(3)))
Definition unit.c:186
bool can_unit_load(const struct unit *punit, const struct unit *ptrans)
Definition unit.c:749
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2502
bool are_unit_orders_equal(const struct unit_order *order1, const struct unit_order *order2)
Definition unit.c:59
bool unit_is_virtual(const struct unit *punit)
Definition unit.c:2307
bool is_flagless_to_player(const struct unit *punit, const struct player *pplayer)
Definition unit.c:363
bool is_square_threatened(const struct civ_map *nmap, const struct player *pplayer, const struct tile *ptile, bool omniscient)
Definition unit.c:412
bool is_guard_unit(const struct unit *punit)
Definition unit.c:340
struct unit * unit_occupies_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1397
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2528
void * unit_ai_data(const struct unit *punit, const struct ai_type *ai)
Definition unit.c:2319
bool unit_has_orders(const struct unit *punit)
Definition unit.c:202
struct unit * tile_allied_unit(const struct tile *ptile, const struct player *pplayer)
Definition unit.c:1297
struct unit * transporter_for_unit(const struct unit *pcargo)
Definition unit.c:1949
unit_airlift_result
Definition unit.h:73
@ AR_SRC_NO_FLIGHTS
Definition unit.h:85
@ AR_OK_SRC_UNKNOWN
Definition unit.h:76
@ AR_OK_DST_UNKNOWN
Definition unit.h:77
@ AR_NO_MOVES
Definition unit.h:79
@ AR_BAD_DST_CITY
Definition unit.h:84
@ AR_NOT_IN_CITY
Definition unit.h:82
@ AR_OCCUPIED
Definition unit.h:81
@ AR_OK
Definition unit.h:75
@ AR_DST_NO_FLIGHTS
Definition unit.h:86
@ AR_WRONG_UNITTYPE
Definition unit.h:80
@ AR_BAD_SRC_CITY
Definition unit.h:83
static bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile, const struct civ_map *zmap)
Definition unit.h:487
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:440
bool unit_can_convert(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:2072
bool activity_requires_target(enum unit_activity activity)
Definition unit.c:590
bool could_unit_be_in_transport(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:692
struct unit * tile_non_allied_unit(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.c:1335
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:931