AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
VMAP::VMapMgr2 Class Reference

#include "VMapMgr2.h"

Inheritance diagram for VMAP::VMapMgr2:
VMAP::IVMapMgr

Public Types

typedef uint32(* GetLiquidFlagsFn) (uint32 liquidType)
 
typedef bool(* IsVMAPDisabledForFn) (uint32 entry, uint8 flags)
 

Public Member Functions

G3D::Vector3 convertPositionToInternalRep (float x, float y, float z) const
 
 VMapMgr2 ()
 
 ~VMapMgr2 () override
 
void InitializeThreadUnsafe (const std::vector< uint32 > &mapIds)
 
int loadMap (const char *pBasePath, unsigned int mapId, int x, int y) override
 
void unloadMap (unsigned int mapId, int x, int y) override
 
void unloadMap (unsigned int mapId) override
 
bool isInLineOfSight (unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags) override
 
bool GetObjectHitPos (unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist) override
 
float getHeight (unsigned int mapId, float x, float y, float z, float maxSearchDist) override
 
bool processCommand (char *) override
 
bool GetAreaInfo (uint32 pMapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const override
 
bool GetLiquidLevel (uint32 pMapId, float x, float y, float z, uint8 reqLiquidType, float &level, float &floor, uint32 &type, uint32 &mogpFlags) const override
 
void GetAreaAndLiquidData (uint32 mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData &data) const override
 
WorldModelacquireModelInstance (const std::string &basepath, const std::string &filename, uint32 flags)
 
void releaseModelInstance (const std::string &filename)
 
std::string getDirFileName (unsigned int mapId, int, int) const override
 
LoadResult existsMap (const char *basePath, unsigned int mapId, int x, int y) override
 
void GetInstanceMapTree (InstanceTreeMap &instanceMapTree)
 
- Public Member Functions inherited from VMAP::IVMapMgr
 IVMapMgr ()
 
virtual ~IVMapMgr ()=default
 
virtual int loadMap (const char *pBasePath, unsigned int pMapId, int x, int y)=0
 
virtual LoadResult existsMap (const char *pBasePath, unsigned int pMapId, int x, int y)=0
 
virtual void unloadMap (unsigned int pMapId, int x, int y)=0
 
virtual void unloadMap (unsigned int pMapId)=0
 
virtual bool isInLineOfSight (unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags)=0
 
virtual float getHeight (unsigned int pMapId, float x, float y, float z, float maxSearchDist)=0
 
virtual bool GetObjectHitPos (unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float pModifyDist)=0
 
virtual bool processCommand (char *pCommand)=0
 
void setEnableLineOfSightCalc (bool pVal)
 
void setEnableHeightCalc (bool pVal)
 
bool isLineOfSightCalcEnabled () const
 
bool isHeightCalcEnabled () const
 
bool isMapLoadingEnabled () const
 
virtual std::string getDirFileName (unsigned int pMapId, int x, int y) const =0
 
virtual bool GetAreaInfo (uint32 pMapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const =0
 
virtual bool GetLiquidLevel (uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float &level, float &floor, uint32 &type, uint32 &mogpFlags) const =0
 
virtual void GetAreaAndLiquidData (uint32 mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData &data) const =0
 

Static Public Member Functions

static std::string getMapFileName (unsigned int mapId)
 

Public Attributes

GetLiquidFlagsFn GetLiquidFlagsPtr
 
IsVMAPDisabledForFn IsVMAPDisabledForPtr
 

Protected Member Functions

bool _loadMap (uint32 mapId, const std::string &basePath, uint32 tileX, uint32 tileY)
 
InstanceTreeMap::const_iterator GetMapTree (uint32 mapId) const
 

Static Protected Member Functions

static uint32 GetLiquidFlagsDummy (uint32)
 
static bool IsVMAPDisabledForDummy (uint32, uint8)
 

Protected Attributes

ModelFileMap iLoadedModelFiles
 
InstanceTreeMap iInstanceMapTrees
 
bool thread_safe_environment
 
std::mutex LoadedModelFilesLock
 

Detailed Description

Member Typedef Documentation

◆ GetLiquidFlagsFn

typedef uint32(* VMAP::VMapMgr2::GetLiquidFlagsFn) (uint32 liquidType)

◆ IsVMAPDisabledForFn

typedef bool(* VMAP::VMapMgr2::IsVMAPDisabledForFn) (uint32 entry, uint8 flags)

Constructor & Destructor Documentation

◆ VMapMgr2()

VMAP::VMapMgr2::VMapMgr2 ( )
35 {
39 }
static uint32 GetLiquidFlagsDummy(uint32)
Definition: VMapMgr2.h:90
IsVMAPDisabledForFn IsVMAPDisabledForPtr
Definition: VMapMgr2.h:138
static bool IsVMAPDisabledForDummy(uint32, uint8)
Definition: VMapMgr2.h:91
bool thread_safe_environment
Definition: VMapMgr2.h:82
GetLiquidFlagsFn GetLiquidFlagsPtr
Definition: VMapMgr2.h:135

References GetLiquidFlagsDummy(), GetLiquidFlagsPtr, IsVMAPDisabledForDummy(), IsVMAPDisabledForPtr, and thread_safe_environment.

◆ ~VMapMgr2()

VMAP::VMapMgr2::~VMapMgr2 ( )
override
42 {
43 for (InstanceTreeMap::iterator i = iInstanceMapTrees.begin(); i != iInstanceMapTrees.end(); ++i)
44 {
45 delete i->second;
46 }
47
48 for (ModelFileMap::iterator i = iLoadedModelFiles.begin(); i != iLoadedModelFiles.end(); ++i)
49 {
50 delete i->second.getModel();
51 }
52 }
InstanceTreeMap iInstanceMapTrees
Definition: VMapMgr2.h:81
ModelFileMap iLoadedModelFiles
Definition: VMapMgr2.h:80

References iInstanceMapTrees, and iLoadedModelFiles.

Member Function Documentation

◆ _loadMap()

bool VMAP::VMapMgr2::_loadMap ( uint32  mapId,
const std::string &  basePath,
uint32  tileX,
uint32  tileY 
)
protected
118 {
119 InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
120 if (instanceTree == iInstanceMapTrees.end())
121 {
123 {
124 instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId, nullptr)).first;
125 }
126 else
127 ABORT("Invalid mapId {} tile [{}, {}] passed to VMapMgr2 after startup in thread unsafe environment",
128 mapId, tileX, tileY);
129 }
130
131 if (!instanceTree->second)
132 {
133 std::string mapFileName = getMapFileName(mapId);
134 StaticMapTree* newTree = new StaticMapTree(mapId, basePath);
135 if (!newTree->InitMap(mapFileName, this))
136 {
137 delete newTree;
138 return false;
139 }
140 instanceTree->second = newTree;
141 }
142
143 return instanceTree->second->LoadMapTile(tileX, tileY, this);
144 }
#define ABORT
Definition: Errors.h:76
static std::string getMapFileName(unsigned int mapId)
Definition: VMapMgr2.cpp:89

