diff --git a/src/game/Maps/Map.cpp b/src/game/Maps/Map.cpp index 2789e34eb77..1a2d971c721 100644 --- a/src/game/Maps/Map.cpp +++ b/src/game/Maps/Map.cpp @@ -147,7 +147,7 @@ bool Map::CanSpawn(TypeID typeId, uint32 dbGuid) { if (typeId == TYPEID_UNIT) return GetCreatureLinkingHolder()->CanSpawn(dbGuid, this, nullptr, 0.f, 0.f); - else if (TYPEID_GAMEOBJECT) + else if (typeId == TYPEID_GAMEOBJECT) { GameObjectData const* data = sObjectMgr.GetGOData(dbGuid); if (data) diff --git a/src/game/Maps/SpawnManager.cpp b/src/game/Maps/SpawnManager.cpp index 44cfcb1ae01..818f0aa6bbb 100644 --- a/src/game/Maps/SpawnManager.cpp +++ b/src/game/Maps/SpawnManager.cpp @@ -58,7 +58,8 @@ void SpawnManager::Initialize() if (m_map.GetPersistentState()->GetCreatureRespawnTime(dbGuid) < now) { auto data = sObjectMgr.GetCreatureData(dbGuid); - m_map.GetPersistentState()->AddCreatureToGrid(dbGuid, data); + if (m_map.GetCreatureLinkingHolder()->CanSpawn(dbGuid, &m_map, nullptr, 0.f, 0.f)) // copy of Map::CanSpawn + m_map.GetPersistentState()->AddCreatureToGrid(dbGuid, data); } else AddCreature(dbGuid); @@ -72,7 +73,8 @@ void SpawnManager::Initialize() if (m_map.GetPersistentState()->GetGORespawnTime(dbGuid) < now) { auto data = sObjectMgr.GetGOData(dbGuid); - m_map.GetPersistentState()->AddGameobjectToGrid(dbGuid, data); + if ((data->spawnMask & (1 << m_map.GetDifficulty())) != 0) // copy of Map::CanSpawn + m_map.GetPersistentState()->AddGameobjectToGrid(dbGuid, data); } else AddGameObject(dbGuid); @@ -239,14 +241,17 @@ bool SpawnManager::IsEventGuid(uint32 dbguid, HighGuid high) const void SpawnManager::RespawnAll() { - for (auto itr = m_spawns.begin(); itr != m_spawns.end();) + for (auto itr = m_spawns.begin(); itr != m_spawns.end(); ) { auto& spawnInfo = *itr; if (spawnInfo.GetHighGuid() == HIGHGUID_GAMEOBJECT) m_map.GetPersistentState()->SaveGORespawnTime(spawnInfo.GetDbGuid(), 0); if (spawnInfo.GetHighGuid() == HIGHGUID_UNIT) m_map.GetPersistentState()->SaveCreatureRespawnTime(spawnInfo.GetDbGuid(), 0); - spawnInfo.ConstructForMap(m_map); + if (spawnInfo.ConstructForMap(m_map)) + itr = m_spawns.erase(itr); + else + ++itr; } }