Add custom formatter for regen text
[ryzomcore.git] / ryzom / client / src / continent.h
blobf48b4b043316ecae0ee90df66867e948c25cb0b5
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CL_CONTINENT_H
20 #define CL_CONTINENT_H
23 /////////////
24 // INCLUDE //
25 /////////////
26 // Misc
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/vector.h"
29 #include "nel/misc/rgba.h"
30 // Game share
31 #include "game_share/season.h"
32 #include "game_share/dir_light_setup.h"
33 // Client sheets
34 #include "client_sheets/continent_sheet.h"
36 #include "streamable_entity_composite.h"
37 #include "fog_map.h"
38 #include "game_share/fog_of_war.h"
39 #include "game_share/fog_type.h"
40 #include "game_share/time_weather_season/weather_function.h"
41 #include "sky_material_setup.h"
42 #include "outpost.h"
44 #include "sky.h" // new style sky
46 #include "water_map.h"
48 #include "continent_manager_build.h"
50 struct IIGEnum;
51 struct IIGAdded;
54 ///////////
55 // CLASS //
56 ///////////
57 namespace NLMISC
59 class CVectorD;
60 class IProgressCallback;
63 namespace NL3D
65 class UDriver;
68 struct CFogState;
70 // Landmark created by the user
71 class CUserLandMark
74 public:
76 enum EUserLandMarkType
78 Misc = 0,
79 Tribe,
80 Bandit,
81 Citizen,
82 Fauna,
83 FaunaExcel,
84 FaunaSup,
85 Forage,
86 ForageExcel,
87 ForageSup,
88 Sap,
89 Amber,
90 Node,
91 Fiber,
92 Bark,
93 Seed,
94 Shell,
95 Resin,
96 Wood,
97 Oil,
98 Mission,
99 Food,
100 Construction,
101 Goo,
102 Insect,
103 Kitin,
104 Nocive,
105 Preservative,
106 Passage,
107 Teleporter,
108 UserLandMarkTypeCount
111 NLMISC::CVector2f Pos; // Pos in local map
112 ucstring Title; // FIXME: UTF-8 (serial)
113 uint8 Type;
115 //User LandMarks Colors
116 static NLMISC::CRGBA _LandMarksColor[UserLandMarkTypeCount];
118 public:
121 CUserLandMark()
123 Type = Misc;
126 /// Get user landmark color
127 NLMISC::CRGBA getColor () const;
129 void serial(NLMISC::IStream &f)
131 f.serial(Pos, Title, Type);
137 * Class to manage the fog of war over a continent
138 * \author Matthieu 'Trap' Besson
139 * \author Nevrax France
140 * \date June 2004
142 class CFogOfWar : public IFogOfWar
145 public:
147 NL3D::UTextureMem *Tx; // Here store the real size
149 public:
151 CFogOfWar()
153 Tx = NULL;
156 ~CFogOfWar();
158 void load(const std::string &contName);
159 void save(const std::string &contName);
161 // Implementation of IFogOfWar
162 virtual uint8 *getData();
163 virtual bool createData(sint16 w, sint16 h);
164 virtual void explored(sint16 mapPosX, sint16 mapPosY);
165 virtual sint16 getRealWidth();
166 virtual sint16 getRealHeight();
171 * Class to manage a continent.
172 * \author Guillaume PUZIN (GUIGUI)
173 * \author Nevrax France
174 * \date 2001
176 class CContinent : public CContinentParameters
178 public:
179 // name of the sheet used to create the continent
180 std::string SheetName;
184 // backup setup of sky for day
185 CSkyMaterialSetup DaySkySetup;
187 // backup setup of sky for day
188 CSkyMaterialSetup NightSkySetup;
190 // Fog map
191 CFogMap FogMap;
193 // Water map
194 CWaterMap WaterMap;
196 // Selected season
197 EGSPD::CSeason::TSeason Season;
199 // A group of village
200 CStreamableEntityComposite _Villages;
202 // A group of outposts
203 std::vector<COutpost> _Outposts;
205 // The current sky
206 CSky CurrentSky;
208 // Weather functions for each season
209 CWeatherFunction WeatherFunction[EGSPD::CSeason::Invalid];
211 // user landmarks (saved)
212 std::vector<CUserLandMark> UserLandMarks;
214 // continent landmarks (not saved but static data)
215 std::vector<CContLandMark> ContLandMarks;
217 // Continent occupation zone
218 NLLIGO::CPrimZone Zone;
220 // Center of the occupation zone
221 NLMISC::CVector2f ZoneCenter;
223 // bool Newbie;
225 CFogOfWar FoW;
227 public:
228 /// Constructor
229 CContinent();
231 /// setup the continent from a sheet (use the SheetName that MUST be set)
232 void setup();
235 * Update global parameters like the texture for the micro veget.
237 void select(const NLMISC::CVectorD &pos, NLMISC::IProgressCallback &progress, bool complete, bool unhibernate, EGSPD::CSeason::TSeason season);
239 /// This will remove extra rsc used by the continent (fog maps ..)
240 void unselect();
242 /** Test whether the next call to updateStreamable will be blocking.
243 * This happen for example when the player is too near of a village and when asynchronous loading is not sufficient.
244 * \param pos player position
246 bool isLoadingforced(const NLMISC::CVector &playerPos) const;
248 /** Given the position of the player, load / unload objects (asynchronously when possible)
250 void updateStreamable(const NLMISC::CVector &playerPos);
252 /** Given the position of the player, load / unload objects (always in a synchronous fashion)
254 void forceUpdateStreamable(const NLMISC::CVector &playerPos, NLMISC::IProgressCallback &progress);
256 /** Remove all villages from the continents
258 void removeVillages();
260 // Get a outpost
261 COutpost *getOutpost (uint i);
263 // get fog
264 void getFogState(TFogType fogType, float dayNight, float duskRatio, CLightCycleManager::TLightState lightState, const NLMISC::CVectorD &pos, CFogState &result, bool overideByWeatherFogDist = true);
268 /** Enum ig of the continent
269 * (for now, these are currently instanciated villages)
270 * \return false if the enumeration has been stopped
272 bool enumIGs(IIGEnum *callback);
275 ///\name ig added observers.
276 //@{
277 void registerObserver(IIGObserver *obs);
278 void removeObserver(IIGObserver *obs);
279 bool isObserver(IIGObserver *obs) const;
280 //@}
282 // load (or reload) the micro-life primitives
283 void loadMicroLife();
285 // init the water map
286 void initWaterMap();
288 /** get corners min / zone max
289 * \return true if success
291 bool getCorners(NLMISC::CVector2f &cornerMin, NLMISC::CVector2f &cornerMax) const;
293 // dump village loading zones in a bitmap
294 void dumpVillagesLoadingZones(const std::string &filename);
296 enum TChannel { ChannelR = 0, ChannelG = 1, ChannelB = 2, ChannelA = 3, ChannelRGBA };
297 // dump fog map, blended with continent map, and with camera pos
298 // If a single channel is used, then channelLookup is used pick up the final color
299 void dumpFogMap(CFogMapBuild::TMapType mapType, const std::string &filename, TChannel channel = ChannelRGBA, const CRGBA channelLookup[256] = NULL);
301 void reloadFogMap();
303 // init release the sky
304 void initSky();
305 void releaseSky();
307 /// Return the max number of user landmarks (standard + bonus ones)
308 static uint getMaxNbUserLandMarks();
310 private:
312 // Register outpost (collsions...)
313 void initOutpost();
315 // Remove all outpost (collisions...)
316 void removeOutpost();
318 // load the fog maps
319 bool loadFogMaps();
321 // Load the weather functions
322 void loadWeatherFunctions(const NLGEORGES::UFormElm &item);
327 #endif // CL_CONTINENT_H
329 /* End of continent.h */