References ABORT, getMapFileName(), iInstanceMapTrees, VMAP::StaticMapTree::InitMap(), VMAP::StaticMapTree::LoadMapTile(), and thread_safe_environment.

Referenced by loadMap().

◆ acquireModelInstance()

WorldModel * VMAP::VMapMgr2::acquireModelInstance ( const std::string &  basepath,
const std::string &  filename,
uint32  flags 
)

Critical section, thread safe access to iLoadedModelFiles

341 {
343 std::lock_guard<std::mutex> lock(LoadedModelFilesLock);
344
345 ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
346 if (model == iLoadedModelFiles.end())
347 {
348 WorldModel* worldmodel = new WorldModel();
349 if (!worldmodel->readFile(basepath + filename + ".vmo"))
350 {
351 LOG_ERROR("maps", "VMapMgr2: could not load '{}{}.vmo'", basepath, filename);
352 delete worldmodel;
353 return nullptr;
354 }
355 LOG_DEBUG("maps", "VMapMgr2: loading file '{}{}'", basepath, filename);
356
357 worldmodel->Flags = flags;
358
359 model = iLoadedModelFiles.insert(std::pair<std::string, ManagedModel>(filename, ManagedModel())).first;
360 model->second.setModel(worldmodel);
361 }
362
363 return model->second.getModel();
364 }
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
std::mutex LoadedModelFilesLock
Definition: VMapMgr2.h:85

