All pastes #917281 Raw Edit

Something

public text v1 · immutable
#917281 ·published 2008-02-25 07:07 UTC
rendered paste body
Index: src/game/MapInstanced.cpp
===================================================================
--- src/game/MapInstanced.cpp	(revision 5304)
+++ src/game/MapInstanced.cpp	(working copy)
@@ -296,15 +296,17 @@
 
 void MapInstanced::CreateInstance(uint32 InstanceId, Map* &map)
 {
-    if (!IsValidInstance(InstanceId))
-    {
+ {
+	// Check there if only 1 thread executed at moment
+	// prevent reduplication
+	Guard guard(*this);
+	if (!IsValidInstance(InstanceId))
+	{
         // instance is invalid, need to verify map presence
         if (map)
         {
             // map for the instance is present, but the instance itself is no more valid, destroy map
-            Guard guard(*this);
-
-            map->Reset();
+		    map->Reset();
             m_InstancedMaps.erase(InstanceId);
             delete map;
             map = NULL;
@@ -315,11 +317,10 @@
     if (!map)
     {
         // map does not exist, create it
-        Guard guard(*this);
-
         map = new Map(GetId(), GetGridExpiry(), InstanceId);
         m_InstancedMaps[InstanceId] = map;
     }
+ }
 }
 
 bool MapInstanced::IsValidInstance(uint32 InstanceId)