Core/Instances: Fix crash and allocation issue in instance id generation

This commit is contained in:
leak
2011-03-11 13:24:58 +01:00
parent 3973d1b454
commit 190ef1c2ef
2 changed files with 2 additions and 6 deletions

View File

@@ -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)

View File

@@ -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<bool> 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));
}