Core/Maps: Fixed possible crash when resetting instances

This commit is contained in:
Shauren
2012-06-08 14:52:52 +02:00
parent 1c0fc0a1ee
commit 32aa983fe2
3 changed files with 16 additions and 5 deletions

View File

@@ -543,7 +543,10 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
if (iMap && iMap->IsDungeon())
((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
iMap->DeleteRespawnTimes();
if (iMap)
iMap->DeleteRespawnTimes();
else
Map::DeleteRespawnTimesInDB(mapid, instanceId);
// Free up the instance id and allow it to be reused
sMapMgr->FreeInstanceId(instanceId);

View File

@@ -2880,14 +2880,19 @@ void Map::DeleteRespawnTimes()
_creatureRespawnTimes.clear();
_goRespawnTimes.clear();
DeleteRespawnTimesInDB(GetId(), GetInstanceId());
}
void Map::DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE);
stmt->setUInt16(0, GetId());
stmt->setUInt32(1, GetInstanceId());
stmt->setUInt16(0, mapId);
stmt->setUInt32(1, instanceId);
CharacterDatabase.Execute(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN_BY_INSTANCE);
stmt->setUInt16(0, GetId());
stmt->setUInt32(1, GetInstanceId());
stmt->setUInt16(0, mapId);
stmt->setUInt32(1, instanceId);
CharacterDatabase.Execute(stmt);
}
@@ -2906,3 +2911,4 @@ time_t Map::GetLinkedRespawnTime(uint64 guid) const
return time_t(0);
}

View File

@@ -473,6 +473,8 @@ class Map : public GridRefManager<NGridType>
void LoadRespawnTimes();
void DeleteRespawnTimes();
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId);
private:
void LoadMapAndVMap(int gx, int gy);
void LoadVMap(int gx, int gy);