1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D is free software; you can redistribute it and/or modify
7 //    it under the terms of the GNU General Public License as published by
8 //    the Free Software Foundation; either version 2 of the License, or
9 //    (at your option) any later version.
10 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #if !defined(__INCLUDE_LandscapeDefnh_INCLUDE__)
22 #define __INCLUDE_LandscapeDefnh_INCLUDE__
23 
24 #include <landscapedef/LandscapeTexDefn.h>
25 #include <common/fixed.h>
26 #include <coms/ComsMessage.h>
27 #include <XML/XMLFile.h>
28 #include <string>
29 
30 class LandscapeDefnType
31 {
32 public:
33 	enum DefnType
34 	{
35 		eNone,
36 		eStartHeight,
37 		eRoofCavern,
38 		eHeightMapFile,
39 		eHeightMapGenerate,
40 		eDeformDeform,
41 		eDeformSolid,
42 		eDeformFile
43 	};
44 
45 	virtual bool readXML(XMLNode *node) = 0;
46 	virtual DefnType getType() = 0;
47 };
48 
49 class LandscapeDefnTypeNone : public LandscapeDefnType
50 {
51 public:
52 	virtual bool readXML(XMLNode *node);
getType()53 	virtual DefnType getType() { return eNone; }
54 };
55 
56 class LandscapeDefnStartHeight : public LandscapeDefnType
57 {
58 public:
59 	fixed flatness;
60 	fixed startcloseness;
61 	fixed heightmin, heightmax;
62 	std::string startmask;
63 
64 	virtual bool readXML(XMLNode *node);
getType()65 	virtual DefnType getType() { return eStartHeight; }
66 };
67 
68 class LandscapeDefnRoofCavern : public LandscapeDefnType
69 {
70 public:
71 	LandscapeDefnRoofCavern();
72 	virtual ~LandscapeDefnRoofCavern();
73 
74 	fixed width;
75 	fixed height;
76 	LandscapeDefnType *heightmap;
77 	LandscapeDefnType *deform;
78 
79 	virtual bool readXML(XMLNode *node);
getType()80 	virtual DefnType getType() { return eRoofCavern; }
81 };
82 
83 class LandscapeDefnDeformFile : public LandscapeDefnType
84 {
85 public:
86 	std::string file;
87 	bool levelsurround;
88 
89 	virtual bool readXML(XMLNode *node);
getType()90 	virtual DefnType getType() { return eDeformFile; }
91 };
92 
93 class LandscapeDefnDeformSolid : public LandscapeDefnType
94 {
95 public:
96 	virtual bool readXML(XMLNode *node);
getType()97 	virtual DefnType getType() { return eDeformSolid; }
98 };
99 
100 class LandscapeDefnDeformDeform : public LandscapeDefnType
101 {
102 public:
103 	virtual bool readXML(XMLNode *node);
getType()104 	virtual DefnType getType() { return eDeformDeform; }
105 };
106 
107 class LandscapeDefnHeightMapFile : public LandscapeDefnType
108 {
109 public:
110 	std::string file;
111 	bool levelsurround;
112 
113 	virtual bool readXML(XMLNode *node);
getType()114 	virtual DefnType getType() { return eHeightMapFile; }
115 };
116 
117 class LandscapeDefnHeightMapGenerate : public LandscapeDefnType
118 {
119 public:
120 	std::string mask;
121 
122 	fixed noisefactor;
123 	int noisewidth, noiseheight;
124 
125 	int errosions;
126 	int errosionlayering, errosionsurroundsize;
127 	fixed errosionforce, errosionmaxdepth;
128 	fixed errosionsurroundforce;
129 
130 	int landhillsmax, landhillsmin;
131 	fixed landheightmax, landheightmin;
132 	fixed landpeakwidthxmax, landpeakwidthxmin;
133 	fixed landpeakwidthymax, landpeakwidthymin;
134 	fixed landpeakheightmax, landpeakheightmin;
135 	fixed landsmoothing;
136 	bool levelsurround;
137 
138 	virtual bool readXML(XMLNode *node);
getType()139 	virtual DefnType getType() { return eHeightMapGenerate; }
140 };
141 
142 class LandscapeDefn
143 {
144 public:
145 	LandscapeDefn();
146 	virtual ~LandscapeDefn();
147 
getMinPlayers()148 	int getMinPlayers() { return minplayers; }
getMaxPlayers()149 	int getMaxPlayers() { return maxplayers; }
getLandscapeWidth()150 	int getLandscapeWidth() { return landscapewidth; }
getLandscapeHeight()151 	int getLandscapeHeight() { return landscapeheight; }
getArenaWidth()152 	int getArenaWidth() { return arenawidth; }
getArenaHeight()153 	int getArenaHeight() { return arenaheight; }
getArenaX()154 	int getArenaX() { return arenax; }
getArenaY()155 	int getArenaY() { return arenay; }
156 
157 	LandscapeDefnType *roof;
158 	LandscapeDefnType *tankstart;
159 	LandscapeDefnType *heightmap;
160 	LandscapeDefnType *deform;
161 	LandscapeTexDefn texDefn;
162 
163 	bool readXML(LandscapeDefinitions *definitions, XMLNode *node);
164 
165 protected:
166 	int minplayers, maxplayers;
167 	int landscapewidth, landscapeheight;
168 	int arenawidth, arenaheight;
169 	int arenax, arenay;
170 
171 private:
172 	LandscapeDefn(const LandscapeDefn &other);
173 	LandscapeDefn &operator=(LandscapeDefn &other);
174 
175 };
176 
177 #endif
178