mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
Core/Maps: Fixed possible crash when resetting instances
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user