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. */
83
85struct government *government_of_player(const struct player *pplayer)
87struct government *government_of_city(const struct city *pcity)
89
90struct government *government_by_rule_name(const char *name);
92
93const char *government_rule_name(const struct government *pgovern)
95const char *government_name_translation(const struct government *pgovern)
97const char *government_name_for_player(const struct player *pplayer);
98
99/* Ruler titles. */
100const struct ruler_title_hash *
103struct ruler_title *
105 const struct nation_type *pnation,
106 const char *ruler_male_title,
107 const char *ruler_female_title);
108
109const struct nation_type *
111const char *
113const char *
115
116const char *ruler_title_for_player(const struct player *pplayer,
117 char *buf, size_t buf_len)
119const char *default_title_for_player(const struct player *pplayer,
120 char *buf, size_t buf_len);
121
122/* Ancillary routines */
123bool can_change_to_government(struct player *pplayer,
124 const struct government *pgovern)
126
127/* Initialization and iteration */
128void governments_alloc(int num);
129void governments_free(void);
130
131struct government_iter;
132size_t government_iter_sizeof(void);
134
135/* Iterate over government types. */
136#define governments_iterate(NAME_pgov) \
137 generic_iterate(struct government_iter, struct government *, \
138 NAME_pgov, government_iter_sizeof, government_iter_init)
139#define governments_iterate_end generic_iterate_end
140
141#define governments_re_active_iterate(_p) \
142 governments_iterate(_p) { \
143 if (!_p->ruledit_disabled) {
144
145#define governments_re_active_iterate_end \
146 } \
147 } governments_iterate_end;
148
150
151/* General government flag accessor routines */
152bool government_has_flag(const struct government *pgov,
153 enum gov_flag_id flag);
154
155void user_gov_flags_init(void);
156void gov_flags_free(void);
158 const char *name,
159 const char *helptxt);
160const char *gov_flag_helptxt(enum gov_flag_id id);
161
162#ifdef __cplusplus
163}
164#endif /* __cplusplus */
165
166#endif /* FC__GOVERNMENT_H */
char * incite_cost
Definition comments.c:77
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:242
#define MAX_LEN_NAME
Definition fc_types.h:68
const char * default_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:422
bool government_has_flag(const struct government *pgov, enum gov_flag_id flag)
Definition government.c:578
const struct ruler_title_hash * government_ruler_titles(const struct government *pgovern) fc__attribute((nonnull(1)))
Definition government.c:312
void governments_free(void)
Definition government.c:542
Government_type_id government_index(const struct government *pgovern) fc__attribute((nonnull(1)))
Definition government.c:84
const struct nation_type * ruler_title_nation(const struct ruler_title *pruler_title)
Definition government.c:362
bool untargeted_revolution_allowed(void)
Definition government.c:563
bool can_change_to_government(struct player *pplayer, const struct government *pgovern) fc__attribute((nonnull(2)))
Definition government.c:166
struct government * government_of_player(const struct player *pplayer) fc__attribute((nonnull(1)))
Definition government.c:115
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:322
struct iterator * government_iter_init(struct government_iter *it)
Definition government.c:479
const char * ruler_title_female_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:380
Government_type_id government_count(void)
Definition government.c:73
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
const char * government_name_for_player(const struct player *pplayer)
Definition government.c:150
const char * ruler_title_male_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:371
Government_type_id government_number(const struct government *pgovern) fc__attribute((nonnull(1)))
Definition government.c:92
const char * gov_flag_helptxt(enum gov_flag_id id)
Definition government.c:651
const char * government_rule_name(const struct government *pgovern) fc__attribute((nonnull(1)))
Definition government.c:132
void governments_alloc(int num)
Definition government.c:525
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len) fc__attribute((nonnull(2)))
Definition government.c:388
void user_gov_flags_init(void)
Definition government.c:590
void gov_flags_free(void)
Definition government.c:602
size_t government_iter_sizeof(void)
Definition government.c:446
struct government * government_by_translated_name(const char *name)
Definition government.c:42
struct government * government_of_city(const struct city *pcity) fc__attribute((nonnull(1)))
Definition government.c:123
const char * government_name_translation(const struct government *pgovern) fc__attribute((nonnull(1)))
Definition government.c:141
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:614
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:187
#define fc__attribute(x)
Definition support.h:99