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 return nation->client.is_pickable;
192}
193
194/************************************************************************/
200bool is_nation_playable(const struct nation_type *nation)
201{
202 NATION_CHECK(nation, return FALSE);
203 return nation->is_playable;
204}
205
206/************************************************************************/
211enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
212{
213 NATION_CHECK(nation, return NOT_A_BARBARIAN);
214 return nation->barb_type;
215}
216
217
218/****************************************************************************
219 Nation leader.
220****************************************************************************/
222 char *name;
224};
225
226/************************************************************************/
229const struct nation_leader_list *
230nation_leaders(const struct nation_type *pnation)
231{
232 NATION_CHECK(pnation, return nullptr);
233
234 return pnation->leaders;
235}
236
237/************************************************************************/
241 const char *name, bool is_male)
242{
243 struct nation_leader *pleader;
244
245 NATION_CHECK(pnation, return nullptr);
246
247 pleader = fc_malloc(sizeof(*pleader));
248 pleader->name = fc_strdup(name);
249 pleader->is_male = is_male;
250
252
253 return pleader;
254}
255
256/************************************************************************/
260{
261 free(pleader->name);
262 free(pleader);
263}
264
265/************************************************************************/
269struct nation_leader *
270nation_leader_by_name(const struct nation_type *pnation, const char *name)
271{
272 NATION_CHECK(pnation, return nullptr);
273
275 if (!fc_strcasecmp(name, pleader->name)) {
276 return pleader;
277 }
279
280 return nullptr;
281}
282
283/************************************************************************/
286const char *nation_leader_name(const struct nation_leader *pleader)
287{
288 fc_assert_ret_val(pleader != nullptr, nullptr);
289
290 return pleader->name;
291}
292
293/************************************************************************/
297{
298 fc_assert_ret_val(pleader != nullptr, TRUE);
299
300 return pleader->is_male;
301}
302
303/************************************************************************/
306const char *nation_legend_translation(const struct nation_type *pnation,
307 const char *legend)
308{
309 if (pnation->translation_domain == nullptr) {
310 return _(legend);
311 }
312
313 return DG_(pnation->translation_domain, legend);
314}
315
316/****************************************************************************
317 Nation default cities. The nation_city structure holds information about
318 a default choice for the city name. The 'name' field is, of course, just
319 the name for the city. The 'river' and 'terrain' fields are entries
320 recording whether the terrain is present near the city - we give higher
321 priority to cities which have matching terrain. In the case of a river we
322 only care if the city is _on_ the river, for other terrain features we
323 give the bonus if the city is close to the terrain.
324
325 This is controlled through the nation's ruleset like this:
326 cities = "Washington (ocean, river, swamp)", "New York (!mountains)"
327****************************************************************************/
333
334/************************************************************************/
337const struct nation_city_list *
338nation_cities(const struct nation_type *pnation)
339{
340 NATION_CHECK(pnation, return nullptr);
341
342 fc_assert_ret_val(is_server(), nullptr);
343
344 return pnation->server.default_cities;
345}
346
347/************************************************************************/
351 const char *name)
352{
353 struct nation_city *pncity;
354
355 NATION_CHECK(pnation, return nullptr);
356
357 fc_assert_ret_val(is_server(), nullptr);
358 fc_assert(NCP_NONE == 0);
359
360 pncity = fc_calloc(1, sizeof(*pncity)); /* Set NCP_NONE. */
361 pncity->name = fc_strdup(name);
362
364
365 return pncity;
366}
367
368/************************************************************************/
372{
373 free(pncity->name);
374 free(pncity);
375}
376
377/************************************************************************/
382{
383 switch (prefer) {
384 case NCP_DISLIKE:
385 return NCP_LIKE;
386 case NCP_NONE:
387 return NCP_NONE;
388 case NCP_LIKE:
389 return NCP_DISLIKE;
390 }
391
392 log_error("%s(): Wrong nation_city_preference variant (%d).",
393 __FUNCTION__, prefer);
394 return NCP_NONE;
395}
396
397/************************************************************************/
401 const struct terrain *pterrain,
402 enum nation_city_preference prefer)
403{
404 fc_assert_ret(pncity != nullptr);
405 fc_assert_ret(pterrain != nullptr);
406
407 pncity->terrain[terrain_index(pterrain)] = prefer;
408}
409
410/************************************************************************/
414 enum nation_city_preference prefer)
415{
416 fc_assert_ret(pncity != nullptr);
417
418 pncity->river = prefer;
419}
420
421/************************************************************************/
424const char *nation_city_name(const struct nation_city *pncity)
425{
426 fc_assert_ret_val(pncity != nullptr, nullptr);
427
428 return pncity->name;
429}
430
431/************************************************************************/
436 const struct terrain *pterrain)
437{
439 fc_assert_ret_val(pterrain != nullptr, NCP_DISLIKE);
440
441 return pncity->terrain[terrain_index(pterrain)];
442}
443
444/************************************************************************/
449{
451
452 return pncity->river;
453}
454
455/************************************************************************/
458struct nation_type *nation_of_player(const struct player *pplayer)
459{
460 fc_assert_ret_val(pplayer != nullptr, nullptr);
461
462 NATION_CHECK(pplayer->nation, return nullptr);
463
464 return pplayer->nation;
465}
466
467/************************************************************************/
470struct nation_type *nation_of_city(const struct city *pcity)
471{
472 fc_assert_ret_val(pcity != nullptr, nullptr);
473
475}
476
477/************************************************************************/
480struct nation_type *nation_of_unit(const struct unit *punit)
481{
482 fc_assert_ret_val(punit != nullptr, nullptr);
483
485}
486
487/************************************************************************/
494{
496 return nullptr;
497 }
498
499 return nations + nation;
500}
501
502/************************************************************************/
506{
507 fc_assert_ret_val(pnation != nullptr, -1);
508
509 return pnation->item_number;
510}
511
512/************************************************************************/
519{
520 fc_assert_ret_val(pnation != nullptr, -1);
521
522 return pnation - nations;
523}
524
525/************************************************************************/
532
533/****************************************************************************
534 Nation iterator.
535****************************************************************************/
538 struct nation_type *p, *end;
539};
540#define NATION_ITER(p) ((struct nation_iter *)(p))
541
542/************************************************************************/
546{
547 return sizeof(struct nation_iter);
548}
549
550/************************************************************************/
553static void nation_iter_next(struct iterator *iter)
554{
555 NATION_ITER(iter)->p++;
556}
557
558/************************************************************************/
561static void *nation_iter_get(const struct iterator *iter)
562{
563 return NATION_ITER(iter)->p;
564}
565
566/************************************************************************/
569static bool nation_iter_valid(const struct iterator *iter)
570{
571 struct nation_iter *it = NATION_ITER(iter);
572 return it->p < it->end;
573}
574
575/************************************************************************/
579{
583 it->p = nations;
584
585 if (nations == nullptr) {
586 it->end = nullptr;
587 } else {
588 it->end = nations + nation_count();
589 }
590
591 return ITERATOR(it);
592}
593
594/************************************************************************/
597static void nation_init(struct nation_type *pnation)
598{
599 memset(pnation, 0, sizeof(*pnation));
600
601 pnation->item_number = pnation - nations;
602 pnation->translation_domain = nullptr;
604 pnation->sets = nation_set_list_new();
605 pnation->groups = nation_group_list_new();
606
607 if (is_server()) {
608 pnation->server.default_cities =
613 /* server.rgb starts out nullptr */
615 sizeof(*pnation->server.traits));
616 }
617}
618
619/************************************************************************/
622static void nation_free(struct nation_type *pnation)
623{
624 free(pnation->legend);
625 FC_FREE(pnation->translation_domain);
629
630 if (is_server()) {
635 rgbcolor_destroy(pnation->server.rgb);
636 FC_FREE(pnation->server.traits);
637 }
638
639 memset(pnation, 0, sizeof(*pnation));
640}
641
642/************************************************************************/
645void nations_alloc(int num)
646{
647 int i;
648
649 nations = fc_malloc(sizeof(*nations) * num);
651
652 for (i = 0; i < num; i++) {
654 }
655}
656
657/************************************************************************/
660void nations_free(void)
661{
662 int i;
663
664 if (nations == nullptr) {
665 return;
666 }
667
668 for (i = 0; i < game.control.nation_count; i++) {
670 }
671
672 free(nations);
673 nations = nullptr;
675}
676
677/************************************************************************/
683{
684 NATION_CHECK(pnation, return game.default_government);
685 if (pnation->init_government) {
686 return pnation->init_government;
687 } else {
689 }
690}
691
692/************************************************************************/
695struct nation_style *style_of_nation(const struct nation_type *pnation)
696{
697 NATION_CHECK(pnation, return 0);
698 return pnation->style;
699}
700
701/************************************************************************/
705const struct rgbcolor *nation_color(const struct nation_type *pnation)
706{
707 NATION_CHECK(pnation, return nullptr);
708
709 return pnation->server.rgb;
710}
711
712/************************************************************************/
716{
717 return num_nation_sets;
718}
719
720/************************************************************************/
724{
725 fc_assert_ret_val(pset != nullptr, -1);
726
727 return pset - nation_sets;
728}
729
730/************************************************************************/
734{
735 return nation_set_index(pset);
736}
737
738/************************************************************************/
742 const char *set_rule_name,
743 const char *set_description)
744{
745 struct nation_set *pset;
746
748 log_error("More nation sets than reported (%d).",
750 return nullptr;
751 }
752
754 log_error("Too many nation sets (%d is the maximum).",
756 return nullptr;
757 }
758
759 /* Print the name and truncate if needed. */
761 names_set(&pset->name, nullptr, set_name, set_rule_name);
763 "Nation set description \"%s\" too long; truncating.");
764
765 if (nation_set_by_rule_name(rule_name_get(&pset->name)) != nullptr) {
766 log_error("Duplicate nation set name %s.", rule_name_get(&pset->name));
767
768 return nullptr;
769 }
770
771 if (nation_group_by_rule_name(rule_name_get(&pset->name)) != nullptr) {
772 log_error("Nation set name %s is already used for a group.",
773 rule_name_get(&pset->name));
774
775 return nullptr;
776 }
777
779
780 return pset;
781}
782
783/************************************************************************/
790{
791 /* Return valid pointer on client side even when the data of the
792 * group is not yet received. So compare against expected number
793 * of sets (game.control.num_nation_sets) and not
794 * what we have already set up (num_nation_sets) */
796 return nullptr;
797 }
798
799 return nation_sets + id;
800}
801
802/************************************************************************/
807{
808 const char *qname = Qn_(name);
809
811 if (0 == fc_strcasecmp(rule_name_get(&pset->name), qname)) {
812 return pset;
813 }
815
816 return nullptr;
817}
818
819/************************************************************************/
825{
826 fc_assert_ret_val(pset != nullptr, nullptr);
827
828 return untranslated_name(&pset->name);
829}
830
831/************************************************************************/
835const char *nation_set_rule_name(const struct nation_set *pset)
836{
837 fc_assert_ret_val(pset != nullptr, nullptr);
838
839 return rule_name_get(&pset->name);
840}
841
842/************************************************************************/
847{
848 fc_assert_ret_val(pset != nullptr, nullptr);
849
850 return name_translation_get(&pset->name);
851}
852
853/************************************************************************/
857const char *nation_set_description(const struct nation_set *pset)
858{
859 fc_assert_ret_val(pset != nullptr, nullptr);
860
861 return pset->description;
862}
863
864/************************************************************************/
867bool nation_is_in_set(const struct nation_type *pnation,
868 const struct nation_set *pset)
869{
870 fc_assert_ret_val(pnation != nullptr, FALSE);
871
873 if (aset == pset) {
874 return TRUE;
875 }
877
878 return FALSE;
879}
880
881/************************************************************************/
891{
892 struct nation_set *pset = nullptr;
893
894 if (strlen(setting) > 0) {
896 }
897 if (pset == nullptr) {
898 /* Either no nation set specified, or the specified one isn't in the
899 * current ruleset. Default to the first nation set specified by
900 * the ruleset. */
902 }
903 fc_assert(pset != nullptr);
904
905 return pset;
906}
907
908/****************************************************************************
909 Nation set iterator.
910****************************************************************************/
913 struct nation_set *p, *end;
914};
915#define NATION_SET_ITER(p) ((struct nation_set_iter *)(p))
916
917/************************************************************************/
921{
922 return sizeof(struct nation_set_iter);
923}
924
925/************************************************************************/
929{
930 NATION_SET_ITER(iter)->p++;
931}
932
933/************************************************************************/
936static void *nation_set_iter_get(const struct iterator *iter)
937{
938 return NATION_SET_ITER(iter)->p;
939}
940
941/************************************************************************/
944static bool nation_set_iter_valid(const struct iterator *iter)
945{
947 return it->p < it->end;
948}
949
950/************************************************************************/
962
963/************************************************************************/
967{
968 return num_nation_groups;
969}
970
971/************************************************************************/
975{
976 fc_assert_ret_val(pgroup != nullptr, -1);
977
978 return pgroup - nation_groups;
979}
980
981/************************************************************************/
985{
987}
988
989/************************************************************************/
993{
994 struct nation_group *pgroup;
995
997 log_error("More nation groups than reported (%d).",
999 return nullptr;
1000 }
1001
1003 log_error("Too many nation groups (%d is the maximum).",
1005 return nullptr;
1006 }
1007
1008 /* Print the name and truncate if needed. */
1010 name_set(&pgroup->name, nullptr, name);
1011 if (nation_group_by_rule_name(rule_name_get(&pgroup->name)) != nullptr) {
1012 log_error("Duplicate nation group name %s.", rule_name_get(&pgroup->name));
1013
1014 return nullptr;
1015 }
1016
1017 if (nation_set_by_rule_name(rule_name_get(&pgroup->name)) != nullptr) {
1018 log_error("Nation group name %s is already used for a set.",
1019 rule_name_get(&pgroup->name));
1020
1021 return nullptr;
1022 }
1023
1024 if (is_server()) {
1025 pgroup->server.match = 0;
1026 }
1028
1029 return pgroup;
1030}
1031
1032/************************************************************************/
1039{
1040 /* Return valid pointer on client side even when the data of the
1041 * group is not yet received. So compare against expected number
1042 * of groups (game.control.num_nation_groups) and not
1043 * what we have already set up (num_nation_groups) */
1045 return nullptr;
1046 }
1047
1048 return nation_groups + id;
1049}
1050
1051/************************************************************************/
1056{
1057 const char *qname = Qn_(name);
1058
1060 if (0 == fc_strcasecmp(rule_name_get(&pgroup->name), qname)) {
1061 return pgroup;
1062 }
1064
1065 return nullptr;
1066}
1067
1068/************************************************************************/
1072{
1073 fc_assert_ret(pgroup != nullptr);
1074
1075 pgroup->hidden = hidden;
1076}
1077
1078/************************************************************************/
1083{
1085 fc_assert_ret(pgroup != nullptr);
1086
1087 pgroup->server.match = match;
1088}
1089
1090/************************************************************************/
1094{
1095 fc_assert_ret_val(pgroup != nullptr, TRUE);
1096
1097 return pgroup->hidden;
1098}
1099
1100/************************************************************************/
1107{
1108 fc_assert_ret_val(pgroup != nullptr, nullptr);
1109
1110 return untranslated_name(&pgroup->name);
1111}
1112
1113/************************************************************************/
1118{
1119 fc_assert_ret_val(pgroup != nullptr, nullptr);
1120
1121 return rule_name_get(&pgroup->name);
1122}
1123
1124/************************************************************************/
1129{
1130 fc_assert_ret_val(pgroup != nullptr, nullptr);
1131
1132 return name_translation_get(&pgroup->name);
1133}
1134
1135/************************************************************************/
1138bool nation_is_in_group(const struct nation_type *pnation,
1139 const struct nation_group *pgroup)
1140{
1141 fc_assert_ret_val(pnation != nullptr, FALSE);
1142
1144 if (agroup == pgroup) {
1145 return TRUE;
1146 }
1148 return FALSE;
1149}
1150
1151/****************************************************************************
1152 Nation group iterator.
1153****************************************************************************/
1158#define NATION_GROUP_ITER(p) ((struct nation_group_iter *)(p))
1159
1160/************************************************************************/
1164{
1165 return sizeof(struct nation_group_iter);
1166}
1167
1168/************************************************************************/
1172{
1173 NATION_GROUP_ITER(iter)->p++;
1174}
1175
1176/************************************************************************/
1179static void *nation_group_iter_get(const struct iterator *iter)
1180{
1181 return NATION_GROUP_ITER(iter)->p;
1182}
1183
1184/************************************************************************/
1187static bool nation_group_iter_valid(const struct iterator *iter)
1188{
1190 return it->p < it->end;
1191}
1192
1193/************************************************************************/
1205
1206/************************************************************************/
1213
1214/************************************************************************/
1221
1222/************************************************************************/
1227 const struct player *pplayer)
1228{
1229 return (can_conn_edit(pconn)
1231 && ((!pconn->observer && pconn->playing == pplayer)
1232 || pconn->access_level >= ALLOW_CTRL)));
1233}
1234
1235/************************************************************************/
1246 const struct nation_type *pnation2,
1247 bool ignore_conflicts)
1248{
1249 bool in_conflict = FALSE;
1250 int sum = 0;
1251
1253 NATION_CHECK(pnation1, return -1);
1254 NATION_CHECK(pnation2, return -1);
1255
1256 if (!ignore_conflicts) {
1257 nation_list_iterate(pnation1->server.conflicts_with, pnation0) {
1258 if (pnation0 == pnation2) {
1259 in_conflict = TRUE;
1260 sum = 1; /* Be sure to return something negative. */
1261 break;
1262 }
1264
1265 if (!in_conflict) {
1266 nation_list_iterate(pnation2->server.conflicts_with, pnation0) {
1267 if (pnation0 == pnation1) {
1268 in_conflict = TRUE;
1269 sum = 1; /* Be sure to return something negative. */
1270 break;
1271 }
1273 }
1274 }
1275
1278 sum += pgroup->server.match;
1279 }
1281
1282 return (in_conflict ? -sum : sum);
1283}
#define city_owner(_pcity_)
Definition city.h:563
char * incite_cost
Definition comments.c:76
#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:240
#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:1082
void nations_free(void)
Definition nation.c:660
const char * nation_city_name(const struct nation_city *pncity)
Definition nation.c:424
static void nation_city_destroy(struct nation_city *pncity)
Definition nation.c:371
const char * nation_group_untranslated_name(const struct nation_group *pgroup)
Definition nation.c:1106
const struct nation_city_list * nation_cities(const struct nation_type *pnation)
Definition nation.c:338
struct nation_group * nation_group_by_rule_name(const char *name)
Definition nation.c:1055
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:381
int nation_group_index(const struct nation_group *pgroup)
Definition nation.c:974
static void nation_free(struct nation_type *pnation)
Definition nation.c:622
Nation_type_id nation_count(void)
Definition nation.c:528
static void * nation_iter_get(const struct iterator *iter)
Definition nation.c:561
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:505
struct nation_group * nation_group_new(const char *name)
Definition nation.c:992
struct nation_leader * nation_leader_by_name(const struct nation_type *pnation, const char *name)
Definition nation.c:270
struct iterator * nation_set_iter_init(struct nation_set_iter *it)
Definition nation.c:953
int nations_match(const struct nation_type *pnation1, const struct nation_type *pnation2, bool ignore_conflicts)
Definition nation.c:1245
static bool nation_iter_valid(const struct iterator *iter)
Definition nation.c:569
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:480
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:296
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
size_t nation_set_iter_sizeof(void)
Definition nation.c:920
static void nation_iter_next(struct iterator *iter)
Definition nation.c:553
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Definition nation.c:741
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:493
int nation_set_index(const struct nation_set *pset)
Definition nation.c:723
struct nation_city * nation_city_new(struct nation_type *pnation, const char *name)
Definition nation.c:350
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain)
Definition nation.c:435
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:230
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:846
const char * nation_group_rule_name(const struct nation_group *pgroup)
Definition nation.c:1117
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:458
const char * nation_set_untranslated_name(const struct nation_set *pset)
Definition nation.c:824
struct nation_type * nation_of_city(const struct city *pcity)
Definition nation.c:470
static void nation_group_iter_next(struct iterator *iter)
Definition nation.c:1171
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
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:578
void nation_sets_groups_free(void)
Definition nation.c:1217
int nation_set_number(const struct nation_set *pset)
Definition nation.c:733
const struct rgbcolor * nation_color(const struct nation_type *pnation)
Definition nation.c:705
void nation_city_set_terrain_preference(struct nation_city *pncity, const struct terrain *pterrain, enum nation_city_preference prefer)
Definition nation.c:400
#define NATION_SET_ITER(p)
Definition nation.c:915
static int num_nation_sets
Definition nation.c:48
struct iterator * nation_group_iter_init(struct nation_group_iter *it)
Definition nation.c:1196
void nation_city_set_river_preference(struct nation_city *pncity, enum nation_city_preference prefer)
Definition nation.c:413
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1138
static void * nation_set_iter_get(const struct iterator *iter)
Definition nation.c:936
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:867
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:857
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1128
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Definition nation.c:448
int nation_set_count(void)
Definition nation.c:715
static int num_nation_groups
Definition nation.c:50
void nation_sets_groups_init(void)
Definition nation.c:1209
struct nation_set * nation_set_by_number(int id)
Definition nation.c:789
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:1038
static void nation_leader_destroy(struct nation_leader *pleader)
Definition nation.c:259
#define NATION_GROUP_ITER(p)
Definition nation.c:1158
static void nation_set_iter_next(struct iterator *iter)
Definition nation.c:928
static bool nation_set_iter_valid(const struct iterator *iter)
Definition nation.c:944
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:806
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1093
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:1226
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:890
Nation_type_id nation_index(const struct nation_type *pnation)
Definition nation.c:518
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:286
#define NATION_ITER(p)
Definition nation.c:540
static bool nation_group_iter_valid(const struct iterator *iter)
Definition nation.c:1187
static void * nation_group_iter_get(const struct iterator *iter)
Definition nation.c:1179
int nation_group_count(void)
Definition nation.c:966
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:835
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Definition nation.c:240
#define NATION_CHECK(pnation, action)
Definition nation.c:99
void nation_group_set_hidden(struct nation_group *pgroup, bool hidden)
Definition nation.c:1071
static void nation_init(struct nation_type *pnation)
Definition nation.c:597
void nations_alloc(int num)
Definition nation.c:645
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Definition nation.c:211
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
size_t nation_iter_sizeof(void)
Definition nation.c:545
int nation_group_number(const struct nation_group *pgroup)
Definition nation.c:984
size_t nation_group_iter_sizeof(void)
Definition nation.c:1163
struct government * init_government_of_nation(const struct nation_type *pnation)
Definition nation.c:682
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:695
const char * nation_legend_translation(const struct nation_type *pnation, const char *legend)
Definition nation.c:306
#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:307
#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:303
#define nations_iterate_end
Definition nation.h:338
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:335
#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:313
#define nation_groups_iterate_end
Definition nation.h:317
#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:330
char * name
Definition nation.c:329
struct iterator vtable
Definition nation.c:1155
struct nation_group * p
Definition nation.c:1156
struct nation_group * end
Definition nation.c:1156
bool hidden
Definition nation.h:171
struct iterator vtable
Definition nation.c:537
struct nation_type * end
Definition nation.c:538
struct nation_type * p
Definition nation.c:538
char * name
Definition nation.c:222
bool is_male
Definition nation.c:223
struct iterator vtable
Definition nation.c:912
struct nation_set * end
Definition nation.c:913
struct nation_set * p
Definition nation.c:913
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:140
#define MAX_NUM_TERRAINS
Definition terrain.h:69
#define unit_owner(_pu)
Definition unit.h:406