From 190ef1c2ef0eac90f90d7f84e8ed20f020b2be11 Mon Sep 17 00:00:00 2001 From: leak Date: Fri, 11 Mar 2011 13:24:58 +0100 Subject: Core/Instances: Fix crash and allocation issue in instance id generation --- src/server/game/Instances/InstanceSaveMgr.cpp | 2 +- src/server/game/Maps/MapManager.cpp | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'src/server') diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index d3b5ad0f1e1..a13c5b79ac6 100755 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -560,7 +560,7 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId) sObjectMgr->DeleteRespawnTimeForInstance(instanceId); // even if map is not loaded // Free up the instance id and allow it to be reused - sMapMgr->FreeInstanceId(iMap->GetInstanceId()); + sMapMgr->FreeInstanceId(instanceId); } void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, time_t resetTime) diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 45aeebd7c47..d2f86917b8b 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -404,16 +404,12 @@ uint32 MapManager::GenerateInstanceId() // Allocate space if necessary if (newInstanceId >= uint32(_instanceIds.size())) { - // DEBUG CODE - TO BE REMOVED OR ENABLED DEPENDING ON THIS ASSERT TRIGGERING - ASSERT(_instanceIds.size() == _instanceIds.capacity()); - - /* + // Due to the odd memory allocation behavior of vector we match size to capacity before triggering a new allocation if (_instanceIds.size() < _instanceIds.capacity()) { _instanceIds.resize(_instanceIds.capacity()); } else - */ _instanceIds.resize(floor(newInstanceId / 32.0f) * 32 + (newInstanceId % 32 > 0 ? 32 : 0)); } -- cgit v1.2.3