References VMAP::WorldModel::Flags, iLoadedModelFiles, LoadedModelFilesLock, LOG_DEBUG, LOG_ERROR, and VMAP::WorldModel::readFile().

Referenced by GameObjectModel::initialize(), VMAP::StaticMapTree::InitMap(), and VMAP::StaticMapTree::LoadMapTile().

◆ convertPositionToInternalRep()

Vector3 VMAP::VMapMgr2::convertPositionToInternalRep ( float  x,
float  y,
float  z 
) const
66 {
67 Vector3 pos;
68 const float mid = 0.5f * MAX_NUMBER_OF_GRIDS * SIZE_OF_GRIDS;
69 pos.x = mid - x;
70 pos.y = mid - y;
71 pos.z = z;
72
73 return pos;
74 }
#define SIZE_OF_GRIDS
Definition: MapDefines.h:25
#define MAX_NUMBER_OF_GRIDS
Definition: MapDefines.h:24

References MAX_NUMBER_OF_GRIDS, and SIZE_OF_GRIDS.

Referenced by GetAreaAndLiquidData(), GetAreaInfo(), getHeight(), GetLiquidLevel(), GetObjectHitPos(), and isInLineOfSight().

◆ existsMap()

LoadResult VMAP::VMapMgr2::existsMap ( const char *  basePath,
unsigned int  mapId,
int  x,
int  y 
)
overridevirtual

Implements VMAP::IVMapMgr.

386 {
387 return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y);
388 }
static LoadResult CanLoadMap(const std::string &basePath, uint32 mapID, uint32 tileX, uint32 tileY)
Definition: MapTree.cpp:247

References VMAP::StaticMapTree::CanLoadMap().

◆ GetAreaAndLiquidData()

void VMAP::VMapMgr2::GetAreaAndLiquidData ( uint32  mapId,
float  x,
float  y,
float  z,
uint8  reqLiquidType,
AreaAndLiquidData data 
) const
overridevirtual

Implements VMAP::IVMapMgr.

309 {
311 {
312 data.floorZ = z;
313 int32 adtId, rootId, groupId;
314 uint32 flags;
315 if (GetAreaInfo(mapId, x, y, data.floorZ, flags, adtId, rootId, groupId))
316 data.areaInfo.emplace(adtId, rootId, groupId, flags);
317 return;
318 }
319
320 InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
321 if (instanceTree != iInstanceMapTrees.end())
322 {
323 LocationInfo info;
324 Vector3 pos = convertPositionToInternalRep(x, y, z);
325 if (instanceTree->second->GetLocationInfo(pos, info))
326 {
327 data.floorZ = info.ground_Z;
328 uint32 liquidType = info.hitModel->GetLiquidType();
329 float liquidLevel;
330 if (!reqLiquidType || (GetLiquidFlagsPtr(liquidType) & reqLiquidType))
331 if (info.hitInstance->GetLiquidLevel(pos, info, liquidLevel))
332 data.liquidInfo.emplace(liquidType, liquidLevel);
333
335 data.areaInfo.emplace(info.hitInstance->adtId, info.rootId, info.hitModel->GetWmoID(), info.hitModel->GetMogpFlags());
336 }
337 }
338 }
std::int32_t int32
Definition: Define.h:104
std::uint32_t uint32
Definition: Define.h:108
@ VMAP_DISABLE_LIQUIDSTATUS
Definition: VMapMgr2.h:73
@ VMAP_DISABLE_AREAFLAG
Definition: VMapMgr2.h:70
G3D::Vector3 convertPositionToInternalRep(float x, float y, float z) const
Definition: VMapMgr2.cpp:65
bool GetAreaInfo(uint32 pMapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const override
Definition: VMapMgr2.cpp:256
InstanceTreeMap::const_iterator GetMapTree(uint32 mapId) const
Definition: VMapMgr2.cpp:76

References VMAP::ModelSpawn::adtId, VMAP::AreaAndLiquidData::areaInfo, convertPositionToInternalRep(), VMAP::AreaAndLiquidData::floorZ, GetAreaInfo(), GetLiquidFlagsPtr, VMAP::ModelInstance::GetLiquidLevel(), VMAP::GroupModel::GetLiquidType(), GetMapTree(), VMAP::GroupModel::GetMogpFlags(), VMAP::GroupModel::GetWmoID(), VMAP::LocationInfo::ground_Z, VMAP::LocationInfo::hitInstance, VMAP::LocationInfo::hitModel, iInstanceMapTrees, IsVMAPDisabledForPtr, VMAP::AreaAndLiquidData::liquidInfo, VMAP::LocationInfo::rootId, VMAP::VMAP_DISABLE_AREAFLAG, and VMAP::VMAP_DISABLE_LIQUIDSTATUS.

◆ GetAreaInfo()

bool VMAP::VMapMgr2::GetAreaInfo ( uint32  pMapId,
float  x,
float  y,
float &  z,
uint32 flags,
int32 adtId,
int32 rootId,
int32 groupId 
) const
overridevirtual

Query world model area info.

Parameters
zgets adjusted to the ground height for which this are info is valid

Implements VMAP::IVMapMgr.

257 {
258#if defined(ENABLE_VMAP_CHECKS)
260#endif
261 {
262 InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
263 if (instanceTree != iInstanceMapTrees.end())
264 {
265 Vector3 pos = convertPositionToInternalRep(x, y, z);
266 bool result = instanceTree->second->GetAreaInfo(pos, flags, adtId, rootId, groupId);
267 // z is not touched by convertPositionToInternalRep(), so just copy
268 z = pos.z;
269 return result;
270 }
271 }
272
273 return false;
274 }

References convertPositionToInternalRep(), GetMapTree(), iInstanceMapTrees, IsVMAPDisabledForPtr, and VMAP::VMAP_DISABLE_AREAFLAG.

Referenced by GetAreaAndLiquidData().

◆ getDirFileName()

std::string VMAP::VMapMgr2::getDirFileName ( unsigned int  mapId,
int  ,
int   
) const
inlineoverridevirtual

Implements VMAP::IVMapMgr.

128 {
129 return getMapFileName(mapId);
130 }

References getMapFileName().

◆ getHeight()

float VMAP::VMapMgr2::getHeight ( unsigned int  mapId,
float  x,
float  y,
float  z,
float  maxSearchDist 
)
overridevirtual

get height or INVALID_HEIGHT if no height available

Implements VMAP::IVMapMgr.

234 {
235#if defined(ENABLE_VMAP_CHECKS)
237#endif
238 {
239 InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
240 if (instanceTree != iInstanceMapTrees.end())
241 {
242 Vector3 pos = convertPositionToInternalRep(x, y, z);
243 float height = instanceTree->second->getHeight(pos, maxSearchDist);
244 if (height >= G3D::finf())
245 {
246 return height = VMAP_INVALID_HEIGHT_VALUE; // No height
247 }
248
249 return height;
250 }
251 }
252
254 }
#define VMAP_INVALID_HEIGHT_VALUE
Definition: IVMapMgr.h:49
@ VMAP_DISABLE_HEIGHT
Definition: VMapMgr2.h:71
bool isHeightCalcEnabled() const
Definition: IVMapMgr.h:119

References convertPositionToInternalRep(), GetMapTree(), iInstanceMapTrees, VMAP::IVMapMgr::isHeightCalcEnabled(), IsVMAPDisabledForPtr, VMAP::VMAP_DISABLE_HEIGHT, and VMAP_INVALID_HEIGHT_VALUE.

◆ GetInstanceMapTree()

void VMAP::VMapMgr2::GetInstanceMapTree ( InstanceTreeMap instanceMapTree)
391 {
392 instanceMapTree = iInstanceMapTrees;
393 }

References iInstanceMapTrees.

◆ GetLiquidFlagsDummy()

static uint32 VMAP::VMapMgr2::GetLiquidFlagsDummy ( uint32  )
inlinestaticprotected
90{ return 0; }

Referenced by VMapMgr2().

◆ GetLiquidLevel()

bool VMAP::VMapMgr2::GetLiquidLevel ( uint32  pMapId,
float  x,
float  y,
float  z,
uint8  reqLiquidType,
float &  level,
float &  floor,
uint32 type,
uint32 mogpFlags 
) const
overridevirtual

Implements VMAP::IVMapMgr.

277 {
278#if defined(ENABLE_VMAP_CHECKS)
280#endif
281 {
282 InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
283 if (instanceTree != iInstanceMapTrees.end())
284 {
285 LocationInfo info;
286 Vector3 pos = convertPositionToInternalRep(x, y, z);
287 if (instanceTree->second->GetLocationInfo(pos, info))
288 {
289 floor = info.ground_Z;
290 ASSERT(floor < std::numeric_limits<float>::max());
291 type = info.hitModel->GetLiquidType(); // entry from LiquidType.dbc
292 mogpFlags = info.hitModel->GetMogpFlags();
293 if (reqLiquidType && !(GetLiquidFlagsPtr(type) & reqLiquidType))
294 {
295 return false;
296 }
297 if (info.hitInstance->GetLiquidLevel(pos, info, level))
298 {
299 return true;
300 }
301 }
302 }
303 }
304
305 return false;
306 }
#define ASSERT
Definition: Errors.h:68

References ASSERT, convertPositionToInternalRep(), GetLiquidFlagsPtr, VMAP::ModelInstance::GetLiquidLevel(), VMAP::GroupModel::GetLiquidType(), GetMapTree(), VMAP::GroupModel::GetMogpFlags(), VMAP::LocationInfo::ground_Z, VMAP::LocationInfo::hitInstance, VMAP::LocationInfo::hitModel, iInstanceMapTrees, IsVMAPDisabledForPtr, and VMAP::VMAP_DISABLE_LIQUIDSTATUS.

◆ getMapFileName()

std::string VMAP::VMapMgr2::getMapFileName ( unsigned int  mapId)
static
90 {
91 std::stringstream fname;
92 fname.width(3);
93 fname << std::setfill('0') << mapId << std::string(MAP_FILENAME_EXTENSION2);
94
95 return fname.str();
96 }
#define MAP_FILENAME_EXTENSION2
Definition: VMapMgr2.h:29

References MAP_FILENAME_EXTENSION2.

Referenced by _loadMap(), VMAP::StaticMapTree::CanLoadMap(), and getDirFileName().

◆ GetMapTree()

InstanceTreeMap::const_iterator VMAP::VMapMgr2::GetMapTree ( uint32  mapId) const
protected
77 {
78 // return the iterator if found or end() if not found/NULL
79 InstanceTreeMap::const_iterator itr = iInstanceMapTrees.find(mapId);
80 if (itr != iInstanceMapTrees.cend() && !itr->second)
81 {
82 itr = iInstanceMapTrees.cend();
83 }
84
85 return itr;
86 }

References iInstanceMapTrees.

Referenced by GetAreaAndLiquidData(), GetAreaInfo(), getHeight(), GetLiquidLevel(), GetObjectHitPos(), and isInLineOfSight().

◆ GetObjectHitPos()

bool VMAP::VMapMgr2::GetObjectHitPos ( unsigned int  mapId,
float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2,
float &  rx,
float &  ry,
float &  rz,
float  modifyDist 
)
overridevirtual

fill the hit pos and return true, if an object was hit

get the hit position and return true if we hit something otherwise the result pos will be the dest pos

Implements VMAP::IVMapMgr.

202 {
203#if defined(ENABLE_VMAP_CHECKS)
205#endif
206 {
207 InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
208 if (instanceTree != iInstanceMapTrees.end())
209 {
210 Vector3 pos1 = convertPositionToInternalRep(x1, y1, z1);
211 Vector3 pos2 = convertPositionToInternalRep(x2, y2, z2);
212 Vector3 resultPos;
213 bool result = instanceTree->second->GetObjectHitPos(pos1, pos2, resultPos, modifyDist);
214 resultPos = convertPositionToInternalRep(resultPos.x, resultPos.y, resultPos.z);
215 rx = resultPos.x;
216 ry = resultPos.y;
217 rz = resultPos.z;
218 return result;
219 }
220 }
221
222 rx = x2;
223 ry = y2;
224 rz = z2;
225
226 return false;
227 }
@ VMAP_DISABLE_LOS
Definition: VMapMgr2.h:72
bool isLineOfSightCalcEnabled() const
Definition: IVMapMgr.h:118

References convertPositionToInternalRep(), GetMapTree(), iInstanceMapTrees, VMAP::IVMapMgr::isLineOfSightCalcEnabled(), IsVMAPDisabledForPtr, and VMAP::VMAP_DISABLE_LOS.

Referenced by Map::CheckCollisionAndGetValidCoords(), and Spell::SelectImplicitCasterDestTargets().

◆ InitializeThreadUnsafe()

void VMAP::VMapMgr2::InitializeThreadUnsafe ( const std::vector< uint32 > &  mapIds)
55 {
56 // the caller must pass the list of all mapIds that will be used in the VMapMgr2 lifetime
57 for (const uint32& mapId : mapIds)
58 {
59 iInstanceMapTrees.emplace(mapId, nullptr);
60 }
61
63 }

References iInstanceMapTrees, and thread_safe_environment.

Referenced by World::SetInitialWorldSettings().

◆ isInLineOfSight()

bool VMAP::VMapMgr2::isInLineOfSight ( unsigned int  mapId,
float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2,
ModelIgnoreFlags  ignoreFlags 
)
overridevirtual

Implements VMAP::IVMapMgr.

175 {
176#if defined(ENABLE_VMAP_CHECKS)
178 {
179 return true;
180 }
181#endif
182
183 InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
184 if (instanceTree != iInstanceMapTrees.end())
185 {
186 Vector3 pos1 = convertPositionToInternalRep(x1, y1, z1);
187 Vector3 pos2 = convertPositionToInternalRep(x2, y2, z2);
188 if (pos1 != pos2)
189 {
190 return instanceTree->second->isInLineOfSight(pos1, pos2, ignoreFlags);
191 }
192 }
193
194 return true;
195 }

References convertPositionToInternalRep(), GetMapTree(), iInstanceMapTrees, VMAP::IVMapMgr::isLineOfSightCalcEnabled(), IsVMAPDisabledForPtr, and VMAP::VMAP_DISABLE_LOS.

◆ IsVMAPDisabledForDummy()

static bool VMAP::VMapMgr2::IsVMAPDisabledForDummy ( uint32  ,
uint8   
)
inlinestaticprotected
91{ return false; }

Referenced by VMapMgr2().

◆ loadMap()

int VMAP::VMapMgr2::loadMap ( const char *  pBasePath,
unsigned int  mapId,
int  x,
int  y 
)
overridevirtual

Implements VMAP::IVMapMgr.

99 {
100 int result = VMAP_LOAD_RESULT_IGNORED;
102 {
103 if (_loadMap(mapId, basePath, x, y))
104 {
105 result = VMAP_LOAD_RESULT_OK;
106 }
107 else
108 {
109 result = VMAP_LOAD_RESULT_ERROR;
110 }
111 }
112
113 return result;
114 }
@ VMAP_LOAD_RESULT_ERROR
Definition: IVMapMgr.h:36
@ VMAP_LOAD_RESULT_OK
Definition: IVMapMgr.h:37
@ VMAP_LOAD_RESULT_IGNORED
Definition: IVMapMgr.h:38
bool isMapLoadingEnabled() const
Definition: IVMapMgr.h:120
bool _loadMap(uint32 mapId, const std::string &basePath, uint32 tileX, uint32 tileY)
Definition: VMapMgr2.cpp:117

References _loadMap(), VMAP::IVMapMgr::isMapLoadingEnabled(), VMAP::VMAP_LOAD_RESULT_ERROR, VMAP::VMAP_LOAD_RESULT_IGNORED, and VMAP::VMAP_LOAD_RESULT_OK.

Referenced by Map::LoadVMap().

◆ processCommand()

bool VMAP::VMapMgr2::processCommand ( char *  pCommand)
inlineoverridevirtual

send debug commands

Implements VMAP::IVMapMgr.

117{ return false; } // for debug and extensions

◆ releaseModelInstance()

void VMAP::VMapMgr2::releaseModelInstance ( const std::string &  filename)

Critical section, thread safe access to iLoadedModelFiles

367 {
369 std::lock_guard<std::mutex> lock(LoadedModelFilesLock);
370
371 ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
372 if (model == iLoadedModelFiles.end())
373 {
374 LOG_ERROR("maps", "VMapMgr2: trying to unload non-loaded file '{}'", filename);
375 return;
376 }
377 if (model->second.decRefCount() == 0)
378 {
379 LOG_DEBUG("maps", "VMapMgr2: unloading file '{}'", filename);
380 delete model->second.getModel();
381 iLoadedModelFiles.erase(model);
382 }
383 }

References iLoadedModelFiles, LoadedModelFilesLock, LOG_DEBUG, and LOG_ERROR.

Referenced by VMAP::StaticMapTree::UnloadMap(), VMAP::StaticMapTree::UnloadMapTile(), and GameObjectModel::~GameObjectModel().

◆ unloadMap() [1/2]

void VMAP::VMapMgr2::unloadMap ( unsigned int  mapId)
overridevirtual

Implements VMAP::IVMapMgr.

147 {
148 InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
149 if (instanceTree != iInstanceMapTrees.end() && instanceTree->second)
150 {
151 instanceTree->second->UnloadMap(this);
152 if (instanceTree->second->numLoadedTiles() == 0)
153 {
154 delete instanceTree->second;
155 instanceTree->second = nullptr;
156 }
157 }
158 }

References iInstanceMapTrees.

◆ unloadMap() [2/2]

void VMAP::VMapMgr2::unloadMap ( unsigned int  mapId,
int  x,
int  y 
)
overridevirtual

Implements VMAP::IVMapMgr.

161 {
162 InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
163 if (instanceTree != iInstanceMapTrees.end() && instanceTree->second)
164 {
165 instanceTree->second->UnloadMapTile(x, y, this);
166 if (instanceTree->second->numLoadedTiles() == 0)
167 {
168 delete instanceTree->second;
169 instanceTree->second = nullptr;
170 }
171 }
172 }

References iInstanceMapTrees.

Referenced by Map::UnloadGrid().

Member Data Documentation

◆ GetLiquidFlagsPtr

◆ iInstanceMapTrees

◆ iLoadedModelFiles

ModelFileMap VMAP::VMapMgr2::iLoadedModelFiles
protected

◆ IsVMAPDisabledForPtr

◆ LoadedModelFilesLock

std::mutex VMAP::VMapMgr2::LoadedModelFilesLock
protected

◆ thread_safe_environment

bool VMAP::VMapMgr2::thread_safe_environment
protected