The Battle for Wesnoth  1.15.2+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 ()
 
 terrain_type (const config &cfg)
 
 terrain_type (const terrain_type &base, const terrain_type &overlay)
 
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
 
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
 
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 21 of file terrain.hpp.

Constructor & Destructor Documentation

◆ terrain_type() [1/3]

terrain_type::terrain_type ( )
explicit

Definition at line 35 of file terrain.cpp.

◆ terrain_type() [2/3]

terrain_type::terrain_type ( const config cfg)
explicit
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 73 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, sort(), 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 54 of file terrain.hpp.

References def_type_.

◆ default_base()

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

◆ description()

const t_string& terrain_type::description ( ) const
inline

◆ editor_group()

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

Definition at line 131 of file terrain.hpp.

References editor_group_.

Referenced by terrain_type_data::lazy_initialization(), and editor::terrain_palette::setup().

◆ 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 36 of file terrain.hpp.

References help_topic_text_.

◆ hide_help()

bool terrain_type::hide_help ( ) const
inline

Definition at line 39 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 41 of file terrain.hpp.

References hide_if_impassable_.

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

◆ hide_in_editor()

bool terrain_type::hide_in_editor ( ) const
inline

Definition at line 40 of file terrain.hpp.

References hide_in_editor_.

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

◆ 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 126 of file terrain.hpp.

References income_description_.

Referenced by REPORT_GENERATOR().

◆ income_description_ally()

const t_string& terrain_type::income_description_ally ( ) const
inline

Definition at line 127 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 128 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 129 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

◆ is_indivisible() [1/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 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?

id the terrain underlying the corresponding mvt_type(), def_type() or union_type()

Definition at line 78 of file terrain.hpp.

References id().

Referenced by gui2::get_mp_tooltip(), and help::unit_topic_generator::operator()().

◆ is_indivisible() [2/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 88 of file terrain.hpp.

References number_, and union_type_.

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

◆ is_keep()

bool terrain_type::is_keep ( ) const
inline

◆ is_mvt_indivisible()

bool terrain_type::is_mvt_indivisible ( ) const
inline

Definition at line 92 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 107 of file terrain.hpp.

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

Referenced by help::generate_terrain_sections(), gui2::get_mp_tooltip(), help::unit_topic_generator::operator()(), and unit_moves().

◆ is_overlay()

bool terrain_type::is_overlay ( ) const
inline

Definition at line 134 of file terrain.hpp.

References overlay_.

Referenced by help::generate_terrain_sections().

◆ 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 111 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 game_lua_kernel::intf_get_terrain_info().

◆ minimap_image()

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

Definition at line 30 of file terrain.hpp.

References minimap_image_.

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

◆ minimap_image_overlay()

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

Definition at line 31 of file terrain.hpp.

References minimap_image_overlay_.

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

◆ 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 53 of file terrain.hpp.

References mvt_type_.

◆ 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 303 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_.

Referenced by default_base().

◆ set_editor_group()

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

Definition at line 132 of file terrain.hpp.

References editor_group_.

Referenced by terrain_type_data::lazy_initialization().

◆ 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 56 of file terrain.hpp.

References union_type_.

Referenced by unit_moves().

◆ unit_height_adjust()

int terrain_type::unit_height_adjust ( ) const
inline

Definition at line 116 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 117 of file terrain.hpp.

References submerge_.

Referenced by unit_drawer::redraw_unit().

◆ vision_type()

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

Definition at line 55 of file terrain.hpp.

References vision_type_.

Member Data Documentation

◆ castle_

bool terrain_type::castle_
private

Definition at line 203 of file terrain.hpp.

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

◆ combined_

bool terrain_type::combined_
private

Definition at line 205 of file terrain.hpp.

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

◆ def_type_

t_translation::ter_list terrain_type::def_type_
private

Definition at line 182 of file terrain.hpp.

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

◆ description_

t_string terrain_type::description_
private

Definition at line 172 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 206 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 201 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 168 of file terrain.hpp.

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

◆ editor_name_

t_string terrain_type::editor_name_
private

Definition at line 171 of file terrain.hpp.

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

◆ heals_

int terrain_type::heals_
private

Definition at line 194 of file terrain.hpp.

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

◆ height_adjust_

int terrain_type::height_adjust_
private

Definition at line 185 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 186 of file terrain.hpp.

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

◆ help_topic_text_

t_string terrain_type::help_topic_text_
private

Definition at line 173 of file terrain.hpp.

Referenced by help_topic_text().

◆ hide_help_

bool terrain_type::hide_help_
private

Definition at line 207 of file terrain.hpp.

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

◆ hide_if_impassable_

bool terrain_type::hide_if_impassable_
private

Definition at line 207 of file terrain.hpp.

Referenced by hide_if_impassable().

◆ hide_in_editor_

bool terrain_type::hide_in_editor_
private

Definition at line 207 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 158 of file terrain.hpp.

Referenced by icon_image().

◆ id_

std::string terrain_type::id_
private

Definition at line 169 of file terrain.hpp.

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

◆ income_description_

t_string terrain_type::income_description_
private

Definition at line 196 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 197 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 198 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 199 of file terrain.hpp.

Referenced by income_description_own(), and terrain_type().

◆ keep_

bool terrain_type::keep_
private

Definition at line 203 of file terrain.hpp.

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

◆ light_modification_

int terrain_type::light_modification_
private

Definition at line 191 of file terrain.hpp.

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

◆ max_light_

int terrain_type::max_light_
private

Definition at line 192 of file terrain.hpp.

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

◆ min_light_

int terrain_type::min_light_
private

Definition at line 193 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 161 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 162 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 180 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 170 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 205 of file terrain.hpp.

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

◆ submerge_

double terrain_type::submerge_
private

Definition at line 188 of file terrain.hpp.

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

◆ submerge_set_

bool terrain_type::submerge_set_
private

Definition at line 189 of file terrain.hpp.

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

◆ union_type_

t_translation::ter_list terrain_type::union_type_
private

Definition at line 183 of file terrain.hpp.

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

◆ village_

bool terrain_type::village_
private

Definition at line 203 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 181 of file terrain.hpp.

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


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