Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
terrain.h File Reference
#include "bitvector.h"
#include "shared.h"
#include "fc_types.h"
#include "name_translation.h"
#include "unittype.h"
#include "terrain_enums_gen.h"

Go to the source code of this file.

Data Structures

struct  resource_type
 
struct  terrain
 

Macros

#define MAX_NUM_USER_TER_FLAGS   (TER_USER_LAST - TER_USER_1 + 1)
 
#define RESOURCE_NULL_IDENTIFIER   '\0'
 
#define RESOURCE_NONE_IDENTIFIER   ' '
 
#define T_NONE   (NULL) /* A special flag meaning no terrain type. */
 
#define T_UNKNOWN   (NULL) /* An unknown terrain. */
 
#define T_FIRST   0
 
#define MAX_NUM_TERRAINS   (96)
 
#define TERRAIN_UNKNOWN_IDENTIFIER   'u'
 
#define RESOURCE_FREQUENCY_MINIMUM   (0)
 
#define RESOURCE_FREQUENCY_DEFAULT   (1)
 
#define RESOURCE_FREQUENCY_MAXIMUM   (255)
 
#define TERRAIN_OCEAN_DEPTH_MINIMUM   (1)
 
#define TERRAIN_OCEAN_DEPTH_MAXIMUM   (100)
 
#define terrain_has_flag(terr, flag)   BV_ISSET((terr)->flags, flag)
 
#define is_ocean(pterrain)
 
#define is_ocean_tile(ptile)    is_ocean(tile_terrain(ptile))
 
#define terrain_type_iterate(_p)
 
#define terrain_type_iterate_end
 
#define terrain_re_active_iterate(_p)
 
#define terrain_re_active_iterate_end
 
#define terrain_resources_iterate(pterrain, _res, _freq)
 
#define terrain_resources_iterate_end
 

Enumerations

enum  special_river_move { RMV_NORMAL = 0 , RMV_FAST_STRICT = 1 , RMV_FAST_RELAXED = 2 , RMV_FAST_ALWAYS = 3 }
 

Functions

Terrain_type_id terrain_count (void)
 
Terrain_type_id terrain_index (const struct terrain *pterrain)
 
Terrain_type_id terrain_number (const struct terrain *pterrain)
 
struct terrainterrain_by_number (const Terrain_type_id type)
 
struct terrainterrain_by_identifier (const char identifier)
 
struct terrainterrain_by_rule_name (const char *name)
 
struct terrainterrain_by_translated_name (const char *name)
 
struct terrainrand_terrain_by_flag (enum terrain_flag_id flag)
 
char terrain_identifier (const struct terrain *pterrain)
 
const charterrain_rule_name (const struct terrain *pterrain)
 
const charterrain_name_translation (const struct terrain *pterrain)
 
bool is_terrain_flag_card_near (const struct civ_map *nmap, const struct tile *ptile, enum terrain_flag_id flag)
 
bool is_terrain_flag_near_tile (const struct civ_map *nmap, const struct tile *ptile, enum terrain_flag_id flag)
 
int count_terrain_flag_near_tile (const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_flag_id flag)
 
void user_terrain_flags_init (void)
 
void user_terrain_flags_free (void)
 
void set_user_terrain_flag_name (enum terrain_flag_id id, const char *name, const char *helptxt)
 
const charterrain_flag_helptxt (enum terrain_flag_id id)
 
bool terrain_has_resource (const struct terrain *pterrain, const struct extra_type *presource)
 
bool is_terrain_card_near (const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain, bool check_self)
 
bool is_terrain_near_tile (const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain, bool check_self)
 
int count_terrain_property_near_tile (const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum mapgen_terrain_property prop)
 
bool is_resource_card_near (const struct civ_map *nmap, const struct tile *ptile, const struct extra_type *pres, bool check_self)
 
bool is_resource_near_tile (const struct civ_map *nmap, const struct tile *ptile, const struct extra_type *pres, bool check_self)
 
struct resource_typeresource_type_init (struct extra_type *pextra)
 
void resource_types_free (void)
 
struct extra_typeresource_extra_get (const struct resource_type *presource)
 
const charget_infrastructure_text (bv_extras extras)
 
struct extra_typeget_preferred_pillage (bv_extras extras)
 
int terrain_extra_build_time (const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
 
int terrain_extra_removal_time (const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt) fc__attribute((nonnull(1
 
int const charterrain_class_name_translation (enum terrain_class tclass)
 
enum terrain_class terrain_type_terrain_class (const struct terrain *pterrain)
 
bool is_terrain_class_card_near (const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
 
bool is_terrain_class_near_tile (const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
 
int count_terrain_class_near_tile (const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_class tclass)
 
bool terrain_can_support_alteration (const struct terrain *pterrain, enum terrain_alteration talter)
 
void terrains_init (void)
 
void terrains_free (void)
 
struct terrainterrain_array_first (void)
 
const struct terrainterrain_array_last (void)
 

Macro Definition Documentation

◆ is_ocean

#define is_ocean (   pterrain)
Value:
((pterrain) != T_UNKNOWN \
char * incite_cost
Definition comments.c:76
#define T_UNKNOWN
Definition terrain.h:62
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
Definition terrain.c:582

Definition at line 194 of file terrain.h.

◆ is_ocean_tile

#define is_ocean_tile (   ptile)     is_ocean(tile_terrain(ptile))

Definition at line 196 of file terrain.h.

◆ MAX_NUM_TERRAINS

#define MAX_NUM_TERRAINS   (96)

Definition at line 69 of file terrain.h.

◆ MAX_NUM_USER_TER_FLAGS

#define MAX_NUM_USER_TER_FLAGS   (TER_USER_LAST - TER_USER_1 + 1)

Definition at line 32 of file terrain.h.

◆ RESOURCE_FREQUENCY_DEFAULT

#define RESOURCE_FREQUENCY_DEFAULT   (1)

Definition at line 101 of file terrain.h.

◆ RESOURCE_FREQUENCY_MAXIMUM

#define RESOURCE_FREQUENCY_MAXIMUM   (255)

Definition at line 102 of file terrain.h.

◆ RESOURCE_FREQUENCY_MINIMUM

#define RESOURCE_FREQUENCY_MINIMUM   (0)

Definition at line 100 of file terrain.h.

◆ RESOURCE_NONE_IDENTIFIER

#define RESOURCE_NONE_IDENTIFIER   ' '

Definition at line 52 of file terrain.h.

◆ RESOURCE_NULL_IDENTIFIER

#define RESOURCE_NULL_IDENTIFIER   '\0'

Definition at line 51 of file terrain.h.

◆ T_FIRST

#define T_FIRST   0

Definition at line 65 of file terrain.h.

◆ T_NONE

#define T_NONE   (NULL) /* A special flag meaning no terrain type. */

Definition at line 61 of file terrain.h.

◆ T_UNKNOWN

#define T_UNKNOWN   (NULL) /* An unknown terrain. */

Definition at line 62 of file terrain.h.

◆ terrain_has_flag

#define terrain_has_flag (   terr,
  flag 
)    BV_ISSET((terr)->flags, flag)

Definition at line 176 of file terrain.h.

◆ TERRAIN_OCEAN_DEPTH_MAXIMUM

#define TERRAIN_OCEAN_DEPTH_MAXIMUM   (100)

Definition at line 148 of file terrain.h.

◆ TERRAIN_OCEAN_DEPTH_MINIMUM

#define TERRAIN_OCEAN_DEPTH_MINIMUM   (1)

Definition at line 147 of file terrain.h.

◆ terrain_re_active_iterate

#define terrain_re_active_iterate (   _p)
Value:
if (!_p->ruledit_disabled) {
#define terrain_type_iterate(_p)
Definition terrain.h:266

Definition at line 277 of file terrain.h.

◆ terrain_re_active_iterate_end

#define terrain_re_active_iterate_end
Value:
} \
#define terrain_type_iterate_end
Definition terrain.h:272

Definition at line 281 of file terrain.h.

◆ terrain_resources_iterate

#define terrain_resources_iterate (   pterrain,
  _res,
  _freq 
)
Value:
if (NULL != pterrain && NULL != pterrain->resources) { \
int _res##_index; \
for (_res##_index = 0; \
pterrain->resources[_res##_index] != NULL; \
_res##_index++) { \
struct extra_type *_res = pterrain->resources[_res##_index]; \
int _freq = pterrain->resource_freq[_res##_index];

Definition at line 285 of file terrain.h.

◆ terrain_resources_iterate_end

#define terrain_resources_iterate_end
Value:
} \
}

Definition at line 294 of file terrain.h.

◆ terrain_type_iterate

#define terrain_type_iterate (   _p)
Value:
{ \
if (NULL != _p) { \
struct terrain * terrain_array_first(void)
Definition terrain.c:96
const struct terrain * terrain_array_last(void)
Definition terrain.c:107

Definition at line 266 of file terrain.h.

◆ terrain_type_iterate_end

#define terrain_type_iterate_end
Value:
} \
} \
}

Definition at line 272 of file terrain.h.

◆ TERRAIN_UNKNOWN_IDENTIFIER

#define TERRAIN_UNKNOWN_IDENTIFIER   'u'

Definition at line 88 of file terrain.h.

Enumeration Type Documentation

◆ special_river_move

Enumerator
RMV_NORMAL 
RMV_FAST_STRICT 
RMV_FAST_RELAXED 
RMV_FAST_ALWAYS 

Definition at line 39 of file terrain.h.

Function Documentation

◆ count_terrain_class_near_tile()

int count_terrain_class_near_tile ( const struct civ_map nmap,
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).

Definition at line 633 of file terrain.c.

Referenced by can_channel_land(), can_reclaim_ocean(), create_tmap(), island_river_mouth_suitability(), island_river_suitability(), make_fracture_relief(), make_river(), make_rivers(), and river_test_adjacent_ocean().

◆ count_terrain_flag_near_tile()

int count_terrain_flag_near_tile ( const struct civ_map nmap,
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).

Definition at line 478 of file terrain.c.

Referenced by can_freeze_terrain(), and can_thaw_terrain().

◆ count_terrain_property_near_tile()

int count_terrain_property_near_tile ( const struct civ_map nmap,
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.

Definition at line 369 of file terrain.c.

Referenced by make_rivers().

◆ get_infrastructure_text()

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 "infrastructure", i.e., man-made extras.

Definition at line 508 of file terrain.c.

Referenced by get_unit_info_label_text2(), popup_info_text(), and popup_terrain_info().

◆ get_preferred_pillage()

struct extra_type * get_preferred_pillage ( bv_extras  extras)

Returns the highest-priority (best) extra to be pillaged from the terrain set. May return NULL if nothing is available.

Definition at line 550 of file terrain.c.

Referenced by actres_possible(), popup_pillage_dialog(), request_unit_pillage(), and unit_assign_specific_activity_target().

◆ is_resource_card_near()

bool is_resource_card_near ( const struct civ_map nmap,
const struct tile ptile,
const struct extra_type pres,
bool  check_self 
)

Returns TRUE iff any cardinally adjacent tile contains the given resource.

Definition at line 395 of file terrain.c.

◆ is_resource_near_tile()

bool is_resource_near_tile ( const struct civ_map nmap,
const struct tile ptile,
const struct extra_type pres,
bool  check_self 
)

Returns TRUE iff any adjacent tile contains the given resource.

Definition at line 416 of file terrain.c.

◆ is_terrain_card_near()

bool is_terrain_card_near ( const struct civ_map nmap,
const struct tile ptile,
const struct terrain pterrain,
bool  check_self 
)

Returns TRUE iff any cardinally adjacent tile contains the given terrain.

Definition at line 327 of file terrain.c.

Referenced by is_terrain_req_active().

◆ is_terrain_class_card_near()

bool is_terrain_class_card_near ( const struct civ_map nmap,
const struct tile ptile,
enum terrain_class  tclass 
)

Is there terrain of the given class cardinally near tile? (Does not check ptile itself.)

Definition at line 591 of file terrain.c.

Referenced by fill_island(), and is_terrainclass_req_active().

◆ is_terrain_class_near_tile()

bool is_terrain_class_near_tile ( const struct civ_map nmap,
const struct tile ptile,
enum terrain_class  tclass 
)

◆ is_terrain_flag_card_near()

bool is_terrain_flag_card_near ( const struct civ_map nmap,
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 ptile itself).

Definition at line 438 of file terrain.c.

Referenced by is_terrainflag_req_active().

◆ is_terrain_flag_near_tile()

bool is_terrain_flag_near_tile ( const struct civ_map nmap,
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).

Definition at line 458 of file terrain.c.

Referenced by is_terrainflag_req_active().

◆ is_terrain_near_tile()

bool is_terrain_near_tile ( const struct civ_map nmap,
const struct tile ptile,
const struct terrain pterrain,
bool  check_self 
)

Returns TRUE iff any adjacent tile contains the given terrain.

Definition at line 348 of file terrain.c.

Referenced by evaluate_city_name_priority(), fill_island(), and is_terrain_req_active().

◆ rand_terrain_by_flag()

struct terrain * rand_terrain_by_flag ( enum terrain_flag_id  flag)

Return terrain having the flag. If several terrains have the flag, random one is returned.

Definition at line 217 of file terrain.c.

◆ resource_extra_get()

struct extra_type * resource_extra_get ( const struct resource_type presource)

Return extra that resource is.

Definition at line 296 of file terrain.c.

◆ resource_type_init()

struct resource_type * resource_type_init ( struct extra_type pextra)

Initialize resource_type structure.

Definition at line 272 of file terrain.c.

Referenced by handle_ruleset_resource(), and load_terrain_names().

◆ resource_types_free()

void resource_types_free ( void  )

Free the memory associated with resource types

Definition at line 288 of file terrain.c.

Referenced by extras_free().

◆ set_user_terrain_flag_name()

void set_user_terrain_flag_name ( enum terrain_flag_id  id,
const char name,
const char helptxt 
)

Sets user defined name for terrain flag.

Definition at line 788 of file terrain.c.

Referenced by handle_ruleset_terrain_flag(), and load_terrain_names().

◆ terrain_array_first()

struct terrain * terrain_array_first ( void  )

Return the first item of terrains.

Definition at line 96 of file terrain.c.

◆ terrain_array_last()

const struct terrain * terrain_array_last ( void  )

Return the last item of terrains.

Definition at line 107 of file terrain.c.

◆ terrain_by_identifier()

struct terrain * terrain_by_identifier ( const char  identifier)

Return the terrain type matching the identifier, or T_UNKNOWN if none matches.

Definition at line 169 of file terrain.c.

◆ terrain_by_number()

struct terrain * terrain_by_number ( const Terrain_type_id  type)

◆ terrain_by_rule_name()

struct terrain * terrain_by_rule_name ( const char name)

◆ terrain_by_translated_name()

struct terrain * terrain_by_translated_name ( const char name)

Return the terrain type matching the name, or T_UNKNOWN if none matches.

Definition at line 202 of file terrain.c.

Referenced by help_update_terrain(), help_dialog::make_tree(), and help_widget::set_topic_terrain().

◆ terrain_can_support_alteration()

bool terrain_can_support_alteration ( const struct terrain pterrain,
enum terrain_alteration  alter 
)

Can terrain support given infrastructure?

Definition at line 673 of file terrain.c.

Referenced by is_terrainalter_req_active(), and terrain_type_found().

◆ terrain_class_name_translation()

int const char * terrain_class_name_translation ( enum terrain_class  tclass)

Return the (translated) name of the given terrain class. You don't have to free the return pointer.

Definition at line 661 of file terrain.c.

Referenced by req_text_insert(), and universal_name_translation().

◆ terrain_count()

Terrain_type_id terrain_count ( void  )

◆ terrain_extra_build_time()

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.

Definition at line 699 of file terrain.c.

Referenced by adv_workers_road_bonus(), check_recursive_road_connect(), helptext_extra(), helptext_extra_for_terrain_str(), manual_terrain(), and tile_activity_time().

◆ terrain_extra_removal_time()

int terrain_extra_removal_time ( const struct terrain pterrain,
enum unit_activity  activity,
const struct extra_type tgt 
)

◆ terrain_flag_helptxt()

const char * terrain_flag_helptxt ( enum terrain_flag_id  id)

Return the (untranslated) helptxt of the user terrain flag.

Definition at line 829 of file terrain.c.

Referenced by helptext_terrain(), save_terrain_ruleset(), and send_ruleset_terrain().

◆ terrain_has_resource()

bool terrain_has_resource ( const struct terrain pterrain,
const struct extra_type presource 
)

◆ terrain_identifier()

char terrain_identifier ( const struct terrain pterrain)

Return the terrain identifier.

Definition at line 126 of file terrain.c.

Referenced by compat_load_020600(), and sg_save_savefile().

◆ terrain_index()

Terrain_type_id terrain_index ( const struct terrain pterrain)

◆ terrain_name_translation()

const char * terrain_name_translation ( const struct terrain pterrain)

◆ terrain_number()

Terrain_type_id terrain_number ( const struct terrain pterrain)

◆ terrain_rule_name()

const char * terrain_rule_name ( const struct terrain pterrain)

◆ terrain_type_terrain_class()

enum terrain_class terrain_type_terrain_class ( const struct terrain pterrain)

◆ terrains_free()

void terrains_free ( void  )

Free memory which is associated with terrain types.

Definition at line 65 of file terrain.c.

Referenced by game_ruleset_free().

◆ terrains_init()

void terrains_init ( void  )

Initialize terrain and resource structures.

Definition at line 42 of file terrain.c.

Referenced by game_ruleset_init().

◆ user_terrain_flags_free()

void user_terrain_flags_free ( void  )

Frees the memory associated with all user terrain flags

Definition at line 776 of file terrain.c.

Referenced by game_ruleset_free().

◆ user_terrain_flags_init()

void user_terrain_flags_init ( void  )

Initialize user terrain type flags.

Definition at line 764 of file terrain.c.

Referenced by game_ruleset_init().