![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "fcintl.h"#include "log.h"#include "rand.h"#include "shared.h"#include "support.h"#include "extras.h"#include "game.h"#include "map.h"#include "rgbcolor.h"#include "road.h"#include "terrain.h"
Include dependency graph for terrain.cpp:Go to the source code of this file.
Macros | |
| #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. More... | |
| #define | variable_adjc_iterate_end |
Functions | |
| void | terrains_init () |
| Initialize terrain and resource structures. More... | |
| void | terrains_free () |
| Free memory which is associated with terrain types. More... | |
| struct terrain * | terrain_array_first () |
| Return the first item of terrains. More... | |
| const struct terrain * | terrain_array_last () |
| Return the last item of terrains. More... | |
| Terrain_type_id | terrain_count () |
| Return the number of terrains. More... | |
| char | terrain_identifier (const struct terrain *pterrain) |
| Return the terrain identifier. More... | |
| Terrain_type_id | terrain_index (const struct terrain *pterrain) |
| Return the terrain index. More... | |
| Terrain_type_id | terrain_number (const struct terrain *pterrain) |
| Return the terrain index. More... | |
| struct terrain * | terrain_by_number (const Terrain_type_id type) |
| Return the terrain for the given terrain index. More... | |
| struct terrain * | terrain_by_rule_name (const char *name) |
| Return the terrain type matching the name, or T_UNKNOWN if none matches. More... | |
| struct terrain * | terrain_by_translated_name (const char *name) |
| Return the terrain type matching the name, or T_UNKNOWN if none matches. More... | |
| const char * | terrain_name_translation (const struct terrain *pterrain) |
| Return the (translated) name of the terrain. More... | |
| const char * | terrain_rule_name (const struct terrain *pterrain) |
| Return the (untranslated) rule name of the terrain. More... | |
| bool | terrain_has_resource (const struct terrain *pterrain, const struct extra_type *presource) |
| Check for resource in terrain resources list. More... | |
| struct resource_type * | resource_type_init (struct extra_type *pextra) |
| Initialize resource_type structure. More... | |
| void | resource_types_free () |
| Free the memory associated with resource types. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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 ptile itself). More... | |
| 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). More... | |
| 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). More... | |
| 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. More... | |
| struct extra_type * | get_preferred_pillage (bv_extras extras) |
| Returns the highest-priority (best) extra to be pillaged from the terrain set. More... | |
| enum terrain_class | terrain_type_terrain_class (const struct terrain *pterrain) |
| What terrain class terrain type belongs to. More... | |
| 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.) More... | |
| 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.) More... | |
| 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). More... | |
| const char * | terrain_class_name_translation (enum terrain_class tclass) |
| Return the (translated) name of the given terrain class. More... | |
| bool | terrain_can_support_alteration (const struct terrain *pterrain, enum terrain_alteration alter) |
| Can terrain support given infrastructure? More... | |
| 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. More... | |
| 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. More... | |
| void | user_terrain_flags_init () |
| Initialize user terrain type flags. More... | |
| void | user_terrain_flags_free () |
| Frees the memory associated with all user terrain flags. More... | |
| void | set_user_terrain_flag_name (enum terrain_flag_id id, const char *name, const char *helptxt) |
| Sets user defined name for terrain flag. More... | |
| const char * | terrain_flag_id_name_cb (enum terrain_flag_id flag) |
| Terrain flag name callback, called from specenum code. More... | |
| const char * | terrain_flag_helptxt (enum terrain_flag_id id) |
| Return the (untranslated) helptxt of the user terrain flag. More... | |
Variables | |
| static struct terrain | civ_terrains [MAX_NUM_TERRAINS] |
| static struct user_flag | user_terrain_flags [MAX_NUM_USER_TER_FLAGS] |
| #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.
Definition at line 232 of file terrain.cpp.
| #define variable_adjc_iterate_end |
Definition at line 248 of file terrain.cpp.
| 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).
Definition at line 517 of file terrain.cpp.
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().
| 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).
Definition at line 365 of file terrain.cpp.
Referenced by can_freeze_terrain(), and can_thaw_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.
Definition at line 298 of file terrain.cpp.
Referenced by make_rivers().
| 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 394 of file terrain.cpp.
Referenced by popup_info_text(), and popup_terrain_info().
| struct extra_type* get_preferred_pillage | ( | bv_extras | extras | ) |
Returns the highest-priority (best) extra to be pillaged from the terrain set.
May return nullptr if nothing is available.
Definition at line 439 of file terrain.cpp.
Referenced by popup_pillage_dialog(), request_unit_pillage(), and unit_assign_specific_activity_target().
| 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.
Definition at line 256 of file terrain.cpp.
| 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.)
Definition at line 473 of file terrain.cpp.
Referenced by fill_island().
| 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.)
Definition at line 495 of file terrain.cpp.
Referenced by building_advisor(), city_landlocked_sell_coastal_improvements(), contemplate_new_city(), dai_effect_value(), find_best_city_placement(), find_closest_city(), find_something_to_kill(), is_terrain_ecologically_wet(), naval_bonus(), and city_widget::select_coastal().
| 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 ptile itself).
Definition at line 325 of file terrain.cpp.
| 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).
Definition at line 345 of file terrain.cpp.
| 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.
Definition at line 277 of file terrain.cpp.
Referenced by evaluate_city_name_priority(), and fill_island().
| struct resource_type* resource_type_init | ( | struct extra_type * | pextra | ) |
Initialize resource_type structure.
Definition at line 209 of file terrain.cpp.
Referenced by handle_ruleset_resource(), and load_terrain_names().
| void resource_types_free | ( | ) |
Free the memory associated with resource types.
Definition at line 223 of file terrain.cpp.
Referenced by extras_free().
| 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 673 of file terrain.cpp.
Referenced by handle_ruleset_terrain_flag(), load_terrain_names(), and rscompat_names().
| struct terrain* terrain_array_first | ( | ) |
Return the first item of terrains.
Definition at line 71 of file terrain.cpp.
| const struct terrain* terrain_array_last | ( | ) |
Return the last item of terrains.
Definition at line 82 of file terrain.cpp.
| struct terrain* terrain_by_number | ( | const Terrain_type_id | type | ) |
Return the terrain for the given terrain index.
Definition at line 128 of file terrain.cpp.
Referenced by tab_terrains::add_now(), api_find_terrain(), editor_tool_get_value_name(), handle_edit_tile_terrain(), handle_ruleset_terrain(), handle_tile_info(), load_ruleset_terrain(), mapimg_colortest(), help_widget::terrain_max_values(), and universal_value_initial().
| struct terrain* terrain_by_rule_name | ( | const char * | name | ) |
Return the terrain type matching the name, or T_UNKNOWN if none matches.
Definition at line 140 of file terrain.cpp.
Referenced by api_find_terrain_by_name(), tab_terrains::initialize_new_terrain(), load_city_name_list(), lookup_terrain(), tab_terrains::select_terrain(), sg_load_savefile(), page_load::slot_selection_changed(), and universal_by_number().
| 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 158 of file terrain.cpp.
Referenced by help_dialog::make_tree(), and help_widget::set_topic_terrain().
| bool terrain_can_support_alteration | ( | const struct terrain * | pterrain, |
| enum terrain_alteration | alter | ||
| ) |
Can terrain support given infrastructure?
Definition at line 558 of file terrain.cpp.
| 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 546 of file terrain.cpp.
Referenced by req_text_insert(), universal_name_translation(), and worklist_item_postpone_req_vec().
| Terrain_type_id terrain_count | ( | ) |
Return the number of terrains.
Definition at line 93 of file terrain.cpp.
Referenced by fill_tile_edit_packet(), handle_ruleset_control(), freeciv::layer_roads::initialize_extra(), mapimg_colortest(), pick_terrain_by_flag(), print_mapgen_map(), send_ruleset_terrain(), send_tile_info(), and help_widget::terrain_max_values().
| 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 579 of file terrain.cpp.
Referenced by adv_settlers_road_bonus(), check_recursive_road_connect(), helptext_extra(), helptext_extra_for_terrain_str(), manual_command(), and tile_activity_time().
| 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.
Definition at line 615 of file terrain.cpp.
Referenced by tile_activity_time().
| const char* terrain_flag_helptxt | ( | enum terrain_flag_id | id | ) |
Return the (untranslated) helptxt of the user terrain flag.
Definition at line 708 of file terrain.cpp.
Referenced by helptext_terrain(), save_terrain_ruleset(), and send_ruleset_terrain().
| const char* terrain_flag_id_name_cb | ( | enum terrain_flag_id | flag | ) |
Terrain flag name callback, called from specenum code.
Definition at line 696 of file terrain.cpp.
Referenced by first_free_terrain_user_flag(), save_terrain_ruleset(), and send_ruleset_terrain().
| bool terrain_has_resource | ( | const struct terrain * | pterrain, |
| const struct extra_type * | presource | ||
| ) |
Check for resource in terrain resources list.
Definition at line 192 of file terrain.cpp.
Referenced by is_native_tile_to_extra(), sg_load_map_tiles_extras(), sg_load_map_tiles_resources(), sg_load_player_vision(), tile_set_resource(), and tile_set_terrain().
| char terrain_identifier | ( | const struct terrain * | pterrain | ) |
Return the terrain identifier.
Definition at line 98 of file terrain.cpp.
Referenced by compat_load_020600(), and sg_save_savefile().
| Terrain_type_id terrain_index | ( | const struct terrain * | pterrain | ) |
Return the terrain index.
Currently same as terrain_number(), paired with terrain_count() indicates use as an array index.
Definition at line 110 of file terrain.cpp.
Referenced by freeciv::layer_terrain::fill_blending_sprite_array(), freeciv::layer_water::fill_irrigation_sprite_array(), freeciv::layer_roads::fill_sprite_array(), freeciv::layer_water::fill_sprite_array(), freeciv::layer_terrain::fill_terrain_sprite_array(), freeciv::layer_terrain::initialize_terrain(), load_ruleset_terrain(), load_terrain_names(), lookup_terrain(), nation_city_set_terrain_preference(), pick_terrain_by_flag(), print_mapgen_map(), tab_terrains::refresh(), and freeciv::layer_terrain::terrain_group().
| const char* terrain_name_translation | ( | const struct terrain * | pterrain | ) |
Return the (translated) name of the terrain.
You don't have to free the return pointer.
Definition at line 175 of file terrain.cpp.
Referenced by api_methods_terrain_name_translation(), boot_help_texts(), do_paradrop(), editor_tool_get_value_name(), explain_why_no_action_enabled(), format_change_terrain_string(), helptext_extra(), illegal_action_msg(), insert_generated_text(), manual_command(), remove_city(), req_text_insert(), help_widget::set_topic_terrain(), terrain_by_translated_name(), tile_get_info_text(), universal_name_translation(), and worklist_item_postpone_req_vec().
| Terrain_type_id terrain_number | ( | const struct terrain * | pterrain | ) |
Return the terrain index.
Definition at line 119 of file terrain.cpp.
Referenced by editor_grab_tool(), fill_tile_edit_packet(), paste_tile(), send_ruleset_terrain(), send_tile_info(), tile_set_terrain(), and universal_number().
| const char* terrain_rule_name | ( | const struct terrain * | pterrain | ) |
Return the (untranslated) rule name of the terrain.
You don't have to free the return pointer.
Definition at line 184 of file terrain.cpp.
Referenced by api_methods_terrain_rule_name(), boot_help_texts(), compat_load_020600(), tab_terrains::delete_now(), tab_terrains::edit_effects(), fill_island(), handle_ruleset_terrain(), freeciv::layer_terrain::initialize_blending(), freeciv::layer_terrain::initialize_cell_corner_match_none(), freeciv::layer_terrain::initialize_cell_corner_match_pair(), freeciv::layer_terrain::initialize_cell_corner_match_same(), freeciv::layer_terrain::initialize_cell_whole_match_same(), freeciv::layer_terrain::initialize_terrain(), insert_generated_text(), manual_command(), tab_terrains::name_given(), print_mapgen_map(), tab_terrains::refresh(), regenerate_lakes(), sanity_check_ruleset_data(), save_nation(), save_terrain_ref(), sg_load_sanitycheck(), sg_load_savefile(), sg_save_savefile(), smooth_water_depth(), terrain_by_rule_name(), tile_set_terrain(), universal_kind_values(), universal_rule_name(), and tab_terrains::update_terrain_info().
| enum terrain_class terrain_type_terrain_class | ( | const struct terrain * | pterrain | ) |
What terrain class terrain type belongs to.
Definition at line 439 of file terrain.cpp.
Referenced by api_methods_terrain_class_name(), assign_continent_flood(), assign_continent_numbers(), count_terrain_class_near_tile(), freeciv::layer_water::fill_sprite_array(), helptext_terrain(), is_terrain_class_card_near(), is_terrain_class_near_tile(), most_adjacent_ocean_type(), pick_ocean(), real_distance_to_land(), recalculate_lake_surrounders(), regenerate_lakes(), and smooth_water_depth().
| void terrains_free | ( | ) |
Free memory which is associated with terrain types.
Definition at line 50 of file terrain.cpp.
Referenced by game_ruleset_free().
| void terrains_init | ( | ) |
Initialize terrain and resource structures.
Definition at line 34 of file terrain.cpp.
Referenced by game_ruleset_init().
| void user_terrain_flags_free | ( | ) |
Frees the memory associated with all user terrain flags.
Definition at line 661 of file terrain.cpp.
Referenced by game_ruleset_free().
| void user_terrain_flags_init | ( | ) |
Initialize user terrain type flags.
Definition at line 649 of file terrain.cpp.
Referenced by game_ruleset_init().
|
static |
Definition at line 1 of file terrain.cpp.
Referenced by terrain_array_first(), terrain_array_last(), terrain_by_number(), terrain_index(), and terrains_init().
|
static |
Definition at line 1 of file terrain.cpp.
Referenced by set_user_terrain_flag_name(), terrain_flag_helptxt(), terrain_flag_id_name_cb(), user_terrain_flags_free(), and user_terrain_flags_init().