Freeciv-3.4
Loading...
Searching...
No Matches
nation.c
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
14/***********************************************************************
15 Functions for handling the nations.
16***********************************************************************/
17
18#ifdef HAVE_CONFIG_H
19#include <fc_config.h>
20#endif
21
22/* utility */
23#include "fcintl.h"
24#include "log.h"
25#include "mem.h"
26#include "support.h"
27
28/* common */
29#include "connection.h"
30#include "game.h"
31#include "government.h"
32#include "player.h"
33#include "rgbcolor.h"
34#include "tech.h"
35#include "traits.h"
36
37#include "nation.h"
38
39
40/* Nation set structure. */
45
46static struct nation_type *nations = nullptr;
47
48static int num_nation_sets;
52
53/****************************************************************************
54 Runs action if the nation is not valid.
55****************************************************************************/
56#ifdef FREECIV_DEBUG
57#define NATION_CHECK(pnation, action) \
58 fc_assert_action(nation_check(pnation, \
59 log_do_output_for_level(LOG_ERROR), \
60 __FILE__, __FUNCTION__, __FC_LINE__), \
61 action)
62
63/************************************************************************/
67static inline bool nation_check(const struct nation_type *pnation,
68 bool do_output, const char *file,
69 const char *function, int line)
70{
71 if (0 == nation_count()) {
72 if (do_output) {
74 "Function called before nations setup.");
75 }
76 return FALSE;
77 }
78 if (pnation == nullptr) {
79 if (do_output) {
81 "This function has nullptr nation argument.");
82 }
83 return FALSE;
84 }
85 if (pnation->item_number < 0
86 || pnation->item_number >= nation_count()
87 || &nations[nation_index(pnation)] != pnation) {
88 if (do_output) {
90 "This function has bad nation number %d (count %d).",
91 pnation->item_number, nation_count());
92 }
93 return FALSE;
94 }
95 return TRUE;
96}
97
98#else /* FREECIV_DEBUG */
99#define NATION_CHECK(pnation, action) /* Do Nothing. */
100#endif /* FREECIV_DEBUG */
101
102/************************************************************************/
107{
108 nations_iterate(pnation) {
109 if (0 == strcmp(nation_plural_translation(pnation), name)) {
110 return pnation;
111 }
113
114 return NO_NATION_SELECTED;
115}
116
117/************************************************************************/
122{
123 const char *qname = Qn_(name);
124
125 nations_iterate(pnation) {
126 if (0 == fc_strcasecmp(nation_rule_name(pnation), qname)) {
127 return pnation;
128 }
130
131 return NO_NATION_SELECTED;
132}
133
134/************************************************************************/
138const char *nation_rule_name(const struct nation_type *pnation)
139{
140 NATION_CHECK(pnation, return "");
141
142 return rule_name_get(&pnation->adjective);
143}
144
145/************************************************************************/
149const char *nation_adjective_translation(const struct nation_type *pnation)
150{
151 NATION_CHECK(pnation, return "");
152 return name_translation_get(&pnation->adjective);
153}
154
155/************************************************************************/
159const char *nation_plural_translation(const struct nation_type *pnation)
160{
161 NATION_CHECK(pnation, return "");
162 return name_translation_get(&pnation->noun_plural);
163}
164
165/************************************************************************/
169const char *nation_adjective_for_player(const struct player *pplayer)
170{
172}
173
174/************************************************************************/
178const char *nation_plural_for_player(const struct player *pplayer)
179{
181}
182
183/************************************************************************/
188bool is_nation_pickable(const struct nation_type *nation)
189{
191
192 return nation->client.is_pickable;
193}
194
195/************************************************************************/
201bool is_nation_playable(const struct nation_type *nation)
202{
203 NATION_CHECK(nation, return FALSE);
204 return nation->is_playable;
205}
206
207/************************************************************************/
212enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
213{
214 NATION_CHECK(nation, return NOT_A_BARBARIAN);
215 return nation->barb_type;
216}
217
218
219/****************************************************************************
220 Nation leader.
221****************************************************************************/
223 char *name;
225};
226
227/************************************************************************/
230const struct nation_leader_list *
231nation_leaders(const struct nation_type *pnation)
232{
233 NATION_CHECK(pnation, return nullptr);
234
235 return pnation->leaders;
236}
237
238/************************************************************************/
242 const char *name, bool is_male)
243{
244 struct nation_leader *pleader;
245
246 NATION_CHECK(pnation, return nullptr);
247
248 pleader = fc_malloc(sizeof(*pleader));
249 pleader->name = fc_strdup(name);
250 pleader->is_male = is_male;
251
253
254 return pleader;
255}
256
257/************************************************************************/
261{
262 free(pleader->name);
263 free(pleader);
264}
265
266/************************************************************************/
270struct nation_leader *
271nation_leader_by_name(const struct nation_type *pnation, const char *name)
272{
273 NATION_CHECK(pnation, return nullptr);
274
276 if (!fc_strcasecmp(name, pleader->name)) {
277 return pleader;
278 }
280
281 return nullptr;
282}
283
284/************************************************************************/
287const char *nation_leader_name(const struct nation_leader *pleader)
288{
289 return pleader->name;
290}
291
292/************************************************************************/
296{
297 return pleader->is_male;
298}
299
300/************************************************************************/
303const char *nation_legend_translation(const struct nation_type *pnation,
304 const char *legend)
305{
306 if (pnation->translation_domain == nullptr) {
307 return _(legend);
308 }
309
310 return DG_(pnation->translation_domain, legend);
311}
312
313/****************************************************************************
314 Nation default cities. The nation_city structure holds information about
315 a default choice for the city name. The 'name' field is, of course, just
316 the name for the city. The 'river' and 'terrain' fields are entries
317 recording whether the terrain is present near the city - we give higher
318 priority to cities which have matching terrain. In the case of a river we
319 only care if the city is _on_ the river, for other terrain features we
320 give the bonus if the city is close to the terrain.
321
322 This is controlled through the nation's ruleset like this:
323 cities = "Washington (ocean, river, swamp)", "New York (!mountains)"
324****************************************************************************/
330
331/************************************************************************/
334const struct nation_city_list *
335nation_cities(const struct nation_type *pnation)
336{
337 NATION_CHECK(pnation, return nullptr);
338
339 fc_assert_ret_val(is_server(), nullptr);
340
341 return pnation->server.default_cities;
342}
343
344/************************************************************************/
348 const char *name)
349{
350 struct nation_city *pncity;
351
352 NATION_CHECK(pnation, return nullptr);
353
354 fc_assert_ret_val(is_server(), nullptr);
355 fc_assert(NCP_NONE == 0);
356
357 pncity = fc_calloc(1, sizeof(*pncity)); /* Set NCP_NONE. */
358 pncity->name = fc_strdup(name);
359
361
362 return pncity;
363}
364
365/************************************************************************/
369{
370 free(pncity->name);
371 free(pncity);
372}
373
374/************************************************************************/
379{
380 switch (prefer) {
381 case NCP_DISLIKE:
382 return NCP_LIKE;
383 case NCP_NONE:
384 return NCP_NONE;
385 case NCP_LIKE:
386 return NCP_DISLIKE;
387 }
388
389 log_error("%s(): Wrong nation_city_preference variant (%d).",
390 __FUNCTION__, prefer);
391 return NCP_NONE;
392}
393
394/************************************************************************/
398 const struct terrain *pterrain,
399 enum nation_city_preference prefer)
400{
401 pncity->terrain[terrain_index(pterrain)] = prefer;
402}
403
404/************************************************************************/
408 enum nation_city_preference prefer)
409{
410 pncity->river = prefer;
411}
412
413/************************************************************************/
416const char *nation_city_name(const struct nation_city *pncity)
417{
418 return pncity->name;
419}
420
421/************************************************************************/
426 const struct terrain *pterrain)
427{
428 return pncity->terrain[terrain_index(pterrain)];
429}
430
431/************************************************************************/
436{
437 return pncity->river;
438}
439
440/************************************************************************/
443struct nation_type *nation_of_player(const struct player *pplayer)
444{
445 NATION_CHECK(pplayer->nation, return nullptr);
446
447 return pplayer->nation;
448}
449
450/************************************************************************/
453struct nation_type *nation_of_city(const struct city *pcity)
454{
456}
457
458/************************************************************************/
461struct nation_type *nation_of_unit(const struct unit *punit)
462{
464}
465
466/************************************************************************/
473{
475 return nullptr;
476 }
477
478 return nations + nation;
479}
480
481/************************************************************************/
485{
486 return pnation->item_number;
487}
488
489/************************************************************************/
496{
497 return pnation - nations;
498}
499
500/************************************************************************/
507
508/****************************************************************************
509 Nation iterator.
510****************************************************************************/
513 struct nation_type *p, *end;
514};
515#define NATION_ITER(p) ((struct nation_iter *)(p))
516
517/************************************************************************/
521{
522 return sizeof(struct nation_iter);
523}
524
525/************************************************************************/
528static void nation_iter_next(struct iterator *iter)
529{
530 NATION_ITER(iter)->p++;
531}
532
533/************************************************************************/
536static void *nation_iter_get(const struct iterator *iter)
537{
538 return NATION_ITER(iter)->p;
539}
540
541/************************************************************************/
544static bool nation_iter_valid(const struct iterator *iter)
545{
546 struct nation_iter *it = NATION_ITER(iter);
547 return it->p < it->end;
548}
549
550/************************************************************************/
554{
558 it->p = nations;
559
560 if (nations == nullptr) {
561 it->end = nullptr;
562 } else {
563 it->end = nations + nation_count();
564 }
565
566 return ITERATOR(it);
567}
568
569/************************************************************************/
572static void nation_init(struct nation_type *pnation)
573{
574 memset(pnation, 0, sizeof(*pnation));
575
576 pnation->item_number = pnation - nations;
577 pnation->translation_domain = nullptr;
579 pnation->sets = nation_set_list_new();
580 pnation->groups = nation_group_list_new();
581
582 if (is_server()) {
583 pnation->server.default_cities =
588 /* server.rgb starts out nullptr */
590 sizeof(*pnation->server.traits));
591 }
592}
593
594/************************************************************************/
597static void nation_free(struct nation_type *pnation)
598{
599 free(pnation->legend);
600 FC_FREE(pnation->translation_domain);
604
605 if (is_server()) {
610 rgbcolor_destroy(pnation->server.rgb);
611 FC_FREE(pnation->server.traits);
612 }
613
614 memset(pnation, 0, sizeof(*pnation));
615}
616
617/************************************************************************/
620void nations_alloc(int num)
621{
622 int i;
623
624 nations = fc_malloc(sizeof(*nations) * num);
626
627 for (i = 0; i < num; i++) {
629 }
630}
631
632/************************************************************************/
635void nations_free(void)
636{
637 int i;
638
639 if (nations == nullptr) {
640 return;
641 }
642
643 for (i = 0; i < game.control.nation_count; i++) {
645 }
646
647 free(nations);
648 nations = nullptr;
650}
651
652/************************************************************************/
658{
659 NATION_CHECK(pnation, return game.default_government);
660 if (pnation->init_government) {
661 return pnation->init_government;
662 } else {
664 }
665}
666
667/************************************************************************/
670struct nation_style *style_of_nation(const struct nation_type *pnation)
671{
672 NATION_CHECK(pnation, return 0);
673 return pnation->style;
674}
675
676/************************************************************************/
680const struct rgbcolor *nation_color(const struct nation_type *pnation)
681{
682 NATION_CHECK(pnation, return nullptr);
683
684 return pnation->server.rgb;
685}
686
687/************************************************************************/
691{
692 return num_nation_sets;
693}
694
695/************************************************************************/
699{
700 return pset - nation_sets;
701}
702
703/************************************************************************/
707{
708 return nation_set_index(pset);
709}
710
711/************************************************************************/
715 const char *set_rule_name,
716 const char *set_description)
717{
718 struct nation_set *pset;
719
721 log_error("More nation sets than reported (%d).",
723 return nullptr;
724 }
725
727 log_error("Too many nation sets (%d is the maximum).",
729 return nullptr;
730 }
731
732 /* Print the name and truncate if needed. */
734 names_set(&pset->name, nullptr, set_name, set_rule_name);
736 "Nation set description \"%s\" too long; truncating.");
737
738 if (nation_set_by_rule_name(rule_name_get(&pset->name)) != nullptr) {
739 log_error("Duplicate nation set name %s.", rule_name_get(&pset->name));
740
741 return nullptr;
742 }
743
744 if (nation_group_by_rule_name(rule_name_get(&pset->name)) != nullptr) {
745 log_error("Nation set name %s is already used for a group.",
746 rule_name_get(&pset->name));
747
748 return nullptr;
749 }
750
752
753 return pset;
754}
755
756/************************************************************************/
763{
764 /* Return valid pointer on client side even when the data of the
765 * group is not yet received. So compare against expected number
766 * of sets (game.control.num_nation_sets) and not
767 * what we have already set up (num_nation_sets) */
769 return nullptr;
770 }
771
772 return nation_sets + id;
773}
774
775/************************************************************************/
780{
781 const char *qname = Qn_(name);
782
784 if (0 == fc_strcasecmp(rule_name_get(&pset->name), qname)) {
785 return pset;
786 }
788
789 return nullptr;
790}
791
792/************************************************************************/
798{
799 return untranslated_name(&pset->name);
800}
801
802/************************************************************************/
806const char *nation_set_rule_name(const struct nation_set *pset)
807{
808 return rule_name_get(&pset->name);
809}
810
811/************************************************************************/
816{
817 return name_translation_get(&pset->name);
818}
819
820/************************************************************************/
824const char *nation_set_description(const struct nation_set *pset)
825{
826 return pset->description;
827}
828
829/************************************************************************/
832bool nation_is_in_set(const struct nation_type *pnation,
833 const struct nation_set *pset)
834{
836 if (aset == pset) {
837 return TRUE;
838 }
840
841 return FALSE;
842}
843
844/************************************************************************/
854{
855 struct nation_set *pset = nullptr;
856
857 if (strlen(setting) > 0) {
859 }
860 if (pset == nullptr) {
861 /* Either no nation set specified, or the specified one isn't in the
862 * current ruleset. Default to the first nation set specified by
863 * the ruleset. */
865 }
866 fc_assert(pset != nullptr);
867
868 return pset;
869}
870
871/****************************************************************************
872 Nation set iterator.
873****************************************************************************/
876 struct nation_set *p, *end;
877};
878#define NATION_SET_ITER(p) ((struct nation_set_iter *)(p))
879
880/************************************************************************/
884{
885 return sizeof(struct nation_set_iter);
886}
887
888/************************************************************************/
892{
893 NATION_SET_ITER(iter)->p++;
894}
895
896/************************************************************************/
899static void *nation_set_iter_get(const struct iterator *iter)
900{
901 return NATION_SET_ITER(iter)->p;
902}
903
904/************************************************************************/
907static bool nation_set_iter_valid(const struct iterator *iter)
908{
910 return it->p < it->end;
911}
912
913/************************************************************************/
925
926/************************************************************************/
930{
931 return num_nation_groups;
932}
933
934/************************************************************************/
938{
939 return pgroup - nation_groups;
940}
941
942/************************************************************************/
946{
948}
949
950/************************************************************************/
954{
955 struct nation_group *pgroup;
956
958 log_error("More nation groups than reported (%d).",
960 return nullptr;
961 }
962
964 log_error("Too many nation groups (%d is the maximum).",
966 return nullptr;
967 }
968
969 /* Print the name and truncate if needed. */
971 name_set(&pgroup->name, nullptr, name);
972 if (nation_group_by_rule_name(rule_name_get(&pgroup->name)) != nullptr) {
973 log_error("Duplicate nation group name %s.", rule_name_get(&pgroup->name));
974
975 return nullptr;
976 }
977
978 if (nation_set_by_rule_name(rule_name_get(&pgroup->name)) != nullptr) {
979 log_error("Nation group name %s is already used for a set.",
980 rule_name_get(&pgroup->name));
981
982 return nullptr;
983 }
984
985 if (is_server()) {
986 pgroup->server.match = 0;
987 }
989
990 return pgroup;
991}
992
993/************************************************************************/
1000{
1001 /* Return valid pointer on client side even when the data of the
1002 * group is not yet received. So compare against expected number
1003 * of groups (game.control.num_nation_groups) and not
1004 * what we have already set up (num_nation_groups) */
1006 return nullptr;
1007 }
1008
1009 return nation_groups + id;
1010}
1011
1012/************************************************************************/
1017{
1018 const char *qname = Qn_(name);
1019
1021 if (0 == fc_strcasecmp(rule_name_get(&pgroup->name), qname)) {
1022 return pgroup;
1023 }
1025
1026 return nullptr;
1027}
1028
1029/************************************************************************/
1033{
1034 pgroup->hidden = hidden;
1035}
1036
1037/************************************************************************/
1042{
1044
1045 pgroup->server.match = match;
1046}
1047
1048/************************************************************************/
1052{
1053 return pgroup->hidden;
1054}
1055
1056/************************************************************************/
1063{
1064 return untranslated_name(&pgroup->name);
1065}
1066
1067/************************************************************************/
1072{
1073 return rule_name_get(&pgroup->name);
1074}
1075
1076/************************************************************************/
1081{
1082 return name_translation_get(&pgroup->name);
1083}
1084
1085/************************************************************************/
1088bool nation_is_in_group(const struct nation_type *pnation,
1089 const struct nation_group *pgroup)
1090{
1092 if (agroup == pgroup) {
1093 return TRUE;
1094 }
1096 return FALSE;
1097}
1098
1099/****************************************************************************
1100 Nation group iterator.
1101****************************************************************************/
1106#define NATION_GROUP_ITER(p) ((struct nation_group_iter *)(p))
1107
1108/************************************************************************/
1112{
1113 return sizeof(struct nation_group_iter);
1114}
1115
1116/************************************************************************/
1120{
1121 NATION_GROUP_ITER(iter)->p++;
1122}
1123
1124/************************************************************************/
1127static void *nation_group_iter_get(const struct iterator *iter)
1128{
1129 return NATION_GROUP_ITER(iter)->p;
1130}
1131
1132/************************************************************************/
1135static bool nation_group_iter_valid(const struct iterator *iter)
1136{
1138 return it->p < it->end;
1139}
1140
1141/************************************************************************/
1153
1154/************************************************************************/
1161
1162/************************************************************************/
1169
1170/************************************************************************/
1175 const struct player *pplayer)
1176{
1177 return (can_conn_edit(pconn)
1179 && ((!pconn->observer && pconn->playing == pplayer)
1180 || pconn->access_level >= ALLOW_CTRL)));
1181}
1182
1183/************************************************************************/
1194 const struct nation_type *pnation2,
1195 bool ignore_conflicts)
1196{
1197 bool in_conflict = FALSE;
1198 int sum = 0;
1199
1201 NATION_CHECK(pnation1, return -1);
1202 NATION_CHECK(pnation2, return -1);
1203
1204 if (!ignore_conflicts) {
1205 nation_list_iterate(pnation1->server.conflicts_with, pnation0) {
1206 if (pnation0 == pnation2) {
1207 in_conflict = TRUE;
1208 sum = 1; /* Be sure to return something negative. */
1209 break;
1210 }
1212
1213 if (!in_conflict) {
1214 nation_list_iterate(pnation2->server.conflicts_with, pnation0) {
1215 if (pnation0 == pnation1) {
1216 in_conflict = TRUE;
1217 sum = 1; /* Be sure to return something negative. */
1218 break;
1219 }
1221 }
1222 }
1223
1226 sum += pgroup->server.match;
1227 }
1229
1230 return (in_conflict ? -sum : sum);
1231}
#define city_owner(_pcity_)
Definition city.h:563
char * incite_cost
Definition comments.c:77
#define MAX_LEN_MSG
Definition conn_types.h:37
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:513
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
int int id
Definition editgui_g.h:28
static bool is_server(void)
#define MAX_NUM_NATION_SETS
Definition fc_types.h:58
int Nation_type_id
Definition fc_types.h:241
#define MAX_NUM_NATION_GROUPS
Definition fc_types.h:59
#define DG_(domain, String)
Definition fcintl.h:68
#define _(String)
Definition fcintl.h:67
#define Qn_(String)
Definition fcintl.h:89
struct civ_game game
Definition game.c:62
const char * name
Definition inputfile.c:127
#define ITERATOR(p)
Definition iterator.h:37
void do_log(const char *file, const char *function, int line, bool print_from_where, enum log_level level, const char *message,...)
Definition log.c:514
#define fc_assert_ret(condition)
Definition log.h:192
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
@ LOG_ERROR
Definition log.h:31
#define log_error(message,...)
Definition log.h:104
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
static void name_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name)
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
static const char * untranslated_name(const struct name_translation *ptrans)
static void names_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name, const char *rule_name)
void nation_group_set_match(struct nation_group *pgroup, int match)
Definition nation.c:1041
void nations_free(void)
Definition nation.c:635
const char * nation_city_name(const struct nation_city *pncity)
Definition nation.c:416
static void nation_city_destroy(struct nation_city *pncity)
Definition nation.c:368
const char * nation_group_untranslated_name(const struct nation_group *pgroup)
Definition nation.c:1062
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
struct nation_type * nation_by_translated_plural(const char *name)
Definition nation.c:106
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
int nation_group_index(const struct nation_group *pgroup)
Definition nation.c:937
static void nation_free(struct nation_type *pnation)
Definition nation.c:597
Nation_type_id nation_count(void)
Definition nation.c:503
static void * nation_iter_get(const struct iterator *iter)
Definition nation.c:536
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:484
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
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
static bool nation_iter_valid(const struct iterator *iter)
Definition nation.c:544
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:461
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:295
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
static void nation_iter_next(struct iterator *iter)
Definition nation.c:528
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Definition nation.c:714
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
static struct nation_set nation_sets[MAX_NUM_NATION_SETS]
Definition nation.c:49
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:472
int nation_set_index(const struct nation_set *pset)
Definition nation.c:698
struct nation_city * nation_city_new(struct nation_type *pnation, const char *name)
Definition nation.c:347
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain)
Definition nation.c:425
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:231
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:815
const char * nation_group_rule_name(const struct nation_group *pgroup)
Definition nation.c:1071
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:443
const char * nation_set_untranslated_name(const struct nation_set *pset)
Definition nation.c:797
struct nation_type * nation_of_city(const struct city *pcity)
Definition nation.c:453
static void nation_group_iter_next(struct iterator *iter)
Definition nation.c:1119
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:201
static struct nation_group nation_groups[MAX_NUM_NATION_GROUPS]
Definition nation.c:51
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
void nation_city_set_terrain_preference(struct nation_city *pncity, const struct terrain *pterrain, enum nation_city_preference prefer)
Definition nation.c:397
#define NATION_SET_ITER(p)
Definition nation.c:878
static int num_nation_sets
Definition nation.c:48
struct iterator * nation_group_iter_init(struct nation_group_iter *it)
Definition nation.c:1144
void nation_city_set_river_preference(struct nation_city *pncity, enum nation_city_preference prefer)
Definition nation.c:407
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1088
static void * nation_set_iter_get(const struct iterator *iter)
Definition nation.c:899
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:832
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:824
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1080
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Definition nation.c:435
int nation_set_count(void)
Definition nation.c:690
static int num_nation_groups
Definition nation.c:50
void nation_sets_groups_init(void)
Definition nation.c:1157
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
static void nation_leader_destroy(struct nation_leader *pleader)
Definition nation.c:260
#define NATION_GROUP_ITER(p)
Definition nation.c:1106
static void nation_set_iter_next(struct iterator *iter)
Definition nation.c:891
static bool nation_set_iter_valid(const struct iterator *iter)
Definition nation.c:907
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
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1051
static struct nation_type * nations
Definition nation.c:46
bool can_conn_edit_players_nation(const struct connection *pconn, const struct player *pplayer)
Definition nation.c:1174
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:853
Nation_type_id nation_index(const struct nation_type *pnation)
Definition nation.c:495
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:287
#define NATION_ITER(p)
Definition nation.c:515
static bool nation_group_iter_valid(const struct iterator *iter)
Definition nation.c:1135
static void * nation_group_iter_get(const struct iterator *iter)
Definition nation.c:1127
int nation_group_count(void)
Definition nation.c:929
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Definition nation.c:241
#define NATION_CHECK(pnation, action)
Definition nation.c:99
void nation_group_set_hidden(struct nation_group *pgroup, bool hidden)
Definition nation.c:1032
static void nation_init(struct nation_type *pnation)
Definition nation.c:572
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
size_t nation_iter_sizeof(void)
Definition nation.c:520
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
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_list_iterate(nationlist, pnation)
Definition nation.h:84
#define nation_sets_iterate_end
Definition nation.h:333
#define nation_set_list_iterate_end
Definition nation.h:68
#define nation_group_list_iterate(grouplist, pgroup)
Definition nation.h:75
#define nation_sets_iterate(NAME_pset)
Definition nation.h:329
#define nations_iterate_end
Definition nation.h:364
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
#define nation_list_iterate_end
Definition nation.h:86
#define nations_iterate(NAME_pnation)
Definition nation.h:361
#define nation_leader_list_iterate_end
Definition nation.h:59
#define nation_group_list_iterate_end
Definition nation.h:77
#define nation_set_list_iterate(setlist, pset)
Definition nation.h:66
#define nation_groups_iterate(NAME_pgroup)
Definition nation.h:339
#define nation_groups_iterate_end
Definition nation.h:343
#define NO_NATION_SELECTED
Definition nation.h:30
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:74
#define sz_loud_strlcpy(buffer, str, errmsg)
Definition shared.h:158
Definition city.h:318
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
struct government * default_government
Definition game.h:93
bool(* valid)(const struct iterator *it)
Definition iterator.h:34
void *(* get)(const struct iterator *it)
Definition iterator.h:33
void(* next)(struct iterator *it)
Definition iterator.h:32
enum nation_city_preference river
Definition nation.c:327
char * name
Definition nation.c:326
struct iterator vtable
Definition nation.c:1103
struct nation_group * p
Definition nation.c:1104
struct nation_group * end
Definition nation.c:1104
bool hidden
Definition nation.h:171
struct iterator vtable
Definition nation.c:512
struct nation_type * end
Definition nation.c:513
struct nation_type * p
Definition nation.c:513
char * name
Definition nation.c:223
bool is_male
Definition nation.c:224
struct iterator vtable
Definition nation.c:875
struct nation_set * end
Definition nation.c:876
struct nation_set * p
Definition nation.c:876
struct name_translation name
Definition nation.c:42
char description[MAX_LEN_MSG]
Definition nation.c:43
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
struct name_translation adjective
Definition nation.h:101
struct rgbcolor * rgb
Definition nation.h:145
struct trait_limits * traits
Definition nation.h:147
struct nation_type::@54::@57 client
struct government * init_government
Definition nation.h:126
bool is_pickable
Definition nation.h:163
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
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
struct nation_type::@54::@56 server
struct nation_list * civilwar_nations
Definition nation.h:137
bool is_playable
Definition nation.h:109
struct nation_type * nation
Definition player.h:260
Definition unit.h:140
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
Terrain_type_id terrain_index(const struct terrain *pterrain)
Definition terrain.c:139
#define MAX_NUM_TERRAINS
Definition terrain.h:69
#define unit_owner(_pu)
Definition unit.h:406