The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
terrain_type Class Reference

#include <terrain.hpp>

Public Member Functions

 terrain_type ()
 Creates an instance for which is_nonnull() returns false. More...
 
 terrain_type (const config &cfg)
 Constructor for terrains defined by a WML [terrain_type] tag. More...
 
 terrain_type (const terrain_type &base, const terrain_type &overlay)
 Used when a terrain code which hasn't been defined with a [terrain_type] tag is used in a map, to build the terrain from already-defined terrains. More...
 
const std::string & icon_image () const
 
const std::string & minimap_image () const
 
const std::string & minimap_image_overlay () const
 
const std::string & editor_image () const
 
const t_stringname () const
 
const t_stringeditor_name () const
 
const t_stringdescription () const
 
const t_stringhelp_topic_text () const
 
const std::string & id () const
 
bool hide_help () const
 For instances created from a [terrain_type] tag, the value in the tag (with default false). More...
 
bool hide_in_editor () const
 
bool hide_if_impassable () const
 
t_translation::terrain_code number () const
 
const t_translation::ter_listmvt_type () const
 The underlying type of the terrain. More...
 
const t_translation::ter_listdef_type () const
 
const t_translation::ter_listvision_type () const
 
const t_translation::ter_listunion_type () const
 
bool is_indivisible () const
 Returns true if this terrain has no underlying types other than itself. More...
 
bool is_mvt_indivisible () const
 
bool is_nonnull () const
 True if this object represents some sentinel values. More...
 
int light_bonus (int base) const
 Returns the light (lawful) bonus for this terrain when the time of day gives a base bonus. More...
 
int unit_height_adjust () const
 
double unit_submerge () const
 
int gives_healing () const
 
bool is_village () const
 
bool is_castle () const
 
bool is_keep () const
 
const t_stringincome_description () const
 
const t_stringincome_description_ally () const
 
const t_stringincome_description_enemy () const
 
const t_stringincome_description_own () const
 
const std::string & editor_group () const
 
void set_editor_group (const std::string &str)
 
bool is_overlay () const
 
bool is_combined () const
 True for instances created by the terrain_code(base, overlay) constructor. More...
 
t_translation::terrain_code default_base () const
 
t_translation::terrain_code terrain_with_default_base () const
 
bool operator== (const terrain_type &other) const
 Returns true if all most of the data matches. More...
 

Static Public Member Functions

static bool is_indivisible (t_translation::terrain_code id, const t_translation::ter_list &underlying)
 Returns true if a terrain has no underlying types other than itself, in respect of either union, movement or defense. More...
 

Private Attributes

std::string icon_image_
 The image used as symbol icon. More...
 
std::string minimap_image_
 The image used in the minimap. More...
 
std::string minimap_image_overlay_
 
std::string editor_image_
 The image used in the editor palette if not defined in WML it will be initialized with the value of minimap_image_. More...
 
std::string id_
 
t_string name_
 
t_string editor_name_
 
t_string description_
 
t_string help_topic_text_
 
t_translation::terrain_code number_
 
t_translation::ter_list mvt_type_
 
t_translation::ter_list vision_type_
 
t_translation::ter_list def_type_
 
t_translation::ter_list union_type_
 
int height_adjust_
 
bool height_adjust_set_
 
double submerge_
 
bool submerge_set_
 
int light_modification_
 
int max_light_
 
int min_light_
 
int heals_
 
t_string income_description_
 
t_string income_description_ally_
 
t_string income_description_enemy_
 
t_string income_description_own_
 
std::string editor_group_
 
bool village_
 
bool castle_
 
bool keep_
 
bool overlay_
 
bool combined_
 
t_translation::terrain_code editor_default_base_
 
bool hide_help_
 
bool hide_in_editor_
 
bool hide_if_impassable_
 

Detailed Description

Definition at line 22 of file terrain.hpp.

Constructor & Destructor Documentation

◆ terrain_type() [1/3]

terrain_type::terrain_type ( )
explicit

Creates an instance for which is_nonnull() returns false.

Used for the sentinel value when terrain_type_data::get_terrain_info() is called for an unknown terrain code.

