aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/collision/Management/VMapManager2.cpp6
-rwxr-xr-xsrc/server/collision/Management/VMapManager2.h3
2 files changed, 9 insertions, 0 deletions
diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp
index 9f32c749c5c..0632542f82e 100644
--- a/src/server/collision/Management/VMapManager2.cpp
+++ b/src/server/collision/Management/VMapManager2.cpp
@@ -247,6 +247,9 @@ namespace VMAP
WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename)
{
+ //! Critical section, thread safe access to iLoadedModelFiles
+ TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
+
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
if (model == iLoadedModelFiles.end())
{
@@ -267,6 +270,9 @@ namespace VMAP
void VMapManager2::releaseModelInstance(const std::string &filename)
{
+ //! Critical section, thread safe access to iLoadedModelFiles
+ TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
+
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
if (model == iLoadedModelFiles.end())
{
diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h
index ac293e2071b..83fec0f0d11 100755
--- a/src/server/collision/Management/VMapManager2.h
+++ b/src/server/collision/Management/VMapManager2.h
@@ -22,6 +22,7 @@
#include "IVMapManager.h"
#include "Dynamic/UnorderedMap.h"
#include "Define.h"
+#include <ace/Thread_Mutex.h>
//===========================================================
@@ -71,6 +72,8 @@ namespace VMAP
// Tree to check collision
ModelFileMap iLoadedModelFiles;
InstanceTreeMap iInstanceMapTrees;
+ // Mutex for iLoadedModelFiles
+ ACE_Thread_Mutex LoadedModelFilesLock;
bool _loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY);
/* void _unloadMap(uint32 pMapId, uint32 x, uint32 y); */