Freeciv-3.1
Loading...
Searching...
No Matches
unittype.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__UNITTYPE_H
14#define FC__UNITTYPE_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "bitvector.h"
22#include "shared.h"
23
24/* common */
25#include "fc_types.h"
26#include "name_translation.h"
27#include "requirements.h"
28
29struct astring; /* Actually defined in "utility/astring.h". */
30struct strvec; /* Actually defined in "utility/string_vector.h". */
31
32struct ai_type;
33struct civ_map;
34
35/* U_LAST is a value which is guaranteed to be larger than all
36 * actual Unit_type_id values. It is used as a flag value;
37 * it can also be used for fixed allocations to ensure able
38 * to hold full number of unit types.
39 * Used in the network protocol. */
40#define U_LAST MAX_NUM_UNITS
41
42/* The largest distance a ruleset can allow a unit to paradrop.
43 *
44 * Remember to make sure that the field type of PACKET_RULESET_UNIT's
45 * paratroopers_range field can transfer the new maximum if you increase
46 * it.
47 *
48 * The top value is reserved in case a future Freeciv version wants to
49 * implement "no maximum range". It could be used to signal that the unit
50 * can paradrop anywhere. Note that the value below it is high enough to
51 * give the same effect on all maps inside the current size limits.
52 * (No map side can be larger than MAP_MAX_LINEAR_SIZE)
53 */
54#define UNIT_MAX_PARADROP_RANGE (65535 - 1)
55
56/* Used in the network protocol. */
57#define SPECENUM_NAME unit_class_flag_id
58#define SPECENUM_VALUE0 UCF_TERRAIN_SPEED
59#define SPECENUM_VALUE0NAME N_("?uclassflag:TerrainSpeed")
60#define SPECENUM_VALUE1 UCF_TERRAIN_DEFENSE
61#define SPECENUM_VALUE1NAME N_("?uclassflag:TerrainDefense")
62#define SPECENUM_VALUE2 UCF_DAMAGE_SLOWS
63#define SPECENUM_VALUE2NAME N_("?uclassflag:DamageSlows")
64/* Can occupy enemy cities */
65#define SPECENUM_VALUE3 UCF_CAN_OCCUPY_CITY
66#define SPECENUM_VALUE3NAME N_("?uclassflag:CanOccupyCity")
67#define SPECENUM_VALUE4 UCF_BUILD_ANYWHERE
68#define SPECENUM_VALUE4NAME N_("?uclassflag:BuildAnywhere")
69#define SPECENUM_VALUE5 UCF_UNREACHABLE
70#define SPECENUM_VALUE5NAME N_("?uclassflag:Unreachable")
71/* Can collect ransom from barbarian leader */
72#define SPECENUM_VALUE6 UCF_COLLECT_RANSOM
73#define SPECENUM_VALUE6NAME N_("?uclassflag:CollectRansom")
74/* Is subject to ZOC */
75#define SPECENUM_VALUE7 UCF_ZOC
76#define SPECENUM_VALUE7NAME N_("?uclassflag:ZOC")
77/* Cities can still work tile when enemy unit on it */
78#define SPECENUM_VALUE8 UCF_DOESNT_OCCUPY_TILE
79#define SPECENUM_VALUE8NAME N_("?uclassflag:DoesntOccupyTile")
80/* Can attack against units on non-native tiles */
81#define SPECENUM_VALUE9 UCF_ATTACK_NON_NATIVE
82#define SPECENUM_VALUE9NAME N_("?uclassflag:AttackNonNative")
83/* Kills citizens upon successful attack against a city */
84#define SPECENUM_VALUE10 UCF_KILLCITIZEN
85#define SPECENUM_VALUE10NAME N_("?uclassflag:KillCitizen")
86/* Frightens the huts it pops. */
87#define SPECENUM_VALUE11 UCF_HUT_FRIGHTEN
88#define SPECENUM_VALUE11NAME N_("?uclassflag:HutFrighten")
89/* Is a target for "Land Bombardment" attacks */
90#define SPECENUM_VALUE12 UCF_NONNAT_BOMBARD_TGT
91#define SPECENUM_VALUE12NAME N_("?uclassflag:NonNatBombardTgt")
92
93#define SPECENUM_VALUE13 UCF_USER_FLAG_1
94#define SPECENUM_VALUE14 UCF_USER_FLAG_2
95#define SPECENUM_VALUE15 UCF_USER_FLAG_3
96#define SPECENUM_VALUE16 UCF_USER_FLAG_4
97#define SPECENUM_VALUE17 UCF_USER_FLAG_5
98#define SPECENUM_VALUE18 UCF_USER_FLAG_6
99#define SPECENUM_VALUE19 UCF_USER_FLAG_7
100#define SPECENUM_VALUE20 UCF_USER_FLAG_8
101#define SPECENUM_VALUE21 UCF_USER_FLAG_9
102#define SPECENUM_VALUE22 UCF_USER_FLAG_10
103#define SPECENUM_VALUE23 UCF_USER_FLAG_11
104#define SPECENUM_VALUE24 UCF_USER_FLAG_12
105
106/* keep this last */
107#define SPECENUM_COUNT UCF_COUNT
108#define SPECENUM_NAMEOVERRIDE
109#define SPECENUM_BITVECTOR bv_unit_class_flags
110#include "specenum_gen.h"
111
112#define UCF_LAST_USER_FLAG UCF_USER_FLAG_12
113#define MAX_NUM_USER_UCLASS_FLAGS (UCF_LAST_USER_FLAG \
114 - UCF_USER_FLAG_1 + 1)
115
116/* Used in savegame processing and clients. */
117#define SPECENUM_NAME unit_move_type
118#define SPECENUM_VALUE0 UMT_LAND
119#define SPECENUM_VALUE0NAME "Land"
120#define SPECENUM_VALUE1 UMT_SEA
121#define SPECENUM_VALUE1NAME "Sea"
122#define SPECENUM_VALUE2 UMT_BOTH
123#define SPECENUM_VALUE2NAME "Both"
124#include "specenum_gen.h"
125
126/* Used in the network protocol. */
127BV_DEFINE(bv_unit_classes, UCL_LAST);
128
130
132
133struct extra_type_list;
134struct unit_class_list;
135
140 enum unit_move_type move_type;
141 int min_speed; /* Minimum speed after damage and effects */
142 int hp_loss_pct; /* Percentage of hitpoints lost each turn not in city or airbase */
144 bv_unit_class_flags flags;
145
147
148 struct {
153
154 struct {
155 struct extra_type_list *refuel_extras;
156 struct extra_type_list *native_tile_extras;
157 struct extra_type_list *native_bases;
158 struct extra_type_list *bonus_roads;
159 struct extra_type_list *hiding_extras;
160 struct unit_class_list *subset_movers;
162
163 /* Used to upgrade the ruleset format version. */
164 struct {
167};
168
169/* Unit "special effects" flags:
170 * Note this is now an enumerated type, and not power-of-two integers
171 * for bits, though unit_type.flags is still a bitfield, and code
172 * which uses unit_has_type_flag() without twiddling bits is unchanged.
173 * (It is easier to go from i to (1<<i) than the reverse.)
174 * See data/classic/units.ruleset for documentation of their effects.
175 * Change the array *flag_names[] in unittype.c accordingly.
176 * Used in the network protocol.
177 */
178#define SPECENUM_NAME unit_type_flag_id
179/* Unit has no ZOC */
180#define SPECENUM_VALUE0 UTYF_NOZOC
181#define SPECENUM_VALUE0NAME N_("?unitflag:HasNoZOC")
182#define SPECENUM_VALUE1 UTYF_IGZOC
183/* TRANS: unit type flag (rarely shown): "ignore zones of control" */
184#define SPECENUM_VALUE1NAME N_("?unitflag:IgZOC")
185#define SPECENUM_VALUE2 UTYF_CIVILIAN
186#define SPECENUM_VALUE2NAME N_("?unitflag:NonMil")
187#define SPECENUM_VALUE3 UTYF_IGTER
188/* TRANS: unit type flag (rarely shown): "ignore terrain" */
189#define SPECENUM_VALUE3NAME N_("?unitflag:IgTer")
190#define SPECENUM_VALUE4 UTYF_FIELDUNIT
191#define SPECENUM_VALUE4NAME N_("?unitflag:FieldUnit")
192/* autoattack: a unit will choose to attack this unit even if defending
193 * against it has better odds. */
194#define SPECENUM_VALUE5 UTYF_PROVOKING
195#define SPECENUM_VALUE5NAME N_("?unitflag:Provoking")
196/* Overrides unreachable_protects server setting */
197#define SPECENUM_VALUE6 UTYF_NEVER_PROTECTS
198#define SPECENUM_VALUE6NAME N_("?unitflag:NeverProtects")
199/* Does not include ability to found cities */
200#define SPECENUM_VALUE7 UTYF_SETTLERS
201#define SPECENUM_VALUE7NAME N_("?unitflag:Settlers")
202#define SPECENUM_VALUE8 UTYF_DIPLOMAT
203#define SPECENUM_VALUE8NAME N_("?unitflag:Diplomat")
204/* Can't leave the coast */
205#define SPECENUM_VALUE9 UTYF_COAST_STRICT
206#define SPECENUM_VALUE9NAME N_("?unitflag:CoastStrict")
207/* Can 'refuel' at coast - meaningless if fuel value not set */
208#define SPECENUM_VALUE10 UTYF_COAST
209#define SPECENUM_VALUE10NAME N_("?unitflag:Coast")
210/* upkeep can switch from shield to gold */
211#define SPECENUM_VALUE11 UTYF_SHIELD2GOLD
212#define SPECENUM_VALUE11NAME N_("?unitflag:Shield2Gold")
213/* Strong in diplomatic battles. */
214#define SPECENUM_VALUE12 UTYF_SPY
215#define SPECENUM_VALUE12NAME N_("?unitflag:Spy")
216/* Cannot attack vs non-native tiles even if class can */
217#define SPECENUM_VALUE13 UTYF_ONLY_NATIVE_ATTACK
218#define SPECENUM_VALUE13NAME N_("?unitflag:Only_Native_Attack")
219/* Only Fundamentalist government can build these units */
220#define SPECENUM_VALUE14 UTYF_FANATIC
221#define SPECENUM_VALUE14NAME N_("?unitflag:Fanatic")
222/* Losing this unit means losing the game */
223#define SPECENUM_VALUE15 UTYF_GAMELOSS
224#define SPECENUM_VALUE15NAME N_("?unitflag:GameLoss")
225/* A player can only have one unit of this type */
226#define SPECENUM_VALUE16 UTYF_UNIQUE
227#define SPECENUM_VALUE16NAME N_("?unitflag:Unique")
228/* When a transport containing this unit disappears the game will try to
229 * rescue units with this flag before it tries to rescue units without
230 * it. */
231#define SPECENUM_VALUE17 UTYF_EVAC_FIRST
232#define SPECENUM_VALUE17NAME N_("?unitflag:EvacuateFirst")
233/* Always wins diplomatic contests */
234#define SPECENUM_VALUE18 UTYF_SUPERSPY
235#define SPECENUM_VALUE18NAME N_("?unitflag:SuperSpy")
236/* Has no homecity */
237#define SPECENUM_VALUE19 UTYF_NOHOME
238#define SPECENUM_VALUE19NAME N_("?unitflag:NoHome")
239/* Cannot increase veteran level */
240#define SPECENUM_VALUE20 UTYF_NO_VETERAN
241#define SPECENUM_VALUE20NAME N_("?unitflag:NoVeteran")
242/* Gets double firepower against cities */
243#define SPECENUM_VALUE21 UTYF_CITYBUSTER
244#define SPECENUM_VALUE21NAME N_("?unitflag:CityBuster")
245/* Unit cannot be built (barb leader etc) */
246#define SPECENUM_VALUE22 UTYF_NOBUILD
247#define SPECENUM_VALUE22NAME N_("?unitflag:NoBuild")
248/* Firepower set to 1 when EFT_DEFEND_BONUS applies
249 * (for example, land unit attacking city with walls) */
250#define SPECENUM_VALUE23 UTYF_BADWALLATTACKER
251#define SPECENUM_VALUE23NAME N_("?unitflag:BadWallAttacker")
252/* Firepower set to 1 and attackers x2 when in city */
253#define SPECENUM_VALUE24 UTYF_BADCITYDEFENDER
254#define SPECENUM_VALUE24NAME N_("?unitflag:BadCityDefender")
255/* Only barbarians can build this unit */
256#define SPECENUM_VALUE25 UTYF_BARBARIAN_ONLY
257#define SPECENUM_VALUE25NAME N_("?unitflag:BarbarianOnly")
258/* Unit can't be built in scenarios where founding new cities is prevented. */
259#define SPECENUM_VALUE26 UTYF_NEWCITY_GAMES_ONLY
260#define SPECENUM_VALUE26NAME N_("?unitflag:NewCityGamesOnly")
261/* Can escape when killstack occours */
262#define SPECENUM_VALUE27 UTYF_CANESCAPE
263#define SPECENUM_VALUE27NAME N_("?unitflag:CanEscape")
264/* Can kill escaping units */
265#define SPECENUM_VALUE28 UTYF_CANKILLESCAPING
266#define SPECENUM_VALUE28NAME N_("?unitflag:CanKillEscaping")
267
268#define SPECENUM_VALUE29 UTYF_USER_FLAG_1
269#define SPECENUM_VALUE30 UTYF_USER_FLAG_2
270#define SPECENUM_VALUE31 UTYF_USER_FLAG_3
271#define SPECENUM_VALUE32 UTYF_USER_FLAG_4
272#define SPECENUM_VALUE33 UTYF_USER_FLAG_5
273#define SPECENUM_VALUE34 UTYF_USER_FLAG_6
274#define SPECENUM_VALUE35 UTYF_USER_FLAG_7
275#define SPECENUM_VALUE36 UTYF_USER_FLAG_8
276#define SPECENUM_VALUE37 UTYF_USER_FLAG_9
277#define SPECENUM_VALUE38 UTYF_USER_FLAG_10
278#define SPECENUM_VALUE39 UTYF_USER_FLAG_11
279#define SPECENUM_VALUE40 UTYF_USER_FLAG_12
280#define SPECENUM_VALUE41 UTYF_USER_FLAG_13
281#define SPECENUM_VALUE42 UTYF_USER_FLAG_14
282#define SPECENUM_VALUE43 UTYF_USER_FLAG_15
283#define SPECENUM_VALUE44 UTYF_USER_FLAG_16
284#define SPECENUM_VALUE45 UTYF_USER_FLAG_17
285#define SPECENUM_VALUE46 UTYF_USER_FLAG_18
286#define SPECENUM_VALUE47 UTYF_USER_FLAG_19
287#define SPECENUM_VALUE48 UTYF_USER_FLAG_20
288#define SPECENUM_VALUE49 UTYF_USER_FLAG_21
289#define SPECENUM_VALUE50 UTYF_USER_FLAG_22
290#define SPECENUM_VALUE51 UTYF_USER_FLAG_23
291#define SPECENUM_VALUE52 UTYF_USER_FLAG_24
292#define SPECENUM_VALUE53 UTYF_USER_FLAG_25
293#define SPECENUM_VALUE54 UTYF_USER_FLAG_26
294#define SPECENUM_VALUE55 UTYF_USER_FLAG_27
295#define SPECENUM_VALUE56 UTYF_USER_FLAG_28
296#define SPECENUM_VALUE57 UTYF_USER_FLAG_29
297#define SPECENUM_VALUE58 UTYF_USER_FLAG_30
298#define SPECENUM_VALUE59 UTYF_USER_FLAG_31
299#define SPECENUM_VALUE60 UTYF_USER_FLAG_32
300#define SPECENUM_VALUE61 UTYF_USER_FLAG_33
301#define SPECENUM_VALUE62 UTYF_USER_FLAG_34
302#define SPECENUM_VALUE63 UTYF_USER_FLAG_35
303#define SPECENUM_VALUE64 UTYF_USER_FLAG_36
304#define SPECENUM_VALUE65 UTYF_USER_FLAG_37
305#define SPECENUM_VALUE66 UTYF_USER_FLAG_38
306#define SPECENUM_VALUE67 UTYF_USER_FLAG_39
307#define SPECENUM_VALUE68 UTYF_USER_FLAG_40
308#define SPECENUM_VALUE69 UTYF_USER_FLAG_41
309#define SPECENUM_VALUE70 UTYF_USER_FLAG_42
310#define SPECENUM_VALUE71 UTYF_USER_FLAG_43
311#define SPECENUM_VALUE72 UTYF_USER_FLAG_44
312#define SPECENUM_VALUE73 UTYF_USER_FLAG_45
313/* Note that first role must have value next to last flag */
314
315#define UTYF_LAST_USER_FLAG UTYF_USER_FLAG_45
316#define MAX_NUM_USER_UNIT_FLAGS (UTYF_LAST_USER_FLAG - UTYF_USER_FLAG_1 + 1)
317#define SPECENUM_NAMEOVERRIDE
318#define SPECENUM_BITVECTOR bv_unit_type_flags
319#include "specenum_gen.h"
320
321
322/* Unit "roles": these are similar to unit flags but differ in that
323 they don't represent intrinsic properties or abilities of units,
324 but determine which units are used (mainly by the server or AI)
325 in various circumstances, or "roles".
326 Note that in some cases flags can act as roles, eg, we don't need
327 a role for "settlers", because we can just use UTYF_SETTLERS.
328 (Now have to consider ACTION_FOUND_CITY too)
329 So we make sure flag values and role values are distinct,
330 so some functions can use them interchangably.
331 See data/classic/units.ruleset for documentation of their effects.
332*/
333#define L_FIRST (UTYF_LAST_USER_FLAG + 1)
334
335#define SPECENUM_NAME unit_role_id
336/* is built first when city established */
337#define SPECENUM_VALUE74 L_FIRSTBUILD
338#define SPECENUM_VALUE74NAME N_("?unitflag:FirstBuild")
339/* initial explorer unit */
340#define SPECENUM_VALUE75 L_EXPLORER
341#define SPECENUM_VALUE75NAME N_("?unitflag:Explorer")
342/* can be found in hut */
343#define SPECENUM_VALUE76 L_HUT
344#define SPECENUM_VALUE76NAME N_("?unitflag:Hut")
345/* can be found in hut, tech required */
346#define SPECENUM_VALUE77 L_HUT_TECH
347#define SPECENUM_VALUE77NAME N_("?unitflag:HutTech")
348/* is created in Partisan circumstances */
349#define SPECENUM_VALUE78 L_PARTISAN
350#define SPECENUM_VALUE78NAME N_("?unitflag:Partisan")
351/* ok on defense (AI) */
352#define SPECENUM_VALUE79 L_DEFEND_OK
353#define SPECENUM_VALUE79NAME N_("?unitflag:DefendOk")
354/* primary purpose is defense (AI) */
355#define SPECENUM_VALUE80 L_DEFEND_GOOD
356#define SPECENUM_VALUE80NAME N_("?unitflag:DefendGood")
357/* is useful for ferrying (AI) */
358#define SPECENUM_VALUE81 L_FERRYBOAT
359#define SPECENUM_VALUE81NAME N_("?unitflag:FerryBoat")
360/* barbarians unit, land only */
361#define SPECENUM_VALUE82 L_BARBARIAN
362#define SPECENUM_VALUE82NAME N_("?unitflag:Barbarian")
363/* barbarians unit, global tech required */
364#define SPECENUM_VALUE83 L_BARBARIAN_TECH
365#define SPECENUM_VALUE83NAME N_("?unitflag:BarbarianTech")
366/* barbarian boat */
367#define SPECENUM_VALUE84 L_BARBARIAN_BOAT
368#define SPECENUM_VALUE84NAME N_("?unitflag:BarbarianBoat")
369/* what barbarians should build */
370#define SPECENUM_VALUE85 L_BARBARIAN_BUILD
371#define SPECENUM_VALUE85NAME N_("?unitflag:BarbarianBuild")
372/* barbarians build when global tech */
373#define SPECENUM_VALUE86 L_BARBARIAN_BUILD_TECH
374#define SPECENUM_VALUE86NAME N_("?unitflag:BarbarianBuildTech")
375/* barbarian leader */
376#define SPECENUM_VALUE87 L_BARBARIAN_LEADER
377#define SPECENUM_VALUE87NAME N_("?unitflag:BarbarianLeader")
378/* sea raider unit */
379#define SPECENUM_VALUE88 L_BARBARIAN_SEA
380#define SPECENUM_VALUE88NAME N_("?unitflag:BarbarianSea")
381/* sea raider unit, global tech required */
382#define SPECENUM_VALUE89 L_BARBARIAN_SEA_TECH
383#define SPECENUM_VALUE89NAME N_("?unitflag:BarbarianSeaTech")
384/* StartUnit: Cities */
385#define SPECENUM_VALUE90 L_START_CITIES
386#define SPECENUM_VALUE90NAME N_("?unitflag:CitiesStartUnit")
387/* StartUnit: Worker */
388#define SPECENUM_VALUE91 L_START_WORKER
389#define SPECENUM_VALUE91NAME N_("?unitflag:WorkerStartUnit")
390/* StartUnit: Explorer */
391#define SPECENUM_VALUE92 L_START_EXPLORER
392#define SPECENUM_VALUE92NAME N_("?unitflag:ExplorerStartUnit")
393/* StartUnit: King */
394#define SPECENUM_VALUE93 L_START_KING
395#define SPECENUM_VALUE93NAME N_("?unitflag:KingStartUnit")
396/* StartUnit: Diplomat */
397#define SPECENUM_VALUE94 L_START_DIPLOMAT
398#define SPECENUM_VALUE94NAME N_("?unitflag:DiplomatStartUnit")
399/* StartUnit: Ferryboat */
400#define SPECENUM_VALUE95 L_START_FERRY
401#define SPECENUM_VALUE95NAME N_("?unitflag:FerryStartUnit")
402/* StartUnit: DefendOk */
403#define SPECENUM_VALUE96 L_START_DEFEND_OK
404#define SPECENUM_VALUE96NAME N_("?unitflag:DefendOkStartUnit")
405/* StartUnit: DefendGood */
406#define SPECENUM_VALUE97 L_START_DEFEND_GOOD
407#define SPECENUM_VALUE97NAME N_("?unitflag:DefendGoodStartUnit")
408/* StartUnit: AttackFast */
409#define SPECENUM_VALUE98 L_START_ATTACK_FAST
410#define SPECENUM_VALUE98NAME N_("?unitflag:AttackFastStartUnit")
411/* StartUnit: AttackStrong */
412#define SPECENUM_VALUE99 L_START_ATTACK_STRONG
413#define SPECENUM_VALUE99NAME N_("?unitflag:AttackStrongStartUnit")
414/* AI hunter type unit */
415#define SPECENUM_VALUE100 L_HUNTER
416#define SPECENUM_VALUE100NAME N_("?unitflag:Hunter")
417/* can improve terrain */
418#define SPECENUM_VALUE101 L_SETTLERS
419#define SPECENUM_VALUE101NAME N_("?unitflag:Settlers")
420#define L_LAST (L_SETTLERS + 1)
421
422#include "specenum_gen.h"
423
424#define L_MAX 64 /* Used in the network protocol. */
425
426FC_STATIC_ASSERT(L_LAST - L_FIRST <= L_MAX, too_many_unit_roles);
427
428/* Used in the network protocol. */
429BV_DEFINE(bv_unit_type_roles, L_MAX);
430
431/* Used in the network protocol. */
432#define SPECENUM_NAME combat_bonus_type
433#define SPECENUM_VALUE0 CBONUS_DEFENSE_MULTIPLIER
434#define SPECENUM_VALUE0NAME "DefenseMultiplier"
435#define SPECENUM_VALUE1 CBONUS_DEFENSE_DIVIDER
436#define SPECENUM_VALUE1NAME "DefenseDivider"
437#define SPECENUM_VALUE2 CBONUS_LOW_FIREPOWER
438#define SPECENUM_VALUE2NAME "LowFirepower"
439#define SPECENUM_VALUE3 CBONUS_DEFENSE_MULTIPLIER_PCT
440#define SPECENUM_VALUE3NAME "DefenseMultiplierPct"
441#define SPECENUM_VALUE4 CBONUS_DEFENSE_DIVIDER_PCT
442#define SPECENUM_VALUE4NAME "DefenseDividerPct"
443#define SPECENUM_VALUE5 CBONUS_SCRAMBLES_PCT
444#define SPECENUM_VALUE5NAME "CityDefensePct"
445#include "specenum_gen.h"
446
448 enum unit_type_flag_id flag;
449 enum combat_bonus_type type;
450 int value;
451
452 /* Not listed in the help text. */
453 bool quiet;
454};
455
456/* get 'struct combat_bonus_list' and related functions: */
457#define SPECLIST_TAG combat_bonus
458#define SPECLIST_TYPE struct combat_bonus
459#include "speclist.h"
460
461#define combat_bonus_list_iterate(bonuslist, pbonus) \
462 TYPED_LIST_ITERATE(struct combat_bonus, bonuslist, pbonus)
463#define combat_bonus_list_iterate_end LIST_ITERATE_END
464
465BV_DEFINE(bv_unit_types, U_LAST);
466
468 struct name_translation name; /* level/rank name */
469 int power_fact; /* combat/work speed/diplomatic power factor (in %) */
471 int base_raise_chance; /* server only */
472 int work_raise_chance; /* server only */
473};
474
480
481struct unit_type {
484 bool ruledit_disabled; /* Does not really exist - hole in units array */
492 int build_cost; /* Use wrappers to access this. */
493 int pop_cost; /* Number of workers the unit contains
494 * (e.g., settlers, engineers) */
498 int unknown_move_cost; /* See utype_unknown_move_cost(). */
499
500 struct advance *require_advance; /* May be NULL */
501 struct requirement_vector build_reqs;
502
505 int hp;
507 struct combat_bonus_list *bonuses;
508
509#define U_NOT_OBSOLETED (NULL)
510 const struct unit_type *obsoleted_by;
511 const struct unit_type *converted_to;
513 int fuel;
514
515 bv_unit_type_flags flags;
516 bv_unit_type_roles roles;
517
518 int happy_cost; /* unhappy people in home city */
520
521 /* Only valid for ACTION_PARADROP* */
523
524 /* Additional values for the expanded veteran system */
526
527 /* Values for bombardment */
529
530 /* Values for founding cities */
532
534
535 enum transp_def_type tp_defense;
536
538
539 bv_unit_classes cargo;
540
541 /* Can attack these classes even if they are otherwise "Unreachable" */
542 bv_unit_classes targets;
543 /* Can load into these class transports at any location,
544 * even if they are otherwise "Unreachable". */
545 bv_unit_classes embarks;
546 /* Can unload from these class transports at any location,
547 * even if they are otherwise "Unreachable". */
548 bv_unit_classes disembarks;
549
550 enum vision_layer vlayer;
551
553
554 struct {
555 bool igwall;
556 bool worker;
558
559 struct {
560 int max_defense_mp_bonus_pct; /* Value 0 here does not guarantee that unit
561 * never has CBONUS_DEFENSE_MULTIPLIER, it
562 * merely means that there's no POSITIVE one */
564 int scramble_coeff[U_LAST]; /* for scrambling units, 10000 x defense factor
565 * in cities (includes common type defense
566 * bonus multiplier), for other 0 */
568
569 /* Used to upgrade the ruleset format version. */
570 struct {
574
575 void *ais[FREECIV_AI_MOD_LAST];
576};
577
578/* General unit and unit type (matched) routines */
580Unit_type_id utype_index(const struct unit_type *punittype);
581Unit_type_id utype_number(const struct unit_type *punittype);
582
583const struct unit_type *unit_type_get(const struct unit *punit);
584struct unit_type *utype_by_number(const Unit_type_id id);
585
586struct unit_type *unit_type_by_rule_name(const char *name);
587struct unit_type *unit_type_by_translated_name(const char *name);
588
589const char *unit_rule_name(const struct unit *punit);
590const char *utype_rule_name(const struct unit_type *punittype);
591
592const char *unit_name_translation(const struct unit *punit);
593const char *utype_name_translation(const struct unit_type *punittype);
594
595const char *utype_values_string(const struct unit_type *punittype);
596const char *utype_values_translation(const struct unit_type *punittype);
597
598/* General unit type flag and role routines */
599bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag);
600
601/**************************************************************************
602 Return whether the given unit type has the flag.
603**************************************************************************/
604static inline bool utype_has_flag(const struct unit_type *punittype, int flag)
605{
606 return BV_ISSET(punittype->flags, flag);
607}
608
609bool unit_has_type_role(const struct unit *punit, enum unit_role_id role);
610bool utype_has_role(const struct unit_type *punittype, int role);
611
613void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name,
614 const char *helptxt);
615const char *unit_type_flag_helptxt(enum unit_type_flag_id id);
616
617bool utype_can_create_extra(const struct unit_type *putype,
618 const struct extra_type *pextra);
619bool utype_can_remove_extra(const struct unit_type *putype,
620 const struct extra_type *pextra);
621
622bool unit_can_take_over(const struct unit *punit);
623bool utype_can_take_over(const struct unit_type *punittype);
624
625bool utype_can_freely_load(const struct unit_type *pcargotype,
626 const struct unit_type *ptranstype);
627bool utype_can_freely_unload(const struct unit_type *pcargotype,
628 const struct unit_type *ptranstype);
629
630bool utype_may_act_at_all(const struct unit_type *putype);
631bool utype_can_do_action(const struct unit_type *putype,
632 const action_id act_id);
633bool utype_can_do_action_result(const struct unit_type *putype,
634 enum action_result result);
635bool utype_can_do_action_sub_result(const struct unit_type *putype,
636 enum action_sub_result sub_result);
637bool utype_acts_hostile(const struct unit_type *putype);
638
639bool can_unit_act_when_ustate_is(const struct unit_type *punit_type,
640 const enum ustate_prop prop,
641 const bool is_there);
642bool utype_can_do_act_when_ustate(const struct unit_type *punit_type,
643 const action_id act_id,
644 const enum ustate_prop prop,
645 const bool is_there);
646bool utype_can_do_action_result_when_ustate(const struct unit_type *putype,
647 enum action_result result,
648 const enum ustate_prop prop,
649 const bool is_there);
650
651bool utype_can_do_act_if_tgt_citytile(const struct unit_type *punit_type,
652 const action_id act_id,
653 const enum citytile_type prop,
654 const bool is_there);
655
656bool can_utype_do_act_if_tgt_diplrel(const struct unit_type *punit_type,
657 const action_id act_id,
658 const int prop,
659 const bool is_there);
660
661bool
663 const action_id act_id,
664 const int prop,
665 const bool is_there);
666
667bool utype_may_act_move_frags(const struct unit_type *punit_type,
668 const action_id act_id,
669 const int move_fragments);
670
671bool utype_may_act_tgt_city_tile(const struct unit_type *punit_type,
672 const action_id act_id,
673 const enum citytile_type prop,
674 const bool is_there);
675
676bool utype_action_takes_all_mp(const struct unit_type *putype,
677 struct action *paction);
678
679bool utype_action_takes_all_mp_if_ustate_is(const struct unit_type *putype,
680 struct action *paction,
681 const enum ustate_prop prop);
682
683bool utype_is_consumed_by_action(const struct action *paction,
684 const struct unit_type *utype);
685
686bool utype_is_consumed_by_action_result(enum action_result result,
687 const struct unit_type *utype);
688
689bool utype_is_moved_to_tgt_by_action(const struct action *paction,
690 const struct unit_type *utype);
691
692bool utype_is_unmoved_by_action(const struct action *paction,
693 const struct unit_type *utype);
694
695bool utype_pays_for_regular_move_to_tgt(const struct action *paction,
696 const struct unit_type *utype);
697
698int utype_pays_mp_for_action_base(const struct action *paction,
699 const struct unit_type *putype);
700
701int utype_pays_mp_for_action_estimate(const struct civ_map *nmap,
702 const struct action *paction,
703 const struct unit_type *putype,
704 const struct player *act_player,
705 const struct tile *act_tile,
706 const struct tile *tgt_tile);
707
708/* Functions to operate on various flag and roles. */
709typedef bool (*role_unit_callback)(struct unit_type *ptype, void *data);
710
711void role_unit_precalcs(void);
712void role_unit_precalcs_free(void);
713int num_role_units(int role);
714struct unit_type *role_units_iterate(int role, role_unit_callback cb, void *data);
715struct unit_type *role_units_iterate_backwards(int role, role_unit_callback cb, void *data);
716struct unit_type *get_role_unit(int role, int role_index);
717struct unit_type *best_role_unit(const struct city *pcity, int role);
718struct unit_type *best_role_unit_for_player(const struct player *pplayer,
719 int role);
720struct unit_type *first_role_unit_for_player(const struct player *pplayer,
721 int role);
722bool role_units_translations(struct astring *astr, int flag, bool alts);
723
724/* General unit class routines */
726Unit_Class_id uclass_number(const struct unit_class *pclass);
727/* Optimised to be identical to uclass_number: the implementation
728 * unittype.c is also semantically correct. */
729#define uclass_index(_c_) (_c_)->item_number
730#ifndef uclass_index
731Unit_Class_id uclass_index(const struct unit_class *pclass);
732#endif /* uclass_index */
733
734struct unit_class *unit_class_get(const struct unit *punit);
736#define utype_class(_t_) (_t_)->uclass
737#ifndef utype_class
738struct unit_class *utype_class(const struct unit_type *punittype);
739#endif /* utype_class */
740
741struct unit_class *unit_class_by_rule_name(const char *s);
742
743const char *uclass_rule_name(const struct unit_class *pclass);
744const char *uclass_name_translation(const struct unit_class *pclass);
745
746bool unit_has_class_flag(const struct unit *punit, enum unit_class_flag_id flag);
747bool utype_has_class_flag(const struct unit_type *ptype,
748 enum unit_class_flag_id flag);
749
750/**************************************************************************
751 Return whether the given unit class has the flag.
752**************************************************************************/
753static inline bool uclass_has_flag(const struct unit_class *punitclass,
754 enum unit_class_flag_id flag)
755{
756 return BV_ISSET(punitclass->flags, flag);
757}
758
760void set_user_unit_class_flag_name(enum unit_class_flag_id id,
761 const char *name,
762 const char *helptxt);
763const char *unit_class_flag_helptxt(enum unit_class_flag_id id);
764
765/* Ancillary routines */
766int unit_build_shield_cost(const struct city *pcity, const struct unit *punit);
767int utype_build_shield_cost(const struct city *pcity,
768 const struct player *pplayer,
769 const struct unit_type *punittype);
770int utype_build_shield_cost_base(const struct unit_type *punittype);
771int unit_build_shield_cost_base(const struct unit *punit);
772
773int utype_buy_gold_cost(const struct city *pcity,
774 const struct unit_type *punittype,
775 int shields_in_stock);
776
777const struct veteran_system *
778 utype_veteran_system(const struct unit_type *punittype);
779int utype_veteran_levels(const struct unit_type *punittype);
780const struct veteran_level *
781 utype_veteran_level(const struct unit_type *punittype, int level);
782const char *utype_veteran_name_translation(const struct unit_type *punittype,
783 int level);
784bool utype_veteran_has_power_bonus(const struct unit_type *punittype);
785
786struct veteran_system *veteran_system_new(int count);
787void veteran_system_destroy(struct veteran_system *vsystem);
788void veteran_system_definition(struct veteran_system *vsystem, int level,
789 const char *vlist_name, int vlist_power,
790 int vlist_move, int vlist_raise,
791 int vlist_wraise);
792
793int unit_pop_value(const struct unit *punit);
794int utype_pop_value(const struct unit_type *punittype, const struct city *pcity);
795
796enum unit_move_type utype_move_type(const struct unit_type *punittype);
797void set_unit_move_type(struct unit_class *puclass);
798
799/* player related unit functions */
800int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer,
801 Output_type_id otype);
802int utype_happy_cost(const struct unit_type *ut, const struct player *pplayer);
803
804const struct unit_type *can_upgrade_unittype(const struct player *pplayer,
805 const struct unit_type *punittype);
806int unit_upgrade_price(const struct player *pplayer,
807 const struct unit_type *from,
808 const struct unit_type *to);
809
810bool utype_player_already_has_this(const struct player *pplayer,
811 const struct unit_type *putype);
812bool utype_player_already_has_this_unique(const struct player *pplayer,
813 const struct unit_type *putype);
814
815bool can_player_build_unit_direct(const struct player *p,
816 const struct unit_type *punittype);
817bool can_player_build_unit_later(const struct player *p,
818 const struct unit_type *punittype);
819bool can_player_build_unit_now(const struct player *p,
820 const struct unit_type *punittype);
821
822#define utype_fuel(ptype) (ptype)->fuel
823
824bool utype_is_cityfounder(const struct unit_type *utype);
825
826bool uclass_flag_is_in_use(enum unit_class_flag_id ucflag);
827bool utype_flag_is_in_use(enum unit_type_flag_id uflag);
828
829/* Initialization and iteration */
830void unit_types_init(void);
831void unit_types_free(void);
832void unit_type_flags_free(void);
833void unit_class_flags_free(void);
834
835struct unit_type *unit_type_array_first(void);
836const struct unit_type *unit_type_array_last(void);
837
838#define unit_type_iterate(_p) \
839{ \
840 struct unit_type *_p = unit_type_array_first(); \
841 if (NULL != _p) { \
842 const struct unit_type *_end_##_p = unit_type_array_last(); \
843 for (; _p <= _end_##_p; _p++) {
844
845#define unit_type_iterate_end \
846 } \
847 } \
848}
849
850#define unit_type_re_active_iterate(_p) \
851 unit_type_iterate(_p) { \
852 if (!_p->ruledit_disabled) {
853
854#define unit_type_re_active_iterate_end \
855 } \
856 } unit_type_iterate_end;
857
858
859void *utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai);
860void utype_set_ai_data(struct unit_type *ptype, const struct ai_type *ai,
861 void *data);
862
863void unit_type_action_cache_set(struct unit_type *ptype);
865
866/* Initialization and iteration */
867void unit_classes_init(void);
868void unit_classes_free(void);
869
870void set_unit_class_caches(struct unit_class *pclass);
871void set_unit_type_caches(struct unit_type *ptype);
872
874const struct unit_class *unit_class_array_last(void);
875
876#define unit_class_iterate(_p) \
877{ \
878 struct unit_class *_p = unit_class_array_first(); \
879 if (NULL != _p) { \
880 const struct unit_class *_end_##_p = unit_class_array_last(); \
881 for (; _p <= _end_##_p; _p++) {
882
883#define unit_class_iterate_end \
884 } \
885 } \
886}
887
888#define unit_class_re_active_iterate(_p) \
889 unit_class_iterate(_p) { \
890 if (!_p->ruledit_disabled) {
891
892#define unit_class_re_active_iterate_end \
893 } \
894 } unit_class_iterate_end;
895
896#define SPECLIST_TAG unit_class
897#define SPECLIST_TYPE struct unit_class
898#include "speclist.h"
899
900#define unit_class_list_iterate(uclass_list, pclass) \
901 TYPED_LIST_ITERATE(struct unit_class, uclass_list, pclass)
902#define unit_class_list_iterate_end LIST_ITERATE_END
903
904#define SPECLIST_TAG unit_type
905#define SPECLIST_TYPE struct unit_type
906#include "speclist.h"
907
908#define unit_type_list_iterate(utype_list, ptype) \
909 TYPED_LIST_ITERATE(struct unit_type, utype_list, ptype)
910#define unit_type_list_iterate_end LIST_ITERATE_END
911
912#ifdef __cplusplus
913}
914#endif /* __cplusplus */
915
916#endif /* FC__UNITTYPE_H */
#define BV_DEFINE(name, bits)
Definition bitvector.h:132
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
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
int Unit_Class_id
Definition fc_types.h:388
int action_id
Definition fc_types.h:359
#define MAX_LEN_NAME
Definition fc_types.h:66
int Unit_type_id
Definition fc_types.h:352
@ O_LAST
Definition fc_types.h:91
#define UCL_LAST
Definition fc_types.h:387
enum output_type_id Output_type_id
Definition fc_types.h:348
const char * name
Definition inputfile.c:127
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:235
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
Definition ai.h:50
Definition city.h:309
enum unit_type_flag_id flag
Definition unittype.h:448
enum combat_bonus_type type
Definition unittype.h:449
Definition tile.h:49
Unit_Class_id item_number
Definition unittype.h:137
int hp_loss_pct
Definition unittype.h:142
enum unit_move_type move_type
Definition unittype.h:140
int non_native_def_pct
Definition unittype.h:143
enum move_level sea_move
Definition unittype.h:150
struct unit_class_list * subset_movers
Definition unittype.h:160
struct unit_class::@85 cache
struct extra_type_list * refuel_extras
Definition unittype.h:155
struct extra_type_list * native_tile_extras
Definition unittype.h:156
int min_speed
Definition unittype.h:141
enum hut_behavior hut_behavior
Definition unittype.h:165
struct extra_type_list * native_bases
Definition unittype.h:157
struct extra_type_list * bonus_roads
Definition unittype.h:158
struct unit_class::@86 rscompat_cache_from_3_0
int ferry_types
Definition unittype.h:151
struct name_translation name
Definition unittype.h:138
struct strvec * helptext
Definition unittype.h:146
bv_unit_class_flags flags
Definition unittype.h:144
bool ruledit_disabled
Definition unittype.h:139
struct extra_type_list * hiding_extras
Definition unittype.h:159
enum move_level land_move
Definition unittype.h:149
struct unit_class::@84 adv
int transport_capacity
Definition unittype.h:504
int max_defense_mp_bonus_pct
Definition unittype.h:560
struct unit_type::@87 adv
struct unit_class * uclass
Definition unittype.h:537
struct unit_type::@89 rscompat_cache
int pop_cost
Definition unittype.h:493
void * ais[FREECIV_AI_MOD_LAST]
Definition unittype.h:575
struct requirement_vector build_reqs
Definition unittype.h:501
Unit_type_id item_number
Definition unittype.h:482
int defense_strength
Definition unittype.h:496
bv_unit_classes cargo
Definition unittype.h:539
int firepower
Definition unittype.h:506
int paratroopers_range
Definition unittype.h:522
char graphic_alt[MAX_LEN_NAME]
Definition unittype.h:487
bool worker
Definition unittype.h:556
char sound_move_alt[MAX_LEN_NAME]
Definition unittype.h:489
int build_cost
Definition unittype.h:492
int convert_time
Definition unittype.h:512
int city_size
Definition unittype.h:531
struct veteran_system * veteran
Definition unittype.h:525
const struct unit_type * obsoleted_by
Definition unittype.h:510
int vision_radius_sq
Definition unittype.h:503
int move_rate
Definition unittype.h:497
bv_unit_classes targets
Definition unittype.h:542
enum vision_layer vlayer
Definition unittype.h:550
struct advance * require_advance
Definition unittype.h:500
struct strvec * helptext
Definition unittype.h:552
int paratroopers_mr_sub
Definition unittype.h:572
int bombard_rate
Definition unittype.h:528
char graphic_str[MAX_LEN_NAME]
Definition unittype.h:486
int city_slots
Definition unittype.h:533
int scramble_coeff[U_LAST]
Definition unittype.h:564
char sound_move[MAX_LEN_NAME]
Definition unittype.h:488
struct unit_type::@88 cache
int paratroopers_mr_req
Definition unittype.h:571
char sound_fight_alt[MAX_LEN_NAME]
Definition unittype.h:491
bool igwall
Definition unittype.h:555
struct name_translation name
Definition unittype.h:483
bv_unit_type_roles roles
Definition unittype.h:516
enum transp_def_type tp_defense
Definition unittype.h:535
int unknown_move_cost
Definition unittype.h:498
int upkeep[O_LAST]
Definition unittype.h:519
bv_unit_classes disembarks
Definition unittype.h:548
const struct unit_type * converted_to
Definition unittype.h:511
bv_unit_type_flags flags
Definition unittype.h:515
bool ruledit_disabled
Definition unittype.h:484
char sound_fight[MAX_LEN_NAME]
Definition unittype.h:490
bv_unit_classes embarks
Definition unittype.h:545
int attack_strength
Definition unittype.h:495
int happy_cost
Definition unittype.h:518
int defense_mp_bonuses_pct[U_LAST]
Definition unittype.h:563
struct combat_bonus_list * bonuses
Definition unittype.h:507
void * ruledit_dlg
Definition unittype.h:485
Definition unit.h:138
int base_raise_chance
Definition unittype.h:471
struct name_translation name
Definition unittype.h:468
int work_raise_chance
Definition unittype.h:472
struct veteran_level * definitions
Definition unittype.h:478
#define bool
Definition support.h:61
bool utype_may_act_tgt_city_tile(const struct unit_type *punit_type, const action_id act_id, const enum citytile_type prop, const bool is_there)
Definition unittype.c:1176
int utype_buy_gold_cost(const struct city *pcity, const struct unit_type *punittype, int shields_in_stock)
Definition unittype.c:1544
void unit_types_init(void)
Definition unittype.c:2394
bool can_unit_act_when_ustate_is(const struct unit_type *punit_type, const enum ustate_prop prop, const bool is_there)
Definition unittype.c:995
const char * uclass_name_translation(const struct unit_class *pclass)
Definition unittype.c:1684
void set_unit_class_caches(struct unit_class *pclass)
Definition unittype.c:2758
struct unit_type * best_role_unit(const struct city *pcity, int role)
Definition unittype.c:2319
struct unit_type * role_units_iterate(int role, role_unit_callback cb, void *data)
Definition unittype.c:2265
bool utype_action_takes_all_mp(const struct unit_type *putype, struct action *paction)
Definition unittype.c:1243
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Definition unittype.c:2646
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
bool utype_has_class_flag(const struct unit_type *ptype, enum unit_class_flag_id flag)
Definition unittype.c:1709
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:753
void user_unit_type_flags_init(void)
Definition unittype.c:1916
int utype_pays_mp_for_action_base(const struct action *paction, const struct unit_type *putype)
Definition unittype.c:1433
bool utype_player_already_has_this(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1993
bool utype_can_freely_unload(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
Definition unittype.c:294
const char * unit_class_flag_helptxt(enum unit_class_flag_id id)
Definition unittype.c:1906
bool utype_pays_for_regular_move_to_tgt(const struct action *paction, const struct unit_type *utype)
Definition unittype.c:1382
#define utype_class(_t_)
Definition unittype.h:736
struct unit_type * role_units_iterate_backwards(int role, role_unit_callback cb, void *data)
Definition unittype.c:2284
bool utype_can_remove_extra(const struct unit_type *putype, const struct extra_type *pextra)
Definition unittype.c:235
int unit_build_shield_cost(const struct city *pcity, const struct unit *punit)
Definition unittype.c:1528
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1621
bool unit_has_class_flag(const struct unit *punit, enum unit_class_flag_id flag)
Definition unittype.c:1701
#define L_FIRST
Definition unittype.h:333
bool utype_is_moved_to_tgt_by_action(const struct action *paction, const struct unit_type *utype)
Definition unittype.c:1301
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Definition unittype.c:132
enum unit_move_type utype_move_type(const struct unit_type *punittype)
Definition unittype.c:1603
struct unit_type * first_role_unit_for_player(const struct player *pplayer, int role)
Definition unittype.c:2370
hut_behavior
Definition unittype.h:129
@ HUT_FRIGHTEN
Definition unittype.h:129
@ HUT_NOTHING
Definition unittype.h:129
@ HUT_NORMAL
Definition unittype.h:129
Unit_Class_id uclass_count(void)
Definition unittype.c:2493
bool utype_is_cityfounder(const struct unit_type *utype)
Definition unittype.c:2967
const struct unit_class * unit_class_array_last(void)
Definition unittype.c:2482
struct unit_type * unit_type_by_rule_name(const char *name)
Definition unittype.c:1819
struct unit_type * get_role_unit(int role, int role_index)
Definition unittype.c:2301
struct unit_type * unit_type_array_first(void)
Definition unittype.c:58
void unit_class_flags_free(void)
Definition unittype.c:2459
bool uclass_flag_is_in_use(enum unit_class_flag_id ucflag)
Definition unittype.c:2983
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1639
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:193
void set_unit_move_type(struct unit_class *puclass)
Definition unittype.c:2926
move_level
Definition unittype.h:131
@ MOVE_PARTIAL
Definition unittype.h:131
@ MOVE_FULL
Definition unittype.h:131
@ MOVE_NONE
Definition unittype.h:131
void unit_type_action_cache_init(void)
Definition unittype.c:983
int utype_build_shield_cost_base(const struct unit_type *punittype)
Definition unittype.c:1520
void set_unit_type_caches(struct unit_type *ptype)
Definition unittype.c:2817
bool utype_may_act_move_frags(const struct unit_type *punit_type, const action_id act_id, const int move_fragments)
Definition unittype.c:1110
const struct veteran_system * utype_veteran_system(const struct unit_type *punittype)
Definition unittype.c:2615
bool utype_is_consumed_by_action_result(enum action_result result, const struct unit_type *utype)
Definition unittype.c:1281
int num_role_units(int role)
Definition unittype.c:2251
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1979
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604
void unit_types_free(void)
Definition unittype.c:2433
bool utype_may_act_at_all(const struct unit_type *putype)
Definition unittype.c:431
int unit_build_shield_cost_base(const struct unit *punit)
Definition unittype.c:1536
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1755
struct unit_type * best_role_unit_for_player(const struct player *pplayer, int role)
Definition unittype.c:2345
void role_unit_precalcs(void)
Definition unittype.c:2223
struct unit_class * uclass_by_number(const Unit_Class_id id)
Definition unittype.c:2524
bool utype_can_create_extra(const struct unit_type *putype, const struct extra_type *pextra)
Definition unittype.c:211
bool utype_can_freely_load(const struct unit_type *pcargotype, const struct unit_type *ptranstype)
Definition unittype.c:282
void veteran_system_definition(struct veteran_system *vsystem, int level, const char *vlist_name, int vlist_power, int vlist_move, int vlist_raise, int vlist_wraise)
Definition unittype.c:2719
#define L_LAST
Definition unittype.h:420
Unit_type_id utype_count(void)
Definition unittype.c:80
bool(* role_unit_callback)(struct unit_type *ptype, void *data)
Definition unittype.h:709
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2015
int utype_veteran_levels(const struct unit_type *punittype)
Definition unittype.c:2661
int utype_pays_mp_for_action_estimate(const struct civ_map *nmap, const struct action *paction, const struct unit_type *putype, const struct player *act_player, const struct tile *act_tile, const struct tile *tgt_tile)
Definition unittype.c:1445
bool utype_can_do_act_when_ustate(const struct unit_type *punit_type, const action_id act_id, const enum ustate_prop prop, const bool is_there)
Definition unittype.c:1007
void veteran_system_destroy(struct veteran_system *vsystem)
Definition unittype.c:2706
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1630
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2546
bool utype_can_do_action_result_when_ustate(const struct unit_type *putype, enum action_result result, const enum ustate_prop prop, const bool is_there)
Definition unittype.c:1027
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Definition unittype.c:459
bool unit_has_type_role(const struct unit *punit, enum unit_role_id role)
Definition unittype.c:202
bool utype_action_takes_all_mp_if_ustate_is(const struct unit_type *putype, struct action *paction, const enum ustate_prop prop)
Definition unittype.c:1259
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2631
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:184
bool unit_can_take_over(const struct unit *punit)
Definition unittype.c:258
void unit_classes_free(void)
Definition unittype.c:2576
void unit_type_action_cache_set(struct unit_type *ptype)
Definition unittype.c:967
const char * uclass_rule_name(const struct unit_class *pclass)
Definition unittype.c:1693
bool utype_is_consumed_by_action(const struct action *paction, const struct unit_type *utype)
Definition unittype.c:1271
void unit_type_flags_free(void)
Definition unittype.c:2447
#define U_LAST
Definition unittype.h:40
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
bool utype_veteran_has_power_bonus(const struct unit_type *punittype)
Definition unittype.c:2674
void user_unit_class_flags_init(void)
Definition unittype.c:1852
bool utype_can_act_if_tgt_diplrel_tile_other(const struct unit_type *punit_type, const action_id act_id, const int prop, const bool is_there)
Definition unittype.c:1088
struct unit_class * unit_class_by_rule_name(const char *s)
Definition unittype.c:1836
struct unit_type * unit_type_by_translated_name(const char *name)
Definition unittype.c:1804
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
Definition unittype.c:1969
const char * utype_values_string(const struct unit_type *punittype)
Definition unittype.c:1648
#define uclass_index(_c_)
Definition unittype.h:729
void * utype_ai_data(const struct unit_type *ptype, const struct ai_type *ai)
Definition unittype.c:2741
struct unit_class * unit_class_array_first(void)
Definition unittype.c:2471
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
void unit_classes_init(void)
Definition unittype.c:2554
bool utype_flag_is_in_use(enum unit_type_flag_id uflag)
Definition unittype.c:3002
#define L_MAX
Definition unittype.h:424
int utype_pop_value(const struct unit_type *punittype, const struct city *pcity)
Definition unittype.c:1580
bool utype_can_take_over(const struct unit_type *punittype)
Definition unittype.c:270
void utype_set_ai_data(struct unit_type *ptype, const struct ai_type *ai, void *data)
Definition unittype.c:2749
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1864
bool can_player_build_unit_later(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2150
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1490
int unit_pop_value(const struct unit *punit)
Definition unittype.c:1595
void role_unit_precalcs_free(void)
Definition unittype.c:2208
struct veteran_system * veteran_system_new(int count)
Definition unittype.c:2688
Unit_Class_id uclass_number(const struct unit_class *pclass)
Definition unittype.c:2515
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2131
bool utype_can_do_action_sub_result(const struct unit_type *putype, enum action_sub_result sub_result)
Definition unittype.c:480
bool utype_is_unmoved_by_action(const struct action *paction, const struct unit_type *utype)
Definition unittype.c:1340
bool utype_acts_hostile(const struct unit_type *putype)
Definition unittype.c:515
bool utype_can_do_act_if_tgt_citytile(const struct unit_type *punit_type, const action_id act_id, const enum citytile_type prop, const bool is_there)
Definition unittype.c:1048
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
bool can_utype_do_act_if_tgt_diplrel(const struct unit_type *punit_type, const action_id act_id, const int prop, const bool is_there)
Definition unittype.c:1069
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:443
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1928
int utype_happy_cost(const struct unit_type *ut, const struct player *pplayer)
Definition unittype.c:175
bool role_units_translations(struct astring *astr, int flag, bool alts)
Definition unittype.c:1720
const char * utype_values_translation(const struct unit_type *punittype)
Definition unittype.c:1669
const struct unit_type * unit_type_array_last(void)
Definition unittype.c:69
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1783