40 #define RESOURCE_NULL_IDENTIFIER '\0'
41 #define RESOURCE_NONE_IDENTIFIER ' '
50 #define T_NONE (nullptr)
51 #define T_UNKNOWN (nullptr)
58 #define MAX_NUM_TERRAINS (96)
61 #define MAX_RESOURCE_TYPES (MAX_NUM_TERRAINS / 2)
64 #define SPECENUM_NAME terrain_class
65 #define SPECENUM_VALUE0 TC_LAND
67 #define SPECENUM_VALUE0NAME N_("Land")
68 #define SPECENUM_VALUE1 TC_OCEAN
70 #define SPECENUM_VALUE1NAME N_("Oceanic")
71 #define SPECENUM_COUNT TC_COUNT
72 #include "specenum_gen.h"
79 #define SPECENUM_NAME terrain_alteration
81 #define SPECENUM_VALUE0 TA_CAN_IRRIGATE
85 #define SPECENUM_VALUE0NAME N_("CanIrrigate")
87 #define SPECENUM_VALUE1 TA_CAN_MINE
88 #define SPECENUM_VALUE1NAME N_("CanMine")
90 #define SPECENUM_VALUE2 TA_CAN_ROAD
91 #define SPECENUM_VALUE2NAME N_("CanRoad")
92 #define SPECENUM_COUNT TA_COUNT
93 #include "specenum_gen.h"
96 #define SPECENUM_NAME terrain_flag_id
98 #define SPECENUM_VALUE0 TER_NO_BARBS
101 #define SPECENUM_VALUE0NAME N_("NoBarbs")
103 #define SPECENUM_VALUE1 TER_NO_CITIES
104 #define SPECENUM_VALUE1NAME N_("NoCities")
106 #define SPECENUM_VALUE2 TER_STARTER
107 #define SPECENUM_VALUE2NAME N_("Starter")
109 #define SPECENUM_VALUE3 TER_CAN_HAVE_RIVER
110 #define SPECENUM_VALUE3NAME N_("CanHaveRiver")
112 #define SPECENUM_VALUE4 TER_UNSAFE_COAST
113 #define SPECENUM_VALUE4NAME N_("UnsafeCoast")
115 #define SPECENUM_VALUE5 TER_FRESHWATER
116 #define SPECENUM_VALUE5NAME N_("FreshWater")
118 #define SPECENUM_VALUE6 TER_NOT_GENERATED
119 #define SPECENUM_VALUE6NAME N_("NotGenerated")
121 #define SPECENUM_VALUE7 TER_NO_ZOC
122 #define SPECENUM_VALUE7NAME N_("NoZoc")
124 #define SPECENUM_VALUE8 TER_FROZEN
125 #define SPECENUM_VALUE8NAME N_("Frozen")
126 #define SPECENUM_VALUE9 TER_USER_1
127 #define SPECENUM_VALUE10 TER_USER_2
128 #define SPECENUM_VALUE11 TER_USER_3
129 #define SPECENUM_VALUE12 TER_USER_4
130 #define SPECENUM_VALUE13 TER_USER_5
131 #define SPECENUM_VALUE14 TER_USER_6
132 #define SPECENUM_VALUE15 TER_USER_7
133 #define SPECENUM_VALUE16 TER_USER_8
134 #define SPECENUM_VALUE17 TER_USER_9
135 #define SPECENUM_VALUE18 TER_USER_LAST
136 #define SPECENUM_NAMEOVERRIDE
137 #define SPECENUM_BITVECTOR bv_terrain_flags
138 #include "specenum_gen.h"
140 #define MAX_NUM_USER_TER_FLAGS (TER_USER_LAST - TER_USER_1 + 1)
142 #define SPECENUM_NAME mapgen_terrain_property
143 #define SPECENUM_VALUE0 MG_MOUNTAINOUS
144 #define SPECENUM_VALUE0NAME "mountainous"
145 #define SPECENUM_VALUE1 MG_GREEN
146 #define SPECENUM_VALUE1NAME "green"
147 #define SPECENUM_VALUE2 MG_FOLIAGE
148 #define SPECENUM_VALUE2NAME "foliage"
149 #define SPECENUM_VALUE3 MG_TROPICAL
150 #define SPECENUM_VALUE3NAME "tropical"
151 #define SPECENUM_VALUE4 MG_TEMPERATE
152 #define SPECENUM_VALUE4NAME "temperate"
153 #define SPECENUM_VALUE5 MG_COLD
154 #define SPECENUM_VALUE5NAME "cold"
155 #define SPECENUM_VALUE6 MG_FROZEN
156 #define SPECENUM_VALUE6NAME "frozen"
157 #define SPECENUM_VALUE7 MG_WET
158 #define SPECENUM_VALUE7NAME "wet"
159 #define SPECENUM_VALUE8 MG_DRY
160 #define SPECENUM_VALUE8NAME "dry"
161 #define SPECENUM_VALUE9 MG_OCEAN_DEPTH
162 #define SPECENUM_VALUE9NAME "ocean_depth"
163 #define SPECENUM_COUNT MG_COUNT
164 #include "specenum_gen.h"
181 #define TERRAIN_UNKNOWN_IDENTIFIER 'u'
183 enum terrain_class
tclass;
232 int property[MG_COUNT];
233 #define TERRAIN_OCEAN_DEPTH_MINIMUM (1)
234 #define TERRAIN_OCEAN_DEPTH_MAXIMUM (100)
260 #define terrain_has_flag(terr, flag) BV_ISSET((terr)->flags, flag)
263 enum terrain_flag_id flag);
265 enum terrain_flag_id flag);
267 bool cardinal_only,
bool percentage,
268 enum terrain_flag_id flag);
272 const char *helptxt);
276 #define is_ocean(pterrain) \
277 ((pterrain) != T_UNKNOWN \
278 && terrain_type_terrain_class(pterrain) == TC_OCEAN)
279 #define is_ocean_tile(ptile) is_ocean(tile_terrain(ptile))
286 const struct terrain *pterrain,
bool check_self);
288 const struct terrain *pterrain,
bool check_self);
290 bool cardinal_only,
bool percentage,
291 enum mapgen_terrain_property prop);
301 enum unit_activity activity,
304 enum unit_activity activity,
313 enum terrain_class tclass);
315 enum terrain_class tclass);
317 bool cardinal_only,
bool percentage,
318 enum terrain_class tclass);
322 enum terrain_alteration talter);
331 #define terrain_type_iterate(_p) \
333 struct terrain *_p = terrain_array_first(); \
334 if (nullptr != _p) { \
335 for (; _p <= terrain_array_last(); _p++) {
337 #define terrain_type_iterate_end \
342 #define terrain_re_active_iterate(_p) \
343 terrain_type_iterate(_p) \
345 if (!_p->ruledit_disabled) {
347 #define terrain_re_active_iterate_end \
350 terrain_type_iterate_end;
struct terrain * cooler_wetter_result
struct extra_type ** resources
struct terrain * cooler_drier_result
struct terrain * warmer_wetter_result
bv_unit_classes native_to
struct name_translation name
struct terrain * irrigation_result
struct terrain * warmer_drier_result
QVector< QString > * helptext
const struct unit_type * animal
struct terrain * mining_result
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
enum terrain_class tclass
int road_output_incr_pct[O_LAST]
struct terrain * transform_result
int terrain_extra_removal_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Time to complete the extra removal activity on the given terrain.
Terrain_type_id terrain_count()
Return the number of terrains.
char terrain_identifier(const struct terrain *pterrain)
Return the terrain identifier.
struct extra_type * get_preferred_pillage(bv_extras extras)
Returns the highest-priority (best) extra to be pillaged from the terrain set.
void user_terrain_flags_init()
Initialize user terrain type flags.
int count_terrain_flag_near_tile(const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_flag_id flag)
Return the number of adjacent tiles that have terrain with the given flag (not including ptile itself...
bool is_terrain_class_card_near(const struct tile *ptile, enum terrain_class tclass)
Is there terrain of the given class cardinally near tile? (Does not check ptile itself....
bool is_terrain_flag_near_tile(const struct tile *ptile, enum terrain_flag_id flag)
Returns TRUE iff any adjacent tile contains terrain with the given flag (does not check ptile itself)...
bool is_terrain_flag_card_near(const struct tile *ptile, enum terrain_flag_id flag)
Returns TRUE iff any cardinally adjacent tile contains terrain with the given flag (does not check pt...
struct terrain * terrain_by_translated_name(const char *name)
Return the terrain type matching the name, or T_UNKNOWN if none matches.
bool terrain_can_support_alteration(const struct terrain *pterrain, enum terrain_alteration talter)
Can terrain support given infrastructure?
struct terrain * terrain_by_number(const Terrain_type_id type)
Return the terrain for the given terrain index.
const char * terrain_rule_name(const struct terrain *pterrain)
Return the (untranslated) rule name of the terrain.
int count_terrain_property_near_tile(const struct tile *ptile, bool cardinal_only, bool percentage, enum mapgen_terrain_property prop)
Return the number of adjacent tiles that have the given terrain property.
struct resource_type * resource_type_init(struct extra_type *pextra)
Initialize resource_type structure.
void terrains_free()
Free memory which is associated with terrain types.
struct terrain * terrain_by_rule_name(const char *name)
Return the terrain type matching the name, or T_UNKNOWN if none matches.
const char * terrain_class_name_translation(enum terrain_class tclass)
Return the (translated) name of the given terrain class.
Terrain_type_id terrain_index(const struct terrain *pterrain)
Return the terrain index.
bool is_terrain_near_tile(const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Returns TRUE iff any adjacent tile contains the given terrain.
const char * get_infrastructure_text(bv_extras extras)
Return a (static) string with extra(s) name(s): eg: "Mine" eg: "Road/Farmland" This only includes "in...
const struct terrain * terrain_array_last()
Return the last item of terrains.
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Return the (untranslated) helptxt of the user terrain flag.
bool is_terrain_card_near(const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Returns TRUE iff any cardinally adjacent tile contains the given terrain.
void user_terrain_flags_free()
Frees the memory associated with all user terrain flags.
bool is_terrain_class_near_tile(const struct tile *ptile, enum terrain_class tclass)
Is there terrain of the given class near tile? (Does not check ptile itself.)
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
What terrain class terrain type belongs to.
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
Check for resource in terrain resources list.
void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name, const char *helptxt)
Sets user defined name for terrain flag.
const char * terrain_name_translation(const struct terrain *pterrain)
Return the (translated) name of the terrain.
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Time to complete the extra building activity on the given terrain.
Terrain_type_id terrain_number(const struct terrain *pterrain)
Return the terrain index.
int count_terrain_class_near_tile(const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_class tclass)
Return the number of adjacent tiles that have given terrain class (not including ptile itself).
struct terrain * terrain_array_first()
Return the first item of terrains.
void resource_types_free()
Free the memory associated with resource types.
void terrains_init()
Initialize terrain and resource structures.