Freeciv-3.4
Loading...
Searching...
No Matches
government.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__GOVERNMENT_H
14#define FC__GOVERNMENT_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "shared.h"
22
23/* common */
24#include "fc_types.h"
25#include "name_translation.h"
26#include "requirements.h"
27
28#define GOVF_LAST_USER_FLAG GOVF_USER_FLAG_8
29#define MAX_NUM_USER_GOVERNMENT_FLAGS (GOVF_LAST_USER_FLAG - GOVF_USER_FLAG_1 + 1)
30
31struct strvec; /* Actually defined in "utility/string_vector.h". */
32
33struct ruler_title; /* Opaque type. */
34
35/* 'struct ruler_title_hash' and related functions. */
36#define SPECHASH_TAG ruler_title
37#define SPECHASH_IKEY_TYPE struct nation_type *
38#define SPECHASH_IDATA_TYPE struct ruler_title *
39#include "spechash.h"
40#define ruler_titles_iterate(ARG_hash, NAME_rule_title) \
41 TYPED_HASH_DATA_ITERATE(const struct ruler_title *, ARG_hash, \
42 NAME_rule_title)
43#define ruler_titles_iterate_end HASH_DATA_ITERATE_END
44
45/* G_LAST is a value guaranteed to be larger than any valid
46 * Government_type_id. It defines the maximum number of governments
47 * (so can also be used to size static arrays indexed by governments);
48 * it is sometimes used as a sentinel value (but not in the network
49 * protocol, which generally uses government_count()). */
50#define G_LAST (127)
51
52/* This is struct government itself. All information about a form of
53 * government is contained inhere. -- SKi */
54struct government {
69
70 /* AI cached data for this government. */
71 struct {
72 struct government *better; /* Hint: A better government (or nullptr) */
73 } ai;
74};
75
76
77/* General government accessor functions. */
81
83struct government *government_of_player(const struct player *pplayer);
84struct government *government_of_city(const struct city *pcity);
85
86struct government *government_by_rule_name(const char *name);
88
89const char *government_rule_name(const struct government *pgovern);
90const char *government_name_translation(const struct government *pgovern);
91const char *government_name_for_player(const struct player *pplayer);
92
93/* Ruler titles. */
94const struct ruler_title_hash *
96struct ruler_title *
98 const struct nation_type *pnation,
99 const char *ruler_male_title,
100 const char *ruler_female_title);
101
102const struct nation_type *
104const char *
106const char *
108
109const char *ruler_title_for_player(const struct player *pplayer,
110 char *buf, size_t buf_len);
111const char *default_title_for_player(const struct player *pplayer,
112 char *buf, size_t buf_len);
113
114/* Ancillary routines */
115bool can_change_to_government(struct player *pplayer,
116 const struct government *pgovern);
117
118/* Initialization and iteration */
119void governments_alloc(int num);
120void governments_free(void);
121
122struct government_iter;
123size_t government_iter_sizeof(void);
125
126/* Iterate over government types. */
127#define governments_iterate(NAME_pgov) \
128 generic_iterate(struct government_iter, struct government *, \
129 NAME_pgov, government_iter_sizeof, government_iter_init)
130#define governments_iterate_end generic_iterate_end
131
132#define governments_re_active_iterate(_p) \
133 governments_iterate(_p) { \
134 if (!_p->ruledit_disabled) {
135
136#define governments_re_active_iterate_end \
137 } \
138 } governments_iterate_end;
139
141
142/* General government flag accessor routines */
143bool government_has_flag(const struct government *pgov,
144 enum gov_flag_id flag);
145
146void user_gov_flags_init(void);
147void gov_flags_free(void);
149 const char *name,
150 const char *helptxt);
151const char *gov_flag_helptxt(enum gov_flag_id id);
152
153#ifdef __cplusplus
154}
155#endif /* __cplusplus */
156
157#endif /* FC__GOVERNMENT_H */
char * incite_cost
Definition comments.c:76
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 Government_type_id
Definition fc_types.h:241
#define MAX_LEN_NAME
Definition fc_types.h:67
const char * government_name_translation(const struct government *pgovern)
Definition government.c:145
const char * default_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:428
bool government_has_flag(const struct government *pgov, enum gov_flag_id flag)
Definition government.c:583
void governments_free(void)
Definition government.c:547
const struct nation_type * ruler_title_nation(const struct ruler_title *pruler_title)
Definition government.c:367
bool untargeted_revolution_allowed(void)
Definition government.c:568
struct ruler_title * government_ruler_title_new(struct government *pgovern, const struct nation_type *pnation, const char *ruler_male_title, const char *ruler_female_title)
Definition government.c:327
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:393
struct iterator * government_iter_init(struct government_iter *it)
Definition government.c:485
const char * ruler_title_female_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:385
Government_type_id government_count(void)
Definition government.c:73
struct government * government_by_number(const Government_type_id gov)
Definition government.c:105
struct government * government_of_player(const struct player *pplayer)
Definition government.c:116
const char * government_name_for_player(const struct player *pplayer)
Definition government.c:156
const char * ruler_title_male_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:376
struct government * government_of_city(const struct city *pcity)
Definition government.c:125
const char * gov_flag_helptxt(enum gov_flag_id id)
Definition government.c:656
void governments_alloc(int num)
Definition government.c:531
void user_gov_flags_init(void)
Definition government.c:595
void gov_flags_free(void)
Definition government.c:607
Government_type_id government_number(const struct government *pgovern)
Definition government.c:93
const struct ruler_title_hash * government_ruler_titles(const struct government *pgovern)
Definition government.c:316
Government_type_id government_index(const struct government *pgovern)
Definition government.c:84
size_t government_iter_sizeof(void)
Definition government.c:452
const char * government_rule_name(const struct government *pgovern)
Definition government.c:135
struct government * government_by_translated_name(const char *name)
Definition government.c:42
bool can_change_to_government(struct player *pplayer, const struct government *pgovern)
Definition government.c:168
struct government * government_by_rule_name(const char *name)
Definition government.c:57
void set_user_gov_flag_name(enum gov_flag_id id, const char *name, const char *helptxt)
Definition government.c:619
const char * name
Definition inputfile.c:127
Definition city.h:318
struct strvec * helptext
Definition government.h:68
struct requirement_vector reqs
Definition government.h:64
void * ruledit_dlg
Definition government.h:58
char graphic_alt[MAX_LEN_NAME]
Definition government.h:60
bool ruledit_disabled
Definition government.h:57
struct government * better
Definition government.h:72
Government_type_id item_number
Definition government.h:55
int changed_to_times
Definition government.h:66
char sound_alt2[MAX_LEN_NAME]
Definition government.h:63
struct government::@43 ai
struct name_translation name
Definition government.h:56
char sound_str[MAX_LEN_NAME]
Definition government.h:61
char graphic_str[MAX_LEN_NAME]
Definition government.h:59
bv_gov_flags flags
Definition government.h:67
struct ruler_title_hash * ruler_titles
Definition government.h:65
char sound_alt[MAX_LEN_NAME]
Definition government.h:62
const struct nation_type * pnation
Definition government.c:191