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