54 delete pterrain->helptext;
55 pterrain->helptext =
nullptr;
56 delete[] pterrain->resources;
57 pterrain->resources =
nullptr;
58 if (pterrain->rgb !=
nullptr) {
62 pterrain->rgb =
nullptr;
130 if (type < 0 || type >=
game.
control.terrain_count) {
197 while (
nullptr != *r) {
198 if (*r == presource) {
215 presource->
self = pextra;
232 #define variable_adjc_iterate(nmap, center_tile, _tile, card_only) \
234 enum direction8 *_tile##_list; \
238 _tile##_list = wld.map.cardinal_dirs; \
239 _tile##_count = wld.map.num_cardinal_dirs; \
241 _tile##_list = wld.map.valid_dirs; \
242 _tile##_count = wld.map.num_valid_dirs; \
244 adjc_dirlist_iterate(nmap, center_tile, _tile, _tile##_dir, \
245 _tile##_list, _tile##_count) \
248 #define variable_adjc_iterate_end \
250 adjc_dirlist_iterate_end; \
257 const struct terrain *pterrain,
bool check_self)
271 return check_self && ptile->
terrain == pterrain;
278 const struct terrain *pterrain,
bool check_self)
292 return check_self && ptile->
terrain == pterrain;
299 bool cardinal_only,
bool percentage,
300 enum mapgen_terrain_property prop)
302 int count = 0, total = 0;
316 count = count * 100 / std::max(1, total);
326 enum terrain_flag_id flag)
346 enum terrain_flag_id flag)
366 bool cardinal_only,
bool percentage,
367 enum terrain_flag_id flag)
369 int count = 0, total = 0;
383 count = count * 100 / std::max(1, total);
404 if (pextra->category == ECAT_INFRA
428 if (
len > 0 && *p ==
'/') {
442 static const enum extra_cause prefs[] = {
443 EC_IRRIGATION, EC_MINE, EC_BASE, EC_ROAD, EC_HUT,
444 EC_APPEARANCE, EC_POLLUTION, EC_FALLOUT, EC_RESOURCE,
EC_NONE};
474 enum terrain_class tclass)
496 enum terrain_class
tclass)
518 bool cardinal_only,
bool percentage,
519 enum terrain_class
tclass)
521 int count = 0, total = 0;
536 count = count * 100 / std::max(1, total);
548 if (!terrain_class_is_valid(
tclass)) {
552 return _(terrain_class_name(
tclass));
559 enum terrain_alteration alter)
562 case TA_CAN_IRRIGATE:
580 enum unit_activity activity,
590 if (tgt ==
nullptr) {
600 case ACTIVITY_GEN_ROAD:
602 case ACTIVITY_IRRIGATE:
616 enum unit_activity activity,
626 if (tgt ==
nullptr) {
634 case ACTIVITY_POLLUTION:
636 case ACTIVITY_FALLOUT:
638 case ACTIVITY_PILLAGE:
676 int tfid =
id - TER_USER_1;
688 if (helptxt && helptxt[0] !=
'\0') {
698 if (flag < TER_USER_1 || flag > TER_USER_LAST) {
710 fc_assert(
id >= TER_USER_1 &&
id <= TER_USER_LAST);
bool BV_ISSET(const BV &bv, int bit)
void user_flag_init(struct user_flag *flag)
Initialize user flag.
void user_flag_free(struct user_flag *flag)
Free user flag.
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define cardinal_adjc_iterate_end
#define adjc_iterate(nmap, center_tile, itr_tile)
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Free rgbcolor structure.
struct packet_ruleset_control control
struct extra_type ** resources
struct name_translation name
struct terrain * irrigation_result
const struct unit_type * animal
struct terrain * mining_result
enum terrain_class tclass
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
int cat_snprintf(char *str, size_t n, const char *format,...)
cat_snprintf is like a combination of fc_snprintf and fc_strlcat; it does snprintf to the end of an e...
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.
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.
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Terrain flag name callback, called from specenum code.
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.
#define variable_adjc_iterate(nmap, center_tile, _tile, card_only)
This iterator behaves like adjc_iterate or cardinal_adjc_iterate depending on the value of card_only.
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.
bool terrain_can_support_alteration(const struct terrain *pterrain, enum terrain_alteration alter)
Can terrain support given infrastructure?
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.
static struct terrain civ_terrains[MAX_NUM_TERRAINS]
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.
static struct user_flag user_terrain_flags[MAX_NUM_USER_TER_FLAGS]
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.
#define variable_adjc_iterate_end
void resource_types_free()
Free the memory associated with resource types.
void terrains_init()
Initialize terrain and resource structures.
#define terrain_type_iterate(_p)
#define terrain_type_iterate_end
#define terrain_has_flag(terr, flag)
#define MAX_NUM_USER_TER_FLAGS
#define tile_terrain(_tile)