The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
terrain.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 #ifndef TERRAIN_H_INCLUDED
15 #define TERRAIN_H_INCLUDED
16 
17 #include "config.hpp"
18 #include "terrain/translation.hpp"
19 #include "util.hpp"
20 
22 {
23 public:
24 
25  terrain_type();
26  terrain_type(const config& cfg);
27  terrain_type(const terrain_type& base, const terrain_type& overlay);
28 
29  const std::string& icon_image() const { return icon_image_; }
30  const std::string& minimap_image() const { return minimap_image_; }
32  const std::string& editor_image() const { return editor_image_; }
33  const t_string& name() const { return name_; }
34  const t_string& editor_name() const { return editor_name_.empty() ? description() : editor_name_; }
35  const t_string& description() const { return description_.empty() ? name_ : description_; }
36  const t_string& help_topic_text() const { return help_topic_text_; }
37  const std::string& id() const { return id_; }
38 
39  bool hide_help() const { return hide_help_; }
40  bool hide_in_editor() const { return hide_in_editor_; }
41 
42  //the character representing this terrain
44 
45  //the underlying type of the terrain
46  const t_translation::t_list& mvt_type() const { return mvt_type_; }
47  const t_translation::t_list& def_type() const { return def_type_; }
48  const t_translation::t_list& vision_type() const { return vision_type_; }
49  const t_translation::t_list& union_type() const { return union_type_; }
50 
51  bool is_nonnull() const { return (number_ != t_translation::NONE_TERRAIN) &&
53  /// Returns the light (lawful) bonus for this terrain when the time of day
54  /// gives a @a base bonus.
55  int light_bonus(int base) const
57 
58  int unit_height_adjust() const { return height_adjust_; }
59  double unit_submerge() const { return submerge_; }
60 
61  int gives_healing() const { return heals_; }
62  bool is_village() const { return village_; }
63  bool is_castle() const { return castle_; }
64  bool is_keep() const { return keep_; }
65 
66  //these descriptions are shown for the terrain in the mouse over
67  //depending on the owner or the village
68  const t_string& income_description() const { return income_description_; }
72 
73  const std::string& editor_group() const { return editor_group_; }
74  void set_editor_group(const std::string& str) { editor_group_ = str; }
75 
76  bool is_overlay() const { return overlay_; }
77  bool is_combined() const { return combined_; }
78 
81 
82  bool operator==(const terrain_type& other) const;
83 private:
84 
85  /** The image used as symbol icon */
87 
88  /** The image used in the minimap */
91 
92  /**
93  * The image used in the editor palette if not defined in WML it will be
94  * initialized with the value of minimap_image_
95  */
102 
103  //the 'number' is the number that represents this
104  //terrain type. The 'type' is a list of the 'underlying types'
105  //of the terrain. This may simply be the same as the number.
106  //This is the internal number used, WML still uses character strings.
112 
115 
116  double submerge_;
118 
122  int heals_;
123 
128 
130 
132 
136 };
137 
139  t_translation::t_list& terrain_list,
140  std::map<t_translation::t_terrain, terrain_type>& letter_to_terrain);
141 
143 
144 #endif
bool height_adjust_set_
Definition: terrain.hpp:114
std::string minimap_image_overlay_
Definition: terrain.hpp:90
const t_string & help_topic_text() const
Definition: terrain.hpp:36
bool operator==(const terrain_type &other) const
Definition: terrain.cpp:292
const t_translation::t_list & def_type() const
Definition: terrain.hpp:47
const t_string & income_description_enemy() const
Definition: terrain.hpp:70
t_translation::t_terrain number_
Definition: terrain.hpp:107
void merge_alias_lists(t_translation::t_list &first, const t_translation::t_list &second)
Definition: terrain.cpp:367
t_string name_
Definition: terrain.hpp:98
const t_terrain NONE_TERRAIN
Definition: translation.hpp:56
const std::string & minimap_image_overlay() const
Definition: terrain.hpp:31
std::string id_
Definition: terrain.hpp:97
bool hide_in_editor_
Definition: terrain.hpp:135
t_translation::t_list mvt_type_
Definition: terrain.hpp:108
t_string income_description_
Definition: terrain.hpp:124
void create_terrain_maps(const config::const_child_itors &cfgs, t_translation::t_list &terrain_list, std::map< t_translation::t_terrain, terrain_type > &letter_to_terrain)
Definition: terrain.cpp:316
std::string editor_image_
The image used in the editor palette if not defined in WML it will be initialized with the value of m...
Definition: terrain.hpp:96
bool combined_
Definition: terrain.hpp:133
bool hide_in_editor() const
Definition: terrain.hpp:40
bool hide_help_
Definition: terrain.hpp:135
const t_string & name() const
Definition: terrain.hpp:33
bool is_overlay() const
Definition: terrain.hpp:76
const std::string & id() const
Definition: terrain.hpp:37
const t_translation::t_list & union_type() const
Definition: terrain.hpp:49
bool is_combined() const
Definition: terrain.hpp:77
int light_bonus(int base) const
Returns the light (lawful) bonus for this terrain when the time of day gives a base bonus...
Definition: terrain.hpp:55
const std::string & editor_group() const
Definition: terrain.hpp:73
Definitions for the interface to Wesnoth Markup Language (WML).
const t_string & editor_name() const
Definition: terrain.hpp:34
t_string description_
Definition: terrain.hpp:100
t_string income_description_own_
Definition: terrain.hpp:127
std::pair< const_child_iterator, const_child_iterator > const_child_itors
Definition: config.hpp:214
std::string editor_group_
Definition: terrain.hpp:129
const t_string & income_description_own() const
Definition: terrain.hpp:71
int unit_height_adjust() const
Definition: terrain.hpp:58
const t_translation::t_list & mvt_type() const
Definition: terrain.hpp:46
t_string income_description_ally_
Definition: terrain.hpp:125
int gives_healing() const
Definition: terrain.hpp:61
const std::string & editor_image() const
Definition: terrain.hpp:32
bool submerge_set_
Definition: terrain.hpp:117
t_translation::t_terrain number() const
Definition: terrain.hpp:43
t_translation::t_terrain default_base() const
Definition: terrain.hpp:79
t_translation::t_terrain editor_default_base_
Definition: terrain.hpp:134
int max_light_
Definition: terrain.hpp:120
bool is_village() const
Definition: terrain.hpp:62
Templates and utility-routines for strings and numbers.
double submerge_
Definition: terrain.hpp:116
bool is_nonnull() const
Definition: terrain.hpp:51
double unit_submerge() const
Definition: terrain.hpp:59
bool hide_help() const
Definition: terrain.hpp:39
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
Definition: translation.hpp:47
int height_adjust_
Definition: terrain.hpp:113
bool is_keep() const
Definition: terrain.hpp:64
const t_string & income_description_ally() const
Definition: terrain.hpp:69
t_translation::t_terrain terrain_with_default_base() const
Definition: terrain.cpp:285
t_translation::t_list vision_type_
Definition: terrain.hpp:109
std::string minimap_image_
The image used in the minimap.
Definition: terrain.hpp:89
bool castle_
Definition: terrain.hpp:131
bool village_
Definition: terrain.hpp:131
const t_terrain VOID_TERRAIN
t_string income_description_enemy_
Definition: terrain.hpp:126
int bounded_add(int base, int increment, int max_sum, int min_sum=0)
Returns base + increment, but will not increase base above max_sum, nor decrease it below min_sum...
Definition: util.hpp:44
int light_modification_
Definition: terrain.hpp:119
void set_editor_group(const std::string &str)
Definition: terrain.hpp:74
t_translation::t_list def_type_
Definition: terrain.hpp:110
const t_translation::t_list & vision_type() const
Definition: terrain.hpp:48
bool overlay_
Definition: terrain.hpp:133
int min_light_
Definition: terrain.hpp:121
GLint * first
Definition: glew.h:1496
t_translation::t_list union_type_
Definition: terrain.hpp:111
t_string help_topic_text_
Definition: terrain.hpp:101
std::string icon_image_
The image used as symbol icon.
Definition: terrain.hpp:86
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
bool is_castle() const
Definition: terrain.hpp:63
const t_string & description() const
Definition: terrain.hpp:35
const std::string & minimap_image() const
Definition: terrain.hpp:30
const t_string & income_description() const
Definition: terrain.hpp:68
GLsizei const GLcharARB ** string
Definition: glew.h:4503
const std::string & icon_image() const
Definition: terrain.hpp:29
bool empty() const
Definition: tstring.hpp:166
std::vector< t_terrain > t_list
Definition: translation.hpp:75
t_string editor_name_
Definition: terrain.hpp:99