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

Freeciv-3.3

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