Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/government.h Source File

Freeciv-3.1

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
29struct strvec; /* Actually defined in "utility/string_vector.h". */
30
31struct ruler_title; /* Opaque type. */
32
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 *
37#include "spechash.h"
38#define ruler_titles_iterate(ARG_hash, NAME_rule_title) \
39 TYPED_HASH_DATA_ITERATE(const struct ruler_title *, ARG_hash, \
40 NAME_rule_title)
41#define ruler_titles_iterate_end HASH_DATA_ITERATE_END
42
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()). */
48#define G_LAST (127)
49
50/* This is struct government itself. All information about a form of
51 * government is contained inhere. -- SKi */
52 struct government {
53 Government_type_id item_number;
54 struct name_translation name;
55 bool ruledit_disabled;
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;
60 int changed_to_times;
61 struct strvec *helptext;
62
63 /* AI cached data for this government. */
64 struct {
65 struct government *better; /* hint: a better government (or NULL) */
66 } ai;
67};
68
69
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);
74
75struct government *government_by_number(const Government_type_id gov);
76struct government *government_of_player(const struct player *pplayer);
77struct government *government_of_city(const struct city *pcity);
78
79struct government *government_by_rule_name(const char *name);
80struct government *government_by_translated_name(const char *name);
81
82const char *government_rule_name(const struct government *pgovern);
83const char *government_name_translation(const struct government *pgovern);
84const char *government_name_for_player(const struct player *pplayer);
85
86/* Ruler titles. */
87const struct ruler_title_hash *
88 government_ruler_titles(const struct government *pgovern);
89struct ruler_title *
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);
94
95const struct nation_type *
96 ruler_title_nation(const struct ruler_title *pruler_title);
97const char *
98 ruler_title_male_untranslated_name(const struct ruler_title *pruler_title);
99const char *
100 ruler_title_female_untranslated_name(const struct ruler_title *pruler_title);
101
102const char *ruler_title_for_player(const struct player *pplayer,
103 char *buf, size_t buf_len);
104const char *default_title_for_player(const struct player *pplayer,
105 char *buf, size_t buf_len);
106
107/* Ancillary routines */
108bool can_change_to_government(struct player *pplayer,
109 const struct government *pgovern);
110
111/* Initialization and iteration */
112void governments_alloc(int num);
113void governments_free(void);
114
115struct government_iter;
116size_t government_iter_sizeof(void);
117struct iterator *government_iter_init(struct government_iter *it);
118
119/* Iterate over government types. */
120#define governments_iterate(NAME_pgov) \
121 generic_iterate(struct government_iter, struct government *, \
122 NAME_pgov, government_iter_sizeof, government_iter_init)
123#define governments_iterate_end generic_iterate_end
124
125#define governments_re_active_iterate(_p) \
126 governments_iterate(_p) { \
127 if (!_p->ruledit_disabled) {
128
129#define governments_re_active_iterate_end \
130 } \
131 } governments_iterate_end;
132
133bool untargeted_revolution_allowed(void);
134
135#ifdef __cplusplus
136}
137#endif /* __cplusplus */
138
139#endif /* FC__GOVERNMENT_H */
fc_types.h
Government_type_id
int Government_type_id
Definition fc_types.h:351
MAX_LEN_NAME
#define MAX_LEN_NAME
Definition fc_types.h:66
government_name_translation
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
default_title_for_player
const char * default_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:425
governments_free
void governments_free(void)
Definition government.c:543
ruler_title_nation
const struct nation_type * ruler_title_nation(const struct ruler_title *pruler_title)
Definition government.c:364
untargeted_revolution_allowed
bool untargeted_revolution_allowed(void)
Definition government.c:564
government_ruler_title_new
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:324
ruler_title_for_player
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:390
government_iter_init
struct iterator * government_iter_init(struct government_iter *it)
Definition government.c:482
ruler_title_female_untranslated_name
const char * ruler_title_female_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:382
government_count
Government_type_id government_count(void)
Definition government.c:70
government_by_number
struct government * government_by_number(const Government_type_id gov)
Definition government.c:102
government_of_player
struct government * government_of_player(const struct player *pplayer)
Definition government.c:113
government_name_for_player
const char * government_name_for_player(const struct player *pplayer)
Definition government.c:153
ruler_title_male_untranslated_name
const char * ruler_title_male_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:373
government_of_city
struct government * government_of_city(const struct city *pcity)
Definition government.c:122
governments_alloc
void governments_alloc(int num)
Definition government.c:527
government_number
Government_type_id government_number(const struct government *pgovern)
Definition government.c:90
government_ruler_titles
const struct ruler_title_hash * government_ruler_titles(const struct government *pgovern)
Definition government.c:313
government_index
Government_type_id government_index(const struct government *pgovern)
Definition government.c:81
government_iter_sizeof
size_t government_iter_sizeof(void)
Definition government.c:449
government_rule_name
const char * government_rule_name(const struct government *pgovern)
Definition government.c:132
government_by_translated_name
struct government * government_by_translated_name(const char *name)
Definition government.c:39
can_change_to_government
bool can_change_to_government(struct player *pplayer, const struct government *pgovern)
Definition government.c:165
government_by_rule_name
struct government * government_by_rule_name(const char *name)
Definition government.c:54
name
const char * name
Definition inputfile.c:127
name_translation.h
requirements.h
shared.h
spechash.h
city
Definition city.h:309
government_iter
Definition government.c:440
government
Definition government.h:52
government::helptext
struct strvec * helptext
Definition government.h:61
government::reqs
struct requirement_vector reqs
Definition government.h:58
government::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition government.h:57
government::ruledit_disabled
bool ruledit_disabled
Definition government.h:55
government::better
struct government * better
Definition government.h:65
government::item_number
Government_type_id item_number
Definition government.h:53
government::changed_to_times
int changed_to_times
Definition government.h:60
government::name
struct name_translation name
Definition government.h:54
government::ai
struct government::@40 ai
government::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition government.h:56
government::ruler_titles
struct ruler_title_hash * ruler_titles
Definition government.h:59
iterator
Definition iterator.h:31
name_translation
Definition name_translation.h:35
nation_type
Definition nation.h:97
player
Definition player.h:249
ruler_title
Definition government.c:187
ruler_title::pnation
const struct nation_type * pnation
Definition government.c:188
strvec
Definition string_vector.c:29