Freeciv-3.4
Loading...
Searching...
No Matches
nation.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__NATION_H
14#define FC__NATION_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "iterator.h"
22
23/* common */
24#include "fc_types.h"
25#include "name_translation.h"
26#include "terrain.h" /* MAX_NUM_TERRAINS */
27
28struct rgbcolor;
29
30#define NO_NATION_SELECTED (nullptr)
31
32/* Changing this value will break network compatibility. */
33#define NATION_NONE -1
34#define NATION_ANY -2
35
36/* Nation city (server only). */
37struct nation_city;
38
44
45#define SPECLIST_TAG nation_city
46#define SPECLIST_TYPE struct nation_city
47#include "speclist.h"
48#define nation_city_list_iterate(citylist, pncity) \
49 TYPED_LIST_ITERATE(struct nation_city, citylist, pncity)
50#define nation_city_list_iterate_end LIST_ITERATE_END
51
52/* Nation leader. */
53struct nation_leader;
54#define SPECLIST_TAG nation_leader
55#define SPECLIST_TYPE struct nation_leader
56#include "speclist.h"
57#define nation_leader_list_iterate(leaderlist, pleader) \
58 TYPED_LIST_ITERATE(struct nation_leader, leaderlist, pleader)
59#define nation_leader_list_iterate_end LIST_ITERATE_END
60
61/* Nation set. */
62struct nation_set;
63#define SPECLIST_TAG nation_set
64#define SPECLIST_TYPE struct nation_set
65#include "speclist.h"
66#define nation_set_list_iterate(setlist, pset) \
67 TYPED_LIST_ITERATE(struct nation_set, setlist, pset)
68#define nation_set_list_iterate_end LIST_ITERATE_END
69
70/* Nation group. */
71struct nation_group;
72#define SPECLIST_TAG nation_group
73#define SPECLIST_TYPE struct nation_group
74#include "speclist.h"
75#define nation_group_list_iterate(grouplist, pgroup) \
76 TYPED_LIST_ITERATE(struct nation_group, grouplist, pgroup)
77#define nation_group_list_iterate_end LIST_ITERATE_END
78
79/* Nation list. */
80struct nation_type;
81#define SPECLIST_TAG nation
82#define SPECLIST_TYPE struct nation_type
83#include "speclist.h"
84#define nation_list_iterate(nationlist, pnation) \
85 TYPED_LIST_ITERATE(struct nation_type, nationlist, pnation)
86#define nation_list_iterate_end LIST_ITERATE_END
87
88/* Nation hash. */
89#define SPECHASH_TAG nation
90#define SPECHASH_IKEY_TYPE struct nation_type *
91#define SPECHASH_IDATA_TYPE void *
92#include "spechash.h"
93#define nation_hash_iterate(nationhash, pnation) \
94 TYPED_HASH_KEYS_ITERATE(struct nation_type *, nationhash, pnation)
95#define nation_hash_iterate_end HASH_KEYS_ITERATE_END
96
97/* Pointer values are allocated on load then freed in free_nations(). */
107 char *legend; /* may be empty */
108
110 enum barbarian_type barb_type;
111
112 /* Sets which this nation is assigned to */
114
115 /* Groups which this nation is assigned to */
117
118 struct player *player; /* Who's using the nation, or nullptr. */
119
120 /* Items given to this nation at game start. */
121 /* (Only used in the client for documentation purposes.) */
124
125 /* Use game default_government if nullptr */
128
129 union {
130 struct {
131 /* Only used in the server (./ai/ and ./server/). */
132
134
135 /* 'civilwar_nations' is a list of the nations that can fork from
136 * this one. 'parent_nations' is the inverse of this list. */
139
140 /* Nations which we don't want in the same game. For example,
141 * British and English. */
143
144 /* Nation's associated player color (nullptr if none). */
145 struct rgbcolor *rgb;
146
148
149 /* This nation has no start position in the current scenario. */
152
153 struct {
154 /* Only used at the client. */
155
156 /* Whether the client is allowed to try to pick the nation at game
157 * start. Reasons for restricting this include lack of start positions
158 * in a scenario, or a nation outside the current nationset. However,
159 * in some circumstances the server may decide to put a nation with this
160 * flag in the game anyway, so the client can't rely on its absence.
161 * (On the server this is calculated on the fly from other values.
162 * Use is_nation_pickable() to get the answer on client or server.) */
165 };
166};
167
168/* Nation group structure. */
171 bool hidden;
172
173 union {
174 struct {
175 /* Only used in the server (./server/). */
176
177 /* How much the AI will try to select a nation in the same group */
178 int match;
180
181 /* Add client side when needed */
182 };
183};
184
185/* General nation accessor functions. */
187Nation_type_id nation_index(const struct nation_type *pnation)
189Nation_type_id nation_number(const struct nation_type *pnation)
191
192struct nation_type *nation_by_number(const Nation_type_id nation);
193struct nation_type *nation_of_player(const struct player *pplayer)
195struct nation_type *nation_of_city(const struct city *pcity)
197struct nation_type *nation_of_unit(const struct unit *punit)
199
200struct nation_type *nation_by_rule_name(const char *name);
201struct nation_type *nation_by_translated_plural(const char *name);
202
203const char *nation_rule_name(const struct nation_type *pnation);
204
205const char *nation_adjective_translation(const struct nation_type *pnation);
206const char *nation_adjective_for_player(const struct player *pplayer);
207const char *nation_plural_translation(const struct nation_type *pnation);
208const char *nation_plural_for_player(const struct player *pplayer);
209
210struct government *init_government_of_nation(const struct nation_type *pnation);
211
212struct nation_style *style_of_nation(const struct nation_type *pnation);
213
214const struct rgbcolor *nation_color(const struct nation_type *pnation);
215
216/* Ancillary nation routines */
217bool is_nation_pickable(const struct nation_type *nation);
218bool is_nation_playable(const struct nation_type *nation);
219enum barbarian_type nation_barbarian_type(const struct nation_type *nation);
221 const struct player *pplayer);
222
223/* General nation leader accessor functions. */
224const struct nation_leader_list *
225nation_leaders(const struct nation_type *pnation);
226struct nation_leader *nation_leader_new(struct nation_type *pnation,
227 const char *name, bool is_male);
228struct nation_leader *
229nation_leader_by_name(const struct nation_type *pnation, const char *name);
230const char *nation_leader_name(const struct nation_leader *pleader)
234
235const char *nation_legend_translation(const struct nation_type *pnation,
236 const char *legend);
237
238/* General nation city accessor functions. */
239struct terrain;
240
241const struct nation_city_list *
242nation_cities(const struct nation_type *pnation);
243struct nation_city *nation_city_new(struct nation_type *pnation,
244 const char *name);
245
246const char *nation_city_name(const struct nation_city *pncity)
248
252 const struct terrain *pterrain,
253 enum nation_city_preference prefer)
254 fc__attribute((nonnull(1, 2)));
256 enum nation_city_preference prefer)
260 const struct terrain *pterrain)
261 fc__attribute((nonnull(1, 2)));
265
266/* General nation set accessor routines */
267int nation_set_count(void);
268int nation_set_index(const struct nation_set *pset)
270int nation_set_number(const struct nation_set *pset);
271
272struct nation_set *nation_set_new(const char *set_name,
273 const char *set_rule_name,
274 const char *set_description);
275struct nation_set *nation_set_by_number(int id);
276struct nation_set *nation_set_by_rule_name(const char *name);
277
278const char *nation_set_untranslated_name(const struct nation_set *pset)
280const char *nation_set_rule_name(const struct nation_set *pset)
282const char *nation_set_name_translation(const struct nation_set *pset)
284const char *nation_set_description(const struct nation_set *pset)
286
287bool nation_is_in_set(const struct nation_type *pnation,
288 const struct nation_set *pset)
290
292
293/* General nation group accessor routines */
294int nation_group_count(void);
295int nation_group_index(const struct nation_group *pgroup)
297int nation_group_number(const struct nation_group *pgroup);
298
299struct nation_group *nation_group_new(const char *name);
301struct nation_group *nation_group_by_rule_name(const char *name);
302
309
310const char *nation_group_untranslated_name(const struct nation_group *pgroup)
312const char *nation_group_rule_name(const struct nation_group *pgroup)
314const char *nation_group_name_translation(const struct nation_group *pgroup)
316
317bool nation_is_in_group(const struct nation_type *pnation,
318 const struct nation_group *pgroup)
320
321/* Initialization and iteration */
322void nation_sets_groups_init(void);
323void nation_sets_groups_free(void);
324
325struct nation_set_iter;
326size_t nation_set_iter_sizeof(void);
328
329#define nation_sets_iterate(NAME_pset) \
330 generic_iterate(struct nation_set_iter, struct nation_set *, \
331 NAME_pset, nation_set_iter_sizeof, \
332 nation_set_iter_init)
333#define nation_sets_iterate_end generic_iterate_end
334
335struct nation_group_iter;
336size_t nation_group_iter_sizeof(void);
338
339#define nation_groups_iterate(NAME_pgroup) \
340 generic_iterate(struct nation_group_iter, struct nation_group *, \
341 NAME_pgroup, nation_group_iter_sizeof, \
342 nation_group_iter_init)
343#define nation_groups_iterate_end generic_iterate_end
344
345/* Initialization and iteration */
346void nations_alloc(int num);
347void nations_free(void);
348
349int nations_match(const struct nation_type *pnation1,
350 const struct nation_type *pnation2,
351 bool ignore_conflicts);
352
353struct nation_iter;
354size_t nation_iter_sizeof(void);
355struct iterator *nation_iter_init(struct nation_iter *it);
356
357/* Iterate over nations. This iterates over _all_ nations, including
358 * unplayable ones (use is_nation_playable to filter if necessary).
359 * This does not take account of the current nationset! -- on the
360 * server, use allowed_nations_iterate() for that. */
361#define nations_iterate(NAME_pnation)\
362 generic_iterate(struct nation_iter, struct nation_type *,\
363 NAME_pnation, nation_iter_sizeof, nation_iter_init)
364#define nations_iterate_end generic_iterate_end
365
366/* Deletion of nations not supported */
367#define nations_re_active_iterate(_pnat_) \
368 nations_iterate(_pnat_)
369
370#define nations_re_active_iterate_end \
371 nations_iterate_end;
372
373#ifdef __cplusplus
374}
375#endif /* __cplusplus */
376
377#endif /* FC__NATION_H */
struct civclient client
char * incite_cost
Definition comments.c:77
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
int Nation_type_id
Definition fc_types.h:241
#define MAX_NUM_UNIT_LIST
Definition fc_types.h:45
#define MAX_LEN_NAME
Definition fc_types.h:68
#define MAX_NUM_TECH_LIST
Definition fc_types.h:44
const char * name
Definition inputfile.c:127
void nations_free(void)
Definition nation.c:635
int nation_set_index(const struct nation_set *pset) fc__attribute((nonnull(1)))
Definition nation.c:698
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain) fc__attribute((nonnull(1
const struct nation_city_list * nation_cities(const struct nation_type *pnation)
Definition nation.c:335
struct nation_group * nation_group_by_rule_name(const char *name)
Definition nation.c:1016
void void nation_city_set_river_preference(struct nation_city *pncity, enum nation_city_preference prefer) fc__attribute((nonnull(1)))
Definition nation.c:407
struct nation_type * nation_by_translated_plural(const char *name)
Definition nation.c:106
void nation_group_set_hidden(struct nation_group *pgroup, bool hidden) fc__attribute((nonnull(1)))
Definition nation.c:1032
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:138
enum nation_city_preference nation_city_preference_revert(enum nation_city_preference prefer)
Definition nation.c:378
Nation_type_id nation_count(void)
Definition nation.c:503
struct nation_group * nation_group_new(const char *name)
Definition nation.c:953
struct nation_leader * nation_leader_by_name(const struct nation_type *pnation, const char *name)
Definition nation.c:271
const char * nation_group_rule_name(const struct nation_group *pgroup) fc__attribute((nonnull(1)))
Definition nation.c:1071
const char * nation_group_untranslated_name(const struct nation_group *pgroup) fc__attribute((nonnull(1)))
Definition nation.c:1062
struct iterator * nation_set_iter_init(struct nation_set_iter *it)
Definition nation.c:916
int nations_match(const struct nation_type *pnation1, const struct nation_type *pnation2, bool ignore_conflicts)
Definition nation.c:1193
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
size_t nation_set_iter_sizeof(void)
Definition nation.c:883
void nation_group_set_match(struct nation_group *pgroup, int match) fc__attribute((nonnull(1)))
Definition nation.c:1041
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Definition nation.c:714
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup) fc__attribute((nonnull(1)))
Definition nation.c:1088
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:472
struct nation_city * nation_city_new(struct nation_type *pnation, const char *name)
Definition nation.c:347
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const char * nation_set_description(const struct nation_set *pset) fc__attribute((nonnull(1)))
Definition nation.c:824
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:231
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:201
struct iterator * nation_iter_init(struct nation_iter *it)
Definition nation.c:553
void nation_sets_groups_free(void)
Definition nation.c:1165
int nation_set_number(const struct nation_set *pset)
Definition nation.c:706
const struct rgbcolor * nation_color(const struct nation_type *pnation)
Definition nation.c:680
enum nation_city_preference enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity) fc__attribute((nonnull(1)))
Definition nation.c:435
struct iterator * nation_group_iter_init(struct nation_group_iter *it)
Definition nation.c:1144
nation_city_preference
Definition nation.h:39
@ NCP_NONE
Definition nation.h:41
@ NCP_DISLIKE
Definition nation.h:40
@ NCP_LIKE
Definition nation.h:42
struct nation_type * nation_of_city(const struct city *pcity) fc__attribute((nonnull(1)))
Definition nation.c:453
Nation_type_id nation_index(const struct nation_type *pnation) fc__attribute((nonnull(1)))
Definition nation.c:495
const char * nation_city_name(const struct nation_city *pncity) fc__attribute((nonnull(1)))
Definition nation.c:416
int nation_set_count(void)
Definition nation.c:690
void nation_sets_groups_init(void)
Definition nation.c:1157
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset) fc__attribute((nonnull(1)))
Definition nation.c:832
struct nation_type * nation_of_unit(const struct unit *punit) fc__attribute((nonnull(1)))
Definition nation.c:461
struct nation_set * nation_set_by_number(int id)
Definition nation.c:762
struct nation_type * nation_by_rule_name(const char *name)
Definition nation.c:121
struct nation_group * nation_group_by_number(int id)
Definition nation.c:999
int nation_group_index(const struct nation_group *pgroup) fc__attribute((nonnull(1)))
Definition nation.c:937
struct nation_type * nation_of_player(const struct player *pplayer) fc__attribute((nonnull(1)))
Definition nation.c:443
const char * nation_plural_translation(const struct nation_type *pnation)
Definition nation.c:159
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
const char * nation_leader_name(const struct nation_leader *pleader) fc__attribute((nonnull(1)))
Definition nation.c:287
void nation_city_set_terrain_preference(struct nation_city *pncity, const struct terrain *pterrain, enum nation_city_preference prefer) fc__attribute((nonnull(1
const char * nation_group_name_translation(const struct nation_group *pgroup) fc__attribute((nonnull(1)))
Definition nation.c:1080
const char * nation_set_untranslated_name(const struct nation_set *pset) fc__attribute((nonnull(1)))
Definition nation.c:797
bool can_conn_edit_players_nation(const struct connection *pconn, const struct player *pplayer)
Definition nation.c:1174
Nation_type_id nation_number(const struct nation_type *pnation) fc__attribute((nonnull(1)))
Definition nation.c:484
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:853
const char * nation_set_name_translation(const struct nation_set *pset) fc__attribute((nonnull(1)))
Definition nation.c:815
int nation_group_count(void)
Definition nation.c:929
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Definition nation.c:241
bool is_nation_group_hidden(struct nation_group *pgroup) fc__attribute((nonnull(1)))
Definition nation.c:1051
void nations_alloc(int num)
Definition nation.c:620
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Definition nation.c:212
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
bool nation_leader_is_male(const struct nation_leader *pleader) fc__attribute((nonnull(1)))
Definition nation.c:295
size_t nation_iter_sizeof(void)
Definition nation.c:520
const char * nation_set_rule_name(const struct nation_set *pset) fc__attribute((nonnull(1)))
Definition nation.c:806
int nation_group_number(const struct nation_group *pgroup)
Definition nation.c:945
size_t nation_group_iter_sizeof(void)
Definition nation.c:1111
struct government * init_government_of_nation(const struct nation_type *pnation)
Definition nation.c:657
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:670
const char * nation_legend_translation(const struct nation_type *pnation, const char *legend)
Definition nation.c:303
Definition city.h:318
struct name_translation name
Definition nation.h:170
bool hidden
Definition nation.h:171
bool is_male
Definition nation.c:224
int init_buildings[MAX_NUM_BUILDING_LIST]
Definition nation.h:123
struct nation_list * conflicts_with
Definition nation.h:142
struct nation_group_list * groups
Definition nation.h:116
struct name_translation noun_plural
Definition nation.h:102
struct nation_list * parent_nations
Definition nation.h:138
struct nation_set_list * sets
Definition nation.h:113
char flag_graphic_str[MAX_LEN_NAME]
Definition nation.h:103
struct name_translation adjective
Definition nation.h:101
struct rgbcolor * rgb
Definition nation.h:145
struct trait_limits * traits
Definition nation.h:147
char flag_graphic_alt[MAX_LEN_NAME]
Definition nation.h:104
struct government * init_government
Definition nation.h:126
bool is_pickable
Definition nation.h:163
struct unit_type * init_units[MAX_NUM_UNIT_LIST]
Definition nation.h:127
struct nation_leader_list * leaders
Definition nation.h:105
char * legend
Definition nation.h:107
Nation_type_id item_number
Definition nation.h:99
enum barbarian_type barb_type
Definition nation.h:110
bool no_startpos
Definition nation.h:150
char * translation_domain
Definition nation.h:100
struct nation_style * style
Definition nation.h:106
struct nation_city_list * default_cities
Definition nation.h:133
int init_techs[MAX_NUM_TECH_LIST]
Definition nation.h:122
struct nation_list * civilwar_nations
Definition nation.h:137
bool is_playable
Definition nation.h:109
struct player * player
Definition nation.h:118
Definition unit.h:140
#define fc__attribute(x)
Definition support.h:99