diff --git a/src/game/MapPersistentStateMgr.cpp b/src/game/MapPersistentStateMgr.cpp index 3f793119b..7905a3617 100644 --- a/src/game/MapPersistentStateMgr.cpp +++ b/src/game/MapPersistentStateMgr.cpp @@ -821,8 +821,7 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes() uint32 count = 0; - QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, instance FROM creature_respawn"); - + QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime FROM creature_respawn LEFT JOIN instance ON instance = id"); if(!result) { barGoLink bar(1); @@ -843,21 +842,27 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes() uint32 loguid = fields[0].GetUInt32(); uint64 respawn_time = fields[1].GetUInt64(); - uint32 instanceId = fields[2].GetUInt32(); + uint32 mapId = fields[2].GetUInt32(); + uint32 instanceId = fields[3].GetUInt32(); + uint8 difficulty = fields[4].GetUInt8(); + + time_t resetTime = (time_t)fields[5].GetUInt64(); CreatureData const* data = sObjectMgr.GetCreatureData(loguid); if (!data) continue; - MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid); + if (mapId != data->mapid) + continue; + + MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0))) continue; - // instances loaded early and respawn data must exist only for existed instances (state loaded) or non-instanced maps - MapPersistentState* state = instanceId - ? GetPersistentState(data->mapid, instanceId) - : AddPersistentState(mapEntry, 0, REGULAR_DIFFICULTY, 0, false, true); + if(difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))) + continue; + MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true); if (!state) continue; @@ -880,7 +885,7 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes() uint32 count = 0; - QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, instance FROM gameobject_respawn"); + QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime FROM gameobject_respawn LEFT JOIN instance ON instance = id"); if(!result) { @@ -902,22 +907,27 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes() uint32 loguid = fields[0].GetUInt32(); uint64 respawn_time = fields[1].GetUInt64(); - uint32 instanceId = fields[2].GetUInt32(); + uint32 mapId = fields[2].GetUInt32(); + uint32 instanceId = fields[3].GetUInt32(); + uint8 difficulty = fields[4].GetUInt8(); + time_t resetTime = (time_t)fields[5].GetUInt64(); GameObjectData const* data = sObjectMgr.GetGOData(loguid); if (!data) continue; - MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid); + if (mapId != data->mapid) + continue; + + MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0))) continue; - // instances loaded early and respawn data must exist only for existed instances (state loaded) or non-instanced maps - MapPersistentState* state = instanceId - ? GetPersistentState(data->mapid, instanceId) - : AddPersistentState(mapEntry, 0, REGULAR_DIFFICULTY, 0, false, true); + if(difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))) + continue; + MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true); if (!state) continue; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b23f1d18a..6d847bd48 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11157" + #define REVISION_NR "11158" #endif // __REVISION_NR_H__