16
16
/* City Improvements, including Wonders. (Alternatively "Buildings".) */
18
#include "shared.h" /* bool */
19
#include "bitvector.h"
20
#include "support.h" /* bool */
20
23
#include "fc_types.h"
24
#include "name_translation.h"
22
25
#include "requirements.h"
27
struct strvec; /* Actually defined in "utility/string_vector.h". */
24
29
/* B_LAST is a value that is guaranteed to be larger than all
25
30
* actual Impr_type_id values. It is used as a flag value; it can
26
31
* also be used for fixed allocations to ensure ability to hold the
33
38
#define B_NEVER (NULL)
36
40
/* Changing these breaks network compatibility. */
38
IF_VISIBLE_BY_OTHERS, /* improvement should be visible to others without spying */
39
IF_SAVE_SMALL_WONDER, /* this small wonder is moved to another city if game.savepalace is on. */
40
IF_GOLD, /* when built, gives gold */
41
#define SPECENUM_NAME impr_flag_id
42
/* improvement should be visible to others without spying */
43
#define SPECENUM_VALUE0 IF_VISIBLE_BY_OTHERS
44
#define SPECENUM_VALUE0NAME "VisibleByOthers"
45
/* this small wonder is moved to another city if game.savepalace is on. */
46
#define SPECENUM_VALUE1 IF_SAVE_SMALL_WONDER
47
#define SPECENUM_VALUE1NAME "SaveSmallWonder"
48
/* when built, gives gold */
49
#define SPECENUM_VALUE2 IF_GOLD
50
#define SPECENUM_VALUE2NAME "Gold"
51
#define SPECENUM_COUNT IF_COUNT
52
#include "specenum_gen.h"
54
#define SPECENUM_NAME impr_genus_id
55
#define SPECENUM_VALUE0 IG_GREAT_WONDER
56
#define SPECENUM_VALUE0NAME "GreatWonder"
57
#define SPECENUM_VALUE1 IG_SMALL_WONDER
58
#define SPECENUM_VALUE1NAME "SmallWonder"
59
#define SPECENUM_VALUE2 IG_IMPROVEMENT
60
#define SPECENUM_VALUE2NAME "Improvement"
61
#define SPECENUM_VALUE3 IG_SPECIAL
62
#define SPECENUM_VALUE3NAME "Special"
63
#include "specenum_gen.h"
52
65
BV_DEFINE(bv_imprs, B_LAST);
66
BV_DEFINE(bv_impr_flags, IF_COUNT);
54
68
/* Type of improvement. (Read from buildings.ruleset file.) */
83
97
struct impr_type *valid_improvement(struct impr_type *pimprove);
84
98
struct impr_type *valid_improvement_by_number(const Impr_type_id id);
86
struct impr_type *find_improvement_by_rule_name(const char *name);
87
struct impr_type *find_improvement_by_translated_name(const char *name);
100
struct impr_type *improvement_by_rule_name(const char *name);
101
struct impr_type *improvement_by_translated_name(const char *name);
89
103
const char *improvement_rule_name(const struct impr_type *pimprove);
90
const char *improvement_name_translation(struct impr_type *pimprove);
104
const char *improvement_name_translation(const struct impr_type *pimprove);
92
106
/* General improvement flag accessor routines */
93
107
bool improvement_has_flag(const struct impr_type *pimprove,
94
enum impr_flag_id flag);
95
enum impr_flag_id find_improvement_flag_by_rule_name(const char *s);
108
enum impr_flag_id flag);
97
110
/* Ancillary routines */
98
111
int impr_build_shield_cost(const struct impr_type *pimprove);
127
140
bool wonder_is_built(const struct player *pplayer,
128
141
const struct impr_type *pimprove);
129
struct city *find_city_from_wonder(const struct player *pplayer,
130
const struct impr_type *pimprove);
142
struct city *city_from_wonder(const struct player *pplayer,
143
const struct impr_type *pimprove);
132
145
bool great_wonder_is_built(const struct impr_type *pimprove);
133
146
bool great_wonder_is_destroyed(const struct impr_type *pimprove);
134
147
bool great_wonder_is_available(const struct impr_type *pimprove);
135
struct city *find_city_from_great_wonder(const struct impr_type *pimprove);
148
struct city *city_from_great_wonder(const struct impr_type *pimprove);
136
149
struct player *great_wonder_owner(const struct impr_type *pimprove);
138
151
bool small_wonder_is_built(const struct player *pplayer,
139
152
const struct impr_type *pimprove);
140
struct city *find_city_from_small_wonder(const struct player *pplayer,
141
const struct impr_type *pimprove);
153
struct city *city_from_small_wonder(const struct player *pplayer,
154
const struct impr_type *pimprove);
143
156
/* player related improvement functions */
144
157
bool improvement_obsolete(const struct player *pplayer,
145
158
const struct impr_type *pimprove);
146
159
bool impr_provides_buildable_units(const struct player *pplayer,
147
160
const struct impr_type *pimprove);
161
bool is_improvement_redundant(const struct city *pcity,
162
struct impr_type *pimprove);
149
164
bool can_player_build_improvement_direct(const struct player *p,
150
165
struct impr_type *pimprove);
153
168
bool can_player_build_improvement_now(const struct player *p,
154
169
struct impr_type *pimprove);
156
/* General genus accessor routines */
157
enum impr_genus_id find_genus_by_rule_name(const char *s);
159
171
/* Initialization and iteration */
160
172
void improvements_init(void);
161
173
void improvements_free(void);