-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
terrain_type_data.hpp
92 lines (75 loc) · 3.54 KB
/
terrain_type_data.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Copyright (C) 2014 by Chris Beck <render787@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef TERRAIN_TYPE_DATA_HPP_INCLUDED
#define TERRAIN_TYPE_DATA_HPP_INCLUDED
#include "terrain.hpp"
#include <boost/shared_ptr.hpp>
#include <map>
class terrain_type_data {
private:
mutable t_translation::t_list terrainList_;
mutable std::map<t_translation::t_terrain, terrain_type> tcodeToTerrain_;
mutable bool initialized_;
const config & game_config_;
public:
terrain_type_data(const config & game_config);
const t_translation::t_list & list() const;
const std::map<t_translation::t_terrain, terrain_type> & map() const;
/**
* Get the corresponding terrain_type information object
* for a given type of terrain.
*/
const terrain_type& get_terrain_info(const t_translation::t_terrain & terrain) const;
// The name of the terrain is the terrain itself,
// The underlying terrain is the name of the terrain for game-logic purposes.
// I.e. if the terrain is simply an alias, the underlying terrain name
// is the name of the terrain that it's aliased to.
const t_translation::t_list& underlying_mvt_terrain(const t_translation::t_terrain & terrain) const;
const t_translation::t_list& underlying_def_terrain(const t_translation::t_terrain & terrain) const;
const t_translation::t_list& underlying_union_terrain(const t_translation::t_terrain & terrain) const;
/**
* Get a formatted terrain name -- terrain (underlying, terrains)
*/
std::string get_terrain_string(const t_translation::t_terrain& terrain) const;
std::string get_terrain_editor_string(const t_translation::t_terrain& terrain) const;
std::string get_underlying_terrain_string(const t_translation::t_terrain& terrain) const;
bool is_village(const t_translation::t_terrain & terrain) const
{ return get_terrain_info(terrain).is_village(); }
int gives_healing(const t_translation::t_terrain & terrain) const
{ return get_terrain_info(terrain).gives_healing(); }
bool is_castle(const t_translation::t_terrain & terrain) const
{ return get_terrain_info(terrain).is_castle(); }
bool is_keep(const t_translation::t_terrain & terrain) const
{ return get_terrain_info(terrain).is_keep(); }
enum tmerge_mode {
BASE,
OVERLAY,
BOTH
};
/**
* Tries to merge old and new terrain using the merge_settings config
* Relevant parameters are "layer" and "replace_conflicting"
* "layer" specifies the layer that should be replaced (base or overlay, default is both).
* If "replace_conflicting" is true the new terrain will replace the old one if merging failed
* (using the default base if new terrain is an overlay terrain)
* Will return the resulting terrain or NONE_TERRAIN if merging failed
*/
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 find out if "terrain" can be created by combining two existing
* terrains Will add the resulting terrain to the terrain list if
* successful
*/
bool try_merge_terrains(const t_translation::t_terrain & terrain);
};
typedef boost::shared_ptr<terrain_type_data> tdata_cache;
#endif