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)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
13 #ifndef FC__GOVERNMENT_H
14 #define FC__GOVERNMENT_H
18 #endif /* __cplusplus */
25 #include "name_translation.h"
26 #include "requirements.h"
29 struct strvec
; /* Actually defined in "utility/string_vector.h". */
31 struct ruler_title
; /* Opaque type. */
33 /* 'struct ruler_title_hash' and related functions. */
34 #define SPECHASH_TAG ruler_title
35 #define SPECHASH_IKEY_TYPE struct nation_type *
36 #define SPECHASH_IDATA_TYPE struct ruler_title *
38 #define ruler_titles_iterate(ARG_hash, NAME_rule_title) \
39 TYPED_HASH_DATA_ITERATE(const struct ruler_title *, ARG_hash, \
41 #define ruler_titles_iterate_end HASH_DATA_ITERATE_END
43 /* G_LAST is a value guaranteed to be larger than any valid
44 * Government_type_id. It defines the maximum number of governments
45 * (so can also be used to size static arrays indexed by governments);
46 * it is sometimes used as a sentinel value (but not in the network
47 * protocol, which generally uses government_count()). */
50 /* This is struct government itself. All information about a form of
51 * government is contained inhere. -- SKi */
53 Government_type_id item_number
;
54 struct name_translation name
;
56 char graphic_str
[MAX_LEN_NAME
];
57 char graphic_alt
[MAX_LEN_NAME
];
58 struct requirement_vector reqs
;
59 struct ruler_title_hash
*ruler_titles
;
61 struct strvec
*helptext
;
63 /* AI cached data for this government. */
65 struct government
*better
; /* hint: a better government (or NULL) */
70 /* General government accessor functions. */
71 Government_type_id
government_count(void);
72 Government_type_id
government_index(const struct government
*pgovern
);
73 Government_type_id
government_number(const struct government
*pgovern
);
75 struct government
*government_by_number(const Government_type_id gov
);
76 struct government
*government_of_player(const struct player
*pplayer
);
77 struct government
*government_of_city(const struct city
*pcity
);
79 struct government
*government_by_rule_name(const char *name
);
80 struct government
*government_by_translated_name(const char *name
);
82 const char *government_rule_name(const struct government
*pgovern
);
83 const char *government_name_translation(const struct government
*pgovern
);
84 const char *government_name_for_player(const struct player
*pplayer
);
87 const struct ruler_title_hash
*
88 government_ruler_titles(const struct government
*pgovern
);
90 government_ruler_title_new(struct government
*pgovern
,
91 const struct nation_type
*pnation
,
92 const char *ruler_male_title
,
93 const char *ruler_female_title
);
95 const struct nation_type
*
96 ruler_title_nation(const struct ruler_title
*pruler_title
);
98 ruler_title_male_untranslated_name(const struct ruler_title
*pruler_title
);
100 ruler_title_female_untranslated_name(const struct ruler_title
*pruler_title
);
102 const char *ruler_title_for_player(const struct player
*pplayer
,
103 char *buf
, size_t buf_len
);
105 /* Ancillary routines */
106 bool can_change_to_government(struct player
*pplayer
,
107 const struct government
*pgovern
);
109 /* Initialization and iteration */
110 void governments_alloc(int num
);
111 void governments_free(void);
113 struct government_iter
;
114 size_t government_iter_sizeof(void);
115 struct iterator
*government_iter_init(struct government_iter
*it
);
117 /* Iterate over government types. */
118 #define governments_iterate(NAME_pgov) \
119 generic_iterate(struct government_iter, struct government *, \
120 NAME_pgov, government_iter_sizeof, government_iter_init)
121 #define governments_iterate_end generic_iterate_end
123 #define governments_active_iterate(_p) \
124 governments_iterate(_p) { \
127 #define governments_active_iterate_end \
129 } governments_iterate_end;
133 #endif /* __cplusplus */
135 bool untargeted_revolution_allowed(void);
137 #endif /* FC__GOVERNMENT_H */