Freeciv-3.3
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 = NULL;
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 (NULL == pnation) {
79 if (do_output) {
81 "This function has NULL 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 NULL);
233 return pnation->leaders;
234}
235
236/************************************************************************/
240 const char *name, bool is_male)
241{
242 struct nation_leader *pleader;
243
244 NATION_CHECK(pnation, return NULL);
245 pleader = fc_malloc(sizeof(*pleader));
246 pleader->name = fc_strdup(name);
247 pleader->is_male = is_male;
248
250 return pleader;
251}
252
253/************************************************************************/
257{
258 free(pleader->name);
259 free(pleader);
260}
261
262/************************************************************************/
266struct nation_leader *
267nation_leader_by_name(const struct nation_type *pnation, const char *name)
268{
269 NATION_CHECK(pnation, return NULL);
271 if (0 == fc_strcasecmp(name, pleader->name)) {
272 return pleader;
273 }
275 return NULL;
276}
277
278/************************************************************************/
281const char *nation_leader_name(const struct nation_leader *pleader)
282{
284 return pleader->name;
285}
286
287/************************************************************************/
291{
293 return pleader->is_male;
294}
295
296/************************************************************************/
299const char *nation_legend_translation(const struct nation_type *pnation,
300 const char *legend)
301{
302 if (pnation->translation_domain == NULL) {
303 return _(legend);
304 }
305
306 return DG_(pnation->translation_domain, legend);
307}
308
309/****************************************************************************
310 Nation default cities. The nation_city structure holds information about
311 a default choice for the city name. The 'name' field is, of course, just
312 the name for the city. The 'river' and 'terrain' fields are entries
313 recording whether the terrain is present near the city - we give higher
314 priority to cities which have matching terrain. In the case of a river we
315 only care if the city is _on_ the river, for other terrain features we
316 give the bonus if the city is close to the terrain.
317
318 This is controlled through the nation's ruleset like this:
319 cities = "Washington (ocean, river, swamp)", "New York (!mountains)"
320****************************************************************************/
326
327/************************************************************************/
330const struct nation_city_list *
331nation_cities(const struct nation_type *pnation)
332{
333 NATION_CHECK(pnation, return NULL);
335
336 return pnation->server.default_cities;
337}
338
339/************************************************************************/
343 const char *name)
344{
345 struct nation_city *pncity;
346
347 NATION_CHECK(pnation, return NULL);
349
350 fc_assert(0 == NCP_NONE);
351 pncity = fc_calloc(1, sizeof(*pncity)); /* Set NCP_NONE. */
352 pncity->name = fc_strdup(name);
353
355 return pncity;
356}
357
358/************************************************************************/
362{
363 free(pncity->name);
364 free(pncity);
365}
366
367/************************************************************************/
372{
373 switch (prefer) {
374 case NCP_DISLIKE:
375 return NCP_LIKE;
376 case NCP_NONE:
377 return NCP_NONE;
378 case NCP_LIKE:
379 return NCP_DISLIKE;
380 }
381
382 log_error("%s(): Wrong nation_city_preference variant (%d).",
383 __FUNCTION__, prefer);
384 return NCP_NONE;
385}
386
387/************************************************************************/
391 const struct terrain *pterrain,
392 enum nation_city_preference prefer)
393{
395 fc_assert_ret(NULL != pterrain);
396 pncity->terrain[terrain_index(pterrain)] = prefer;
397}
398
399/************************************************************************/
403 enum nation_city_preference prefer)
404{
406 pncity->river = prefer;
407}
408
409/************************************************************************/
412const char *nation_city_name(const struct nation_city *pncity)
413{
415 return pncity->name;
416}
417
418/************************************************************************/
423 const struct terrain *pterrain)
424{
426 fc_assert_ret_val(NULL != pterrain, NCP_DISLIKE);
427 return pncity->terrain[terrain_index(pterrain)];
428}
429
430/************************************************************************/
435{
437 return pncity->river;
438}
439
440
441/************************************************************************/
444struct nation_type *nation_of_player(const struct player *pplayer)
445{
446 fc_assert_ret_val(NULL != pplayer, NULL);
447 NATION_CHECK(pplayer->nation, return NULL);
448 return pplayer->nation;
449}
450
451/************************************************************************/
454struct nation_type *nation_of_city(const struct city *pcity)
455{
458}
459
460/************************************************************************/
463struct nation_type *nation_of_unit(const struct unit *punit)
464{
467}
468
469/************************************************************************/
476{
478 return NULL;
479 }
480 return nations + nation;
481}
482
483/************************************************************************/
487{
488 fc_assert_ret_val(NULL != pnation, -1);
489 return pnation->item_number;
490}
491
492/************************************************************************/
499{
500 fc_assert_ret_val(NULL != pnation, -1);
501 return pnation - nations;
502}
503
504/************************************************************************/
511
512/****************************************************************************
513 Nation iterator.
514****************************************************************************/
517 struct nation_type *p, *end;
518};
519#define NATION_ITER(p) ((struct nation_iter *)(p))
520
521/************************************************************************/
525{
526 return sizeof(struct nation_iter);
527}
528
529/************************************************************************/
532static void nation_iter_next(struct iterator *iter)
533{
534 NATION_ITER(iter)->p++;
535}
536
537/************************************************************************/
540static void *nation_iter_get(const struct iterator *iter)
541{
542 return NATION_ITER(iter)->p;
543}
544
545/************************************************************************/
548static bool nation_iter_valid(const struct iterator *iter)
549{
550 struct nation_iter *it = NATION_ITER(iter);
551 return it->p < it->end;
552}
553
554/************************************************************************/
558{
562 it->p = nations;
563 if (nations == NULL) {
564 it->end = NULL;
565 } else {
566 it->end = nations + nation_count();
567 }
568 return ITERATOR(it);
569}
570
571/************************************************************************/
574static void nation_init(struct nation_type *pnation)
575{
576 memset(pnation, 0, sizeof(*pnation));
577
578 pnation->item_number = pnation - nations;
579 pnation->translation_domain = NULL;
581 pnation->sets = nation_set_list_new();
582 pnation->groups = nation_group_list_new();
583
584 if (is_server()) {
585 pnation->server.default_cities =
590 /* server.rgb starts out NULL */
592 sizeof(*pnation->server.traits));
593 }
594}
595
596/************************************************************************/
599static void nation_free(struct nation_type *pnation)
600{
601 free(pnation->legend);
602 FC_FREE(pnation->translation_domain);
606
607 if (is_server()) {
612 rgbcolor_destroy(pnation->server.rgb);
613 FC_FREE(pnation->server.traits);
614 }
615
616 memset(pnation, 0, sizeof(*pnation));
617}
618
619/************************************************************************/
622void nations_alloc(int num)
623{
624 int i;
625
626 nations = fc_malloc(sizeof(*nations) * num);
628
629 for (i = 0; i < num; i++) {
631 }
632}
633
634/************************************************************************/
637void nations_free(void)
638{
639 int i;
640
641 if (NULL == nations) {
642 return;
643 }
644
645 for (i = 0; i < game.control.nation_count; i++) {
647 }
648
649 free(nations);
650 nations = NULL;
652}
653
654/************************************************************************/
660{
661 NATION_CHECK(pnation, return game.default_government);
662 if (pnation->init_government) {
663 return pnation->init_government;
664 } else {
666 }
667}
668
669/************************************************************************/
672struct nation_style *style_of_nation(const struct nation_type *pnation)
673{
674 NATION_CHECK(pnation, return 0);
675 return pnation->style;
676}
677
678/************************************************************************/
682const struct rgbcolor *nation_color(const struct nation_type *pnation)
683{
684 NATION_CHECK(pnation, return NULL);
685 return pnation->server.rgb;
686}
687
688/************************************************************************/
692{
693 return num_nation_sets;
694}
695
696/************************************************************************/
700{
702 return pset - nation_sets;
703}
704
705/************************************************************************/
709{
710 return nation_set_index(pset);
711}
712
713/************************************************************************/
717 const char *set_rule_name,
718 const char *set_description)
719{
720 struct nation_set *pset;
721
723 log_error("More nation sets than reported (%d).",
725 return NULL;
726 }
727
729 log_error("Too many nation sets (%d is the maximum).",
731 return NULL;
732 }
733
734 /* Print the name and truncate if needed. */
738 "Nation set description \"%s\" too long; truncating.");
739
741 log_error("Duplicate nation set name %s.", rule_name_get(&pset->name));
742 return NULL;
743 }
744
746 log_error("Nation set name %s is already used for a group.",
747 rule_name_get(&pset->name));
748 return NULL;
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 NULL;
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 NULL;
790}
791
792/************************************************************************/
798{
800 return untranslated_name(&pset->name);
801}
802
803/************************************************************************/
807const char *nation_set_rule_name(const struct nation_set *pset)
808{
810
811 return rule_name_get(&pset->name);
812}
813
814/************************************************************************/
819{
821 return name_translation_get(&pset->name);
822}
823
824/************************************************************************/
828const char *nation_set_description(const struct nation_set *pset)
829{
831 return pset->description;
832}
833
834/************************************************************************/
837bool nation_is_in_set(const struct nation_type *pnation,
838 const struct nation_set *pset)
839{
840 fc_assert_ret_val(NULL != pnation, FALSE);
841
843 if (aset == pset) {
844 return TRUE;
845 }
847 return FALSE;
848}
849
850/************************************************************************/
860{
861 struct nation_set *pset = NULL;
862
863 if (strlen(setting) > 0) {
865 }
866 if (pset == NULL) {
867 /* Either no nation set specified, or the specified one isn't in the
868 * current ruleset. Default to the first nation set specified by
869 * the ruleset. */
871 }
872 fc_assert(pset != NULL);
873
874 return pset;
875}
876
877/****************************************************************************
878 Nation set iterator.
879****************************************************************************/
882 struct nation_set *p, *end;
883};
884#define NATION_SET_ITER(p) ((struct nation_set_iter *)(p))
885
886/************************************************************************/
890{
891 return sizeof(struct nation_set_iter);
892}
893
894/************************************************************************/
898{
899 NATION_SET_ITER(iter)->p++;
900}
901
902/************************************************************************/
905static void *nation_set_iter_get(const struct iterator *iter)
906{
907 return NATION_SET_ITER(iter)->p;
908}
909
910/************************************************************************/
913static bool nation_set_iter_valid(const struct iterator *iter)
914{
916 return it->p < it->end;
917}
918
919/************************************************************************/
931
932/************************************************************************/
936{
937 return num_nation_groups;
938}
939
940/************************************************************************/
944{
946 return pgroup - nation_groups;
947}
948
949/************************************************************************/
953{
955}
956
957/************************************************************************/
961{
962 struct nation_group *pgroup;
963
965 log_error("More nation groups than reported (%d).",
967 return NULL;
968 }
969
971 log_error("Too many nation groups (%d is the maximum).",
973 return NULL;
974 }
975
976 /* Print the name and truncate if needed. */
978 name_set(&pgroup->name, NULL, name);
980 log_error("Duplicate nation group name %s.", rule_name_get(&pgroup->name));
981 return NULL;
982 }
983
985 log_error("Nation group name %s is already used for a set.",
986 rule_name_get(&pgroup->name));
987 return NULL;
988 }
989
990 if (is_server()) {
991 pgroup->server.match = 0;
992 }
994
995 return pgroup;
996}
997
998/************************************************************************/
1005{
1006 /* Return valid pointer on client side even when the data of the
1007 * group is not yet received. So compare against expected number
1008 * of groups (game.control.num_nation_groups) and not
1009 * what we have already set up (num_nation_groups) */
1011 return NULL;
1012 }
1013
1014 return nation_groups + id;
1015}
1016
1017/************************************************************************/
1022{
1023 const char *qname = Qn_(name);
1024
1026 if (0 == fc_strcasecmp(rule_name_get(&pgroup->name), qname)) {
1027 return pgroup;
1028 }
1030
1031 return NULL;
1032}
1033
1034/************************************************************************/
1038{
1040 pgroup->hidden = hidden;
1041}
1042
1043/************************************************************************/
1048{
1051 pgroup->server.match = match;
1052}
1053
1054/************************************************************************/
1058{
1060 return pgroup->hidden;
1061}
1062
1063/************************************************************************/
1070{
1072 return untranslated_name(&pgroup->name);
1073}
1074
1075/************************************************************************/
1080{
1082
1083 return rule_name_get(&pgroup->name);
1084}
1085
1086/************************************************************************/
1091{
1093 return name_translation_get(&pgroup->name);
1094}
1095
1096/************************************************************************/
1099bool nation_is_in_group(const struct nation_type *pnation,
1100 const struct nation_group *pgroup)
1101{
1102 fc_assert_ret_val(NULL != pnation, FALSE);
1103
1105 if (agroup == pgroup) {
1106 return TRUE;
1107 }
1109 return FALSE;
1110}
1111
1112/****************************************************************************
1113 Nation group iterator.
1114****************************************************************************/
1119#define NATION_GROUP_ITER(p) ((struct nation_group_iter *)(p))
1120
1121/************************************************************************/
1125{
1126 return sizeof(struct nation_group_iter);
1127}
1128
1129/************************************************************************/
1133{
1134 NATION_GROUP_ITER(iter)->p++;
1135}
1136
1137/************************************************************************/
1140static void *nation_group_iter_get(const struct iterator *iter)
1141{
1142 return NATION_GROUP_ITER(iter)->p;
1143}
1144
1145/************************************************************************/
1148static bool nation_group_iter_valid(const struct iterator *iter)
1149{
1151 return it->p < it->end;
1152}
1153
1154/************************************************************************/
1166
1167/************************************************************************/
1174
1175/************************************************************************/
1182
1183/************************************************************************/
1188 const struct player *pplayer)
1189{
1190 return (can_conn_edit(pconn)
1192 && ((!pconn->observer && pconn->playing == pplayer)
1193 || pconn->access_level >= ALLOW_CTRL)));
1194}
1195
1196/************************************************************************/
1207 const struct nation_type *pnation2,
1208 bool ignore_conflicts)
1209{
1210 bool in_conflict = FALSE;
1211 int sum = 0;
1212
1214 NATION_CHECK(pnation1, return -1);
1215 NATION_CHECK(pnation2, return -1);
1216
1217 if (!ignore_conflicts) {
1218 nation_list_iterate(pnation1->server.conflicts_with, pnation0) {
1219 if (pnation0 == pnation2) {
1220 in_conflict = TRUE;
1221 sum = 1; /* Be sure to return something negative. */
1222 break;
1223 }
1225
1226 if (!in_conflict) {
1227 nation_list_iterate(pnation2->server.conflicts_with, pnation0) {
1228 if (pnation0 == pnation1) {
1229 in_conflict = TRUE;
1230 sum = 1; /* Be sure to return something negative. */
1231 break;
1232 }
1234 }
1235 }
1236
1239 sum += pgroup->server.match;
1240 }
1242
1243 return (in_conflict ? -sum : sum);
1244}
#define city_owner(_pcity_)
Definition city.h:560
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:511
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:57
int Nation_type_id
Definition fc_types.h:239
#define MAX_NUM_NATION_GROUPS
Definition fc_types.h:58
#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:61
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:1047
void nations_free(void)
Definition nation.c:637
const char * nation_city_name(const struct nation_city *pncity)
Definition nation.c:412
static void nation_city_destroy(struct nation_city *pncity)
Definition nation.c:361
const char * nation_group_untranslated_name(const struct nation_group *pgroup)
Definition nation.c:1069
const struct nation_city_list * nation_cities(const struct nation_type *pnation)
Definition nation.c:331
struct nation_group * nation_group_by_rule_name(const char *name)
Definition nation.c:1021
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:371
int nation_group_index(const struct nation_group *pgroup)
Definition nation.c:943
static void nation_free(struct nation_type *pnation)
Definition nation.c:599
Nation_type_id nation_count(void)
Definition nation.c:507
static void * nation_iter_get(const struct iterator *iter)
Definition nation.c:540
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:486
struct nation_group * nation_group_new(const char *name)
Definition nation.c:960
struct nation_leader * nation_leader_by_name(const struct nation_type *pnation, const char *name)
Definition nation.c:267
struct iterator * nation_set_iter_init(struct nation_set_iter *it)
Definition nation.c:922
int nations_match(const struct nation_type *pnation1, const struct nation_type *pnation2, bool ignore_conflicts)
Definition nation.c:1206
static bool nation_iter_valid(const struct iterator *iter)
Definition nation.c:548
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:463
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
size_t nation_set_iter_sizeof(void)
Definition nation.c:889
static void nation_iter_next(struct iterator *iter)
Definition nation.c:532
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Definition nation.c:716
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:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
struct nation_city * nation_city_new(struct nation_type *pnation, const char *name)
Definition nation.c:342
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain)
Definition nation.c:422
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:818
const char * nation_group_rule_name(const struct nation_group *pgroup)
Definition nation.c:1079
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
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:454
static void nation_group_iter_next(struct iterator *iter)
Definition nation.c:1132
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:557
void nation_sets_groups_free(void)
Definition nation.c:1178
int nation_set_number(const struct nation_set *pset)
Definition nation.c:708
const struct rgbcolor * nation_color(const struct nation_type *pnation)
Definition nation.c:682
void nation_city_set_terrain_preference(struct nation_city *pncity, const struct terrain *pterrain, enum nation_city_preference prefer)
Definition nation.c:390
#define NATION_SET_ITER(p)
Definition nation.c:884
static int num_nation_sets
Definition nation.c:48
struct iterator * nation_group_iter_init(struct nation_group_iter *it)
Definition nation.c:1157
void nation_city_set_river_preference(struct nation_city *pncity, enum nation_city_preference prefer)
Definition nation.c:402
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
static void * nation_set_iter_get(const struct iterator *iter)
Definition nation.c:905
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:837
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1090
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Definition nation.c:434
int nation_set_count(void)
Definition nation.c:691
static int num_nation_groups
Definition nation.c:50
void nation_sets_groups_init(void)
Definition nation.c:1170
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:1004
static void nation_leader_destroy(struct nation_leader *pleader)
Definition nation.c:256
#define NATION_GROUP_ITER(p)
Definition nation.c:1119
static void nation_set_iter_next(struct iterator *iter)
Definition nation.c:897
static bool nation_set_iter_valid(const struct iterator *iter)
Definition nation.c:913
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:1057
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:1187
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
Nation_type_id nation_index(const struct nation_type *pnation)
Definition nation.c:498
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
#define NATION_ITER(p)
Definition nation.c:519
static bool nation_group_iter_valid(const struct iterator *iter)
Definition nation.c:1148
static void * nation_group_iter_get(const struct iterator *iter)
Definition nation.c:1140
int nation_group_count(void)
Definition nation.c:935
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Definition nation.c:239
#define NATION_CHECK(pnation, action)
Definition nation.c:99
void nation_group_set_hidden(struct nation_group *pgroup, bool hidden)
Definition nation.c:1037
static void nation_init(struct nation_type *pnation)
Definition nation.c:574
void nations_alloc(int num)
Definition nation.c:622
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:524
int nation_group_number(const struct nation_group *pgroup)
Definition nation.c:952
size_t nation_group_iter_sizeof(void)
Definition nation.c:1124
struct government * init_government_of_nation(const struct nation_type *pnation)
Definition nation.c:659
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
const char * nation_legend_translation(const struct nation_type *pnation, const char *legend)
Definition nation.c:299
#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:305
#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:301
#define nations_iterate_end
Definition nation.h:336
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:333
#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:311
#define nation_groups_iterate_end
Definition nation.h:315
#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:317
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:323
char * name
Definition nation.c:322
struct iterator vtable
Definition nation.c:1116
struct nation_group * p
Definition nation.c:1117
struct nation_group * end
Definition nation.c:1117
bool hidden
Definition nation.h:169
struct iterator vtable
Definition nation.c:516
struct nation_type * end
Definition nation.c:517
struct nation_type * p
Definition nation.c:517
char * name
Definition nation.c:222
bool is_male
Definition nation.c:223
struct iterator vtable
Definition nation.c:881
struct nation_set * end
Definition nation.c:882
struct nation_set * p
Definition nation.c:882
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:140
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:136
struct nation_set_list * sets
Definition nation.h:113
struct name_translation adjective
Definition nation.h:101
struct rgbcolor * rgb
Definition nation.h:143
struct trait_limits * traits
Definition nation.h:145
struct nation_type::@54::@57 client
struct government * init_government
Definition nation.h:124
bool is_pickable
Definition nation.h:161
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:131
struct nation_type::@54::@56 server
struct nation_list * civilwar_nations
Definition nation.h:135
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:138
#define MAX_NUM_TERRAINS
Definition terrain.h:69
#define unit_owner(_pu)
Definition unit.h:403