The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
type_data.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Chris Beck <[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 
15 #ifndef TERRAIN_TYPE_DATA_HPP_INCLUDED
16 #define TERRAIN_TYPE_DATA_HPP_INCLUDED
17 
18 #include "terrain/terrain.hpp"
19 
20 #include <boost/shared_ptr.hpp>
21 #include <map>
22 
24 private:
26  mutable std::map<t_translation::t_terrain, terrain_type> tcodeToTerrain_;
27 
28  mutable bool initialized_;
30 
31 public:
33 
34  const t_translation::t_list & list() const;
35  const std::map<t_translation::t_terrain, terrain_type> & map() const;
36 
37  /**
38  * Get the corresponding terrain_type information object
39  * for a given type of terrain.
40  */
42 
43  // The name of the terrain is the terrain itself,
44  // The underlying terrain is the name of the terrain for game-logic purposes.
45  // I.e. if the terrain is simply an alias, the underlying terrain name
46  // is the name of the terrain that it's aliased to.
50  /**
51  * Get a formatted terrain name -- terrain (underlying, terrains)
52  */
56 
58  { return get_terrain_info(terrain).is_village(); }
60  { return get_terrain_info(terrain).gives_healing(); }
62  { return get_terrain_info(terrain).is_castle(); }
64  { return get_terrain_info(terrain).is_keep(); }
65 
66  enum tmerge_mode {
70  };
71 
72  /**
73  * Tries to merge old and new terrain using the merge_settings config
74  * Relevant parameters are "layer" and "replace_conflicting"
75  * "layer" specifies the layer that should be replaced (base or overlay, default is both).
76  * If "replace_conflicting" is true the new terrain will replace the old one if merging failed
77  * (using the default base if new terrain is an overlay terrain)
78  * Will return the resulting terrain or NONE_TERRAIN if merging failed
79  */
80  t_translation::t_terrain merge_terrains(const t_translation::t_terrain & old_t, const t_translation::t_terrain & new_t, const tmerge_mode mode, bool replace_if_failed = false);
81 
82  /**
83  * Tries to find out if "terrain" can be created by combining two existing
84  * terrains Will add the resulting terrain to the terrain list if
85  * successful
86  */
88 
89 };
90 
92 #endif
const t_translation::t_list & underlying_union_terrain(const t_translation::t_terrain &terrain) const
Definition: type_data.cpp:93
t_translation::t_terrain merge_terrains(const t_translation::t_terrain &old_t, const t_translation::t_terrain &new_t, const tmerge_mode mode, bool replace_if_failed=false)
Tries to merge old and new terrain using the merge_settings config Relevant parameters are "layer" an...
Definition: type_data.cpp:177
bool is_keep(const t_translation::t_terrain &terrain) const
Definition: type_data.hpp:63
GLenum mode
Definition: glew.h:2390
bool is_village(const t_translation::t_terrain &terrain) const
Definition: type_data.hpp:57
int gives_healing() const
Definition: terrain.hpp:61
boost::shared_ptr< terrain_type_data > tdata_cache
Definition: type_data.hpp:91
const terrain_type & get_terrain_info(const t_translation::t_terrain &terrain) const
Get the corresponding terrain_type information object for a given type of terrain.
Definition: type_data.cpp:53
bool try_merge_terrains(const t_translation::t_terrain &terrain)
Tries to find out if "terrain" can be created by combining two existing terrains Will add the resulti...
Definition: type_data.cpp:156
std::string get_terrain_editor_string(const t_translation::t_terrain &terrain) const
Definition: type_data.cpp:119
static const ::config * terrain
The terrain used to create the cache.
Definition: minimap.cpp:135
bool is_village() const
Definition: terrain.hpp:62
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
const std::map< t_translation::t_terrain, terrain_type > & map() const
Definition: type_data.cpp:42
const t_translation::t_list & underlying_def_terrain(const t_translation::t_terrain &terrain) const
Definition: type_data.cpp:79
const t_translation::t_list & list() const
Definition: type_data.cpp:31
bool is_keep() const
Definition: terrain.hpp:64
Game configuration data as global variables.
Definition: build_info.cpp:38
std::string get_terrain_string(const t_translation::t_terrain &terrain) const
Get a formatted terrain name – terrain (underlying, terrains)
Definition: type_data.cpp:109
int gives_healing(const t_translation::t_terrain &terrain) const
Definition: type_data.hpp:59
std::string get_underlying_terrain_string(const t_translation::t_terrain &terrain) const
Definition: type_data.cpp:136
t_translation::t_list terrainList_
Definition: type_data.hpp:25
terrain_type_data(const config &game_config)
Definition: type_data.cpp:23
bool is_castle(const t_translation::t_terrain &terrain) const
Definition: type_data.hpp:61
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
std::map< t_translation::t_terrain, terrain_type > tcodeToTerrain_
Definition: type_data.hpp:26
const config & game_config_
Definition: type_data.hpp:29
GLsizei const GLcharARB ** string
Definition: glew.h:4503
std::vector< t_terrain > t_list
Definition: translation.hpp:75
const t_translation::t_list & underlying_mvt_terrain(const t_translation::t_terrain &terrain) const
Definition: type_data.cpp:65