From 83a25ce554474982ced2b0534ce712d7efebe242 Mon Sep 17 00:00:00 2001 From: Treeston Date: Sun, 7 Jul 2019 19:18:32 +0200 Subject: [PATCH] Entities/Creature: Some asserts are now LOG_ERRORs that block spawning. Fix a group spawning bug exposed by the CoS merge. Improve some command output. # Conflicts: # src/server/game/Maps/Map.cpp # src/server/scripts/Commands/cs_list.cpp --- .../game/Entities/Creature/Creature.cpp | 26 ++++++++++++++++--- src/server/game/Maps/Map.cpp | 4 +-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index c5e7eb1acb6..76ecfc046ad 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1537,14 +1537,32 @@ bool Creature::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, if (!m_respawnTime && !map->IsSpawnGroupActive(data->spawnGroupData->groupId)) { - // @todo pools need fixing! this is just a temporary crashfix, but they violate dynspawn principles - ASSERT(m_respawnCompatibilityMode || sPoolMgr->IsPartOfAPool(spawnId), "Creature (SpawnID %u) trying to load in inactive spawn group %s.", spawnId, data->spawnGroupData->name.c_str()); + if (!m_respawnCompatibilityMode) + { + // @todo pools need fixing! this is just a temporary thing, but they violate dynspawn principles + if (!sPoolMgr->IsPartOfAPool(spawnId)) + { + TC_LOG_ERROR("entities.unit", "Creature (SpawnID %u) trying to load in inactive spawn group '%s':\n%s", spawnId, data->spawnGroupData->name.c_str(), GetDebugInfo().c_str()); + return false; + } + } + m_respawnTime = GameTime::GetGameTime() + urand(4, 7); } - if (m_respawnTime) // respawn on Update + if (m_respawnTime) { - ASSERT(m_respawnCompatibilityMode || sPoolMgr->IsPartOfAPool(spawnId), "Creature (SpawnID %u) trying to load despite a respawn timer in progress.", spawnId); + if (!m_respawnCompatibilityMode) + { + // @todo same as above + if (!sPoolMgr->IsPartOfAPool(spawnId)) + { + TC_LOG_ERROR("entities.unit", "Creature (SpawnID %u) trying to load despite a respawn timer in progress:\n%s", spawnId, GetDebugInfo().c_str()); + return false; + } + } + + // compatibility mode creatures will be respawned in ::Update() m_deathState = DEAD; if (CanFly()) { diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 4570b5fa697..02719912f90 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3410,9 +3410,9 @@ bool Map::SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn, bool force, std::v continue; time_t respawnTime = GetRespawnTime(data->type, data->spawnId); - if (respawnTime && respawnTime > time(NULL)) + if (respawnTime) { - if (!force && !ignoreRespawn) + if (!force && !ignoreRespawn && (respawnTime > GameTime::GetGameTime())) continue; // we need to remove the respawn time, otherwise we'd end up double spawning