Definition at line 34 of file terrain.cpp.

◆ terrain_type() [2/3]

terrain_type::terrain_type ( const config cfg)
explicit

Constructor for terrains defined by a WML [terrain_type] tag.

Todo:
reenable these validations. The problem is that all MP scenarios/campaigns share the same namespace and one rogue scenario can avoid the player to create a MP game. So every scenario/campaign should get its own namespace to be safe.

Definition at line 72 of file terrain.cpp.

References _(), def_type_, deprecated_message(), editor_image_, t_string::empty(), hide_in_editor_, income_description_, income_description_ally_, income_description_enemy_, income_description_own_, minimap_image_, t_translation::MINUS, missing_mandatory_wml_key(), mvt_type_, name_, t_translation::NONE_TERRAIN, number_, t_translation::PLUS, t_translation::read_list(), gui2::dialogs::tip::remove(), REMOVED, union_type_, VALIDATE, village_, vision_type_, and t_translation::write_terrain_code().

◆ terrain_type() [3/3]

terrain_type::terrain_type ( const terrain_type base,
const terrain_type overlay 
)
explicit

Member Function Documentation

◆ def_type()

const t_translation::ter_list& terrain_type::def_type ( ) const
inline

Definition at line 76 of file terrain.hpp.

References def_type_.

Referenced by help::terrain_topic_generator::operator()().

◆ default_base()

t_translation::terrain_code terrain_type::default_base ( ) const
inline

Definition at line 169 of file terrain.hpp.

References editor_default_base_.

Referenced by editor::terrain_palette::setup_item().

◆ description()

const t_string& terrain_type::description ( ) const
inline

◆ editor_group()

const std::string& terrain_type::editor_group ( ) const
inline

◆ editor_image()

const std::string& terrain_type::editor_image ( ) const
inline

◆ editor_name()

const t_string& terrain_type::editor_name ( ) const
inline

◆ gives_healing()

int terrain_type::gives_healing ( ) const
inline

◆ help_topic_text()

const t_string& terrain_type::help_topic_text ( ) const
inline

Definition at line 51 of file terrain.hpp.

References help_topic_text_.

Referenced by help::terrain_topic_generator::operator()().

◆ hide_help()

bool terrain_type::hide_help ( ) const
inline

For instances created from a [terrain_type] tag, the value in the tag (with default false).

Always true for instances generated by the terrain_type(base, overlay) constructor.

Definition at line 61 of file terrain.hpp.

References hide_help_.

Referenced by help::generate_terrain_sections().

◆ hide_if_impassable()

bool terrain_type::hide_if_impassable ( ) const
inline

Definition at line 63 of file terrain.hpp.

References hide_if_impassable_.

◆ hide_in_editor()

bool terrain_type::hide_in_editor ( ) const
inline

◆ icon_image()

const std::string& terrain_type::icon_image ( ) const
inline

◆ id()

const std::string& terrain_type::id ( ) const
inline

◆ income_description()

const t_string& terrain_type::income_description ( ) const
inline

Definition at line 147 of file terrain.hpp.

References income_description_.

Referenced by help::terrain_topic_generator::operator()(), and REPORT_GENERATOR().

◆ income_description_ally()

const t_string& terrain_type::income_description_ally ( ) const
inline

Definition at line 148 of file terrain.hpp.

References income_description_ally_.

Referenced by REPORT_GENERATOR().

◆ income_description_enemy()

const t_string& terrain_type::income_description_enemy ( ) const
inline

Definition at line 149 of file terrain.hpp.

References income_description_enemy_.

Referenced by REPORT_GENERATOR().

◆ income_description_own()

const t_string& terrain_type::income_description_own ( ) const
inline

Definition at line 150 of file terrain.hpp.

References income_description_own_.

Referenced by REPORT_GENERATOR().

◆ is_castle()

bool terrain_type::is_castle ( ) const
inline

◆ is_combined()

bool terrain_type::is_combined ( ) const
inline

True for instances created by the terrain_code(base, overlay) constructor.

False for instances created by the terrain_type(config) constructor, implying that they were created directly from a WML [terrain_type] tag.

Note that this returns false for terrains such as Dd^Dc (crater) and Mm^Xm (regular impassible mountains), because there are [terrain_type] tags for those specific combinations of base^overlay.

Definition at line 167 of file terrain.hpp.

References combined_.

Referenced by help::terrain_topic_generator::operator()(), and editor::terrain_palette::setup().

◆ is_indivisible() [1/2]

bool terrain_type::is_indivisible ( ) const
inline

Returns true if this terrain has no underlying types other than itself.

Todo:
what about a terrain where is_mvt_indivisible() != is_def_indivisible()?

Definition at line 110 of file terrain.hpp.

References number_, and union_type_.

Referenced by movetype::terrain_info::data::calc_value().

◆ is_indivisible() [2/2]

static bool terrain_type::is_indivisible ( t_translation::terrain_code  id,
const t_translation::ter_list underlying 
)
inlinestatic

Returns true if a terrain has no underlying types other than itself, in respect of either union, movement or defense.

If this returns false, then underlying must be non-empty.

This function is to encapsulate the logic of whether such a terrain is represented by a empty list, or whether it's represented by a list including only itself; so that a refactor can switch between these two possible implementations.

This is not related to whether the terrain has an overlay. For example, Gg^Uf (flat with old mushrooms) is indivisible (it's only Tt), although Gg^Tf (flat with new mushrooms) can be divided (in to Gt and Tt).

TODO: should this document vision_type() too?

Parameters
idthe terrain
underlyingthe corresponding mvt_type(), def_type() or union_type()

Definition at line 100 of file terrain.hpp.

Referenced by help::terrain_topic_generator::operator()().

◆ is_keep()

bool terrain_type::is_keep ( ) const
inline

◆ is_mvt_indivisible()

bool terrain_type::is_mvt_indivisible ( ) const
inline

Definition at line 114 of file terrain.hpp.

References mvt_type_, and number_.

◆ is_nonnull()

bool terrain_type::is_nonnull ( ) const
inline

True if this object represents some sentinel values.

Todo:

number_ should never be NONE_TERRAIN

there's two different VOID_TERRAINS - see the comment attached to the definition of VOID_TERRAIN.

Todo:
unclear what this should mean, so replace it with a clearly-named successor.

Definition at line 129 of file terrain.hpp.

References t_translation::NONE_TERRAIN, number_, and t_translation::VOID_TERRAIN.

Referenced by help::generate_terrain_sections(), and help::terrain_topic_generator::operator()().

◆ is_overlay()

bool terrain_type::is_overlay ( ) const
inline

Definition at line 155 of file terrain.hpp.

References overlay_.

Referenced by help::terrain_topic_generator::operator()().

◆ is_village()

bool terrain_type::is_village ( ) const
inline

◆ light_bonus()

int terrain_type::light_bonus ( int  base) const
inline

Returns the light (lawful) bonus for this terrain when the time of day gives a base bonus.

Definition at line 132 of file terrain.hpp.

References bounded_add(), light_modification_, max_light_, and min_light_.

Referenced by tod_manager::get_illuminated_time_of_day(), wfl::terrain_callable::get_value(), and help::terrain_topic_generator::operator()().

◆ minimap_image()

const std::string& terrain_type::minimap_image ( ) const
inline

Definition at line 45 of file terrain.hpp.

References minimap_image_.

Referenced by image::prep_minimap_for_rendering(), and terrain_builder::rebuild_terrain().

◆ minimap_image_overlay()

const std::string& terrain_type::minimap_image_overlay ( ) const
inline

◆ mvt_type()

const t_translation::ter_list& terrain_type::mvt_type ( ) const
inline

The underlying type of the terrain.

Whether "underlying" means "only the types used in [movetype]" is determined by the terrain.cfg file, rather than the .cpp code - in 1.14, the terrain.cfg file uses only the [movetype] terrains in its alias lists.

Definition at line 75 of file terrain.hpp.

References mvt_type_.

Referenced by help::terrain_topic_generator::operator()().

◆ name()

const t_string& terrain_type::name ( ) const
inline

◆ number()

t_translation::terrain_code terrain_type::number ( ) const
inline

◆ operator==()

bool terrain_type::operator== ( const terrain_type other) const

Returns true if all most of the data matches.

The ones that don't need to match:

  • editor_group_
  • icon_image_
  • description_
  • help_topic_text_
  • income_description_ , ~ally_ , ~enemy_, ~own_
  • hide_if_impassable_

The intention seems to be to allow additional [terrain_type] tags to add compatible definitions to multiple addon-specific editor groups. For this purpose the description strings aren't too important, and hide_if_impassable_ seems trivial.

Definition at line 302 of file terrain.cpp.

References t_string::base_str(), castle_, combined_, def_type_, editor_default_base_, editor_image_, editor_name_, heals_, height_adjust_, height_adjust_set_, hide_help_, hide_in_editor_, id_, keep_, light_modification_, max_light_, min_light_, minimap_image_, minimap_image_overlay_, mvt_type_, name_, number_, overlay_, submerge_, submerge_set_, union_type_, village_, and vision_type_.

◆ set_editor_group()

void terrain_type::set_editor_group ( const std::string &  str)
inline

Definition at line 153 of file terrain.hpp.

References editor_group_.

◆ terrain_with_default_base()

t_translation::terrain_code terrain_type::terrain_with_default_base ( ) const

◆ union_type()

const t_translation::ter_list& terrain_type::union_type ( ) const
inline

Definition at line 78 of file terrain.hpp.

References union_type_.

Referenced by help::terrain_topic_generator::operator()().

◆ unit_height_adjust()

int terrain_type::unit_height_adjust ( ) const
inline

Definition at line 137 of file terrain.hpp.

References height_adjust_.

Referenced by unit_animation_component::invalidate(), and unit_drawer::redraw_unit().

◆ unit_submerge()

double terrain_type::unit_submerge ( ) const
inline

Definition at line 138 of file terrain.hpp.

References submerge_.

Referenced by display::draw_hex(), and unit_drawer::redraw_unit().

◆ vision_type()

const t_translation::ter_list& terrain_type::vision_type ( ) const
inline

Definition at line 77 of file terrain.hpp.

References vision_type_.

Member Data Documentation

◆ castle_

bool terrain_type::castle_
private

Definition at line 235 of file terrain.hpp.

Referenced by is_castle(), and operator==().

◆ combined_

bool terrain_type::combined_
private

Definition at line 237 of file terrain.hpp.

Referenced by is_combined(), and operator==().

◆ def_type_

t_translation::ter_list terrain_type::def_type_
private

Definition at line 214 of file terrain.hpp.

Referenced by def_type(), operator==(), and terrain_type().

◆ description_

t_string terrain_type::description_
private

Definition at line 204 of file terrain.hpp.

Referenced by description(), and terrain_type().

◆ editor_default_base_

t_translation::terrain_code terrain_type::editor_default_base_
private

Definition at line 238 of file terrain.hpp.

Referenced by default_base(), operator==(), and terrain_with_default_base().

◆ editor_group_

std::string terrain_type::editor_group_
private

Definition at line 233 of file terrain.hpp.

Referenced by editor_group(), and set_editor_group().

◆ editor_image_

std::string terrain_type::editor_image_
private

The image used in the editor palette if not defined in WML it will be initialized with the value of minimap_image_.

Definition at line 200 of file terrain.hpp.

Referenced by editor_image(), operator==(), and terrain_type().

◆ editor_name_

t_string terrain_type::editor_name_
private

Definition at line 203 of file terrain.hpp.

Referenced by editor_name(), and operator==().

◆ heals_

int terrain_type::heals_
private

Definition at line 226 of file terrain.hpp.

Referenced by gives_healing(), and operator==().

◆ height_adjust_

int terrain_type::height_adjust_
private

Definition at line 217 of file terrain.hpp.

Referenced by operator==(), terrain_type(), and unit_height_adjust().

◆ height_adjust_set_

bool terrain_type::height_adjust_set_
private

Definition at line 218 of file terrain.hpp.

Referenced by operator==(), and terrain_type().

◆ help_topic_text_

t_string terrain_type::help_topic_text_
private

Definition at line 205 of file terrain.hpp.

Referenced by help_topic_text().

◆ hide_help_

bool terrain_type::hide_help_
private

Definition at line 239 of file terrain.hpp.

Referenced by hide_help(), and operator==().

◆ hide_if_impassable_

bool terrain_type::hide_if_impassable_
private

Definition at line 239 of file terrain.hpp.

Referenced by hide_if_impassable().

◆ hide_in_editor_

bool terrain_type::hide_in_editor_
private

Definition at line 239 of file terrain.hpp.

Referenced by hide_in_editor(), operator==(), and terrain_type().

◆ icon_image_

std::string terrain_type::icon_image_
private

The image used as symbol icon.

Definition at line 190 of file terrain.hpp.

Referenced by icon_image().

◆ id_

std::string terrain_type::id_
private

Definition at line 201 of file terrain.hpp.

Referenced by id(), and operator==().

◆ income_description_

t_string terrain_type::income_description_
private

Definition at line 228 of file terrain.hpp.

Referenced by income_description(), and terrain_type().

◆ income_description_ally_

t_string terrain_type::income_description_ally_
private

Definition at line 229 of file terrain.hpp.

Referenced by income_description_ally(), and terrain_type().

◆ income_description_enemy_

t_string terrain_type::income_description_enemy_
private

Definition at line 230 of file terrain.hpp.

Referenced by income_description_enemy(), and terrain_type().

◆ income_description_own_

t_string terrain_type::income_description_own_
private

Definition at line 231 of file terrain.hpp.

Referenced by income_description_own(), and terrain_type().

◆ keep_

bool terrain_type::keep_
private

Definition at line 235 of file terrain.hpp.

Referenced by is_keep(), and operator==().

◆ light_modification_

int terrain_type::light_modification_
private

Definition at line 223 of file terrain.hpp.

Referenced by light_bonus(), and operator==().

◆ max_light_

int terrain_type::max_light_
private

Definition at line 224 of file terrain.hpp.

Referenced by light_bonus(), and operator==().

◆ min_light_

int terrain_type::min_light_
private

Definition at line 225 of file terrain.hpp.

Referenced by light_bonus(), and operator==().

◆ minimap_image_

std::string terrain_type::minimap_image_
private

The image used in the minimap.

Definition at line 193 of file terrain.hpp.

Referenced by minimap_image(), operator==(), and terrain_type().

◆ minimap_image_overlay_

std::string terrain_type::minimap_image_overlay_
private

Definition at line 194 of file terrain.hpp.

Referenced by minimap_image_overlay(), and operator==().

◆ mvt_type_

t_translation::ter_list terrain_type::mvt_type_
private

Definition at line 212 of file terrain.hpp.

Referenced by is_mvt_indivisible(), mvt_type(), operator==(), and terrain_type().

◆ name_

t_string terrain_type::name_
private

Definition at line 202 of file terrain.hpp.

Referenced by description(), name(), operator==(), and terrain_type().

◆ number_

t_translation::terrain_code terrain_type::number_
private

◆ overlay_

bool terrain_type::overlay_
private

Definition at line 237 of file terrain.hpp.

Referenced by is_overlay(), operator==(), and terrain_with_default_base().

◆ submerge_

double terrain_type::submerge_
private

Definition at line 220 of file terrain.hpp.

Referenced by operator==(), terrain_type(), and unit_submerge().

◆ submerge_set_

bool terrain_type::submerge_set_
private

Definition at line 221 of file terrain.hpp.

Referenced by operator==(), and terrain_type().

◆ union_type_

t_translation::ter_list terrain_type::union_type_
private

Definition at line 215 of file terrain.hpp.

Referenced by is_indivisible(), operator==(), terrain_type(), and union_type().

◆ village_

bool terrain_type::village_
private

Definition at line 235 of file terrain.hpp.

Referenced by is_village(), operator==(), and terrain_type().

◆ vision_type_

t_translation::ter_list terrain_type::vision_type_
private

Definition at line 213 of file terrain.hpp.

Referenced by operator==(), terrain_type(), and vision_type().


The documentation for this class was generated from the following files: