From a693bed21156d6dcf64369d134feb5c21da6927f Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 27 Dec 2021 15:51:24 -0500 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. Port From (https://github.com/TrinityCore/TrinityCore/commit/2225cb120100da741814dec7515b191cc68f07be) --- Source/Game/Chat/Commands/ListCommands.cs | 4 ++-- Source/Game/Entities/Creature/Creature.cs | 26 +++++++++++++++++++---- Source/Game/Maps/Map.cs | 4 ++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Source/Game/Chat/Commands/ListCommands.cs b/Source/Game/Chat/Commands/ListCommands.cs index 28d084d3b..396e95dea 100644 --- a/Source/Game/Chat/Commands/ListCommands.cs +++ b/Source/Game/Chat/Commands/ListCommands.cs @@ -601,7 +601,7 @@ namespace Game.Chat.Commands uint gridX = ri.gridId % MapConst.MaxGrids; string respawnTime = ri.respawnTime > GameTime.GetGameTime() ? Time.secsToTimeString((ulong)(ri.respawnTime - GameTime.GetGameTime()), true) : stringOverdue; - handler.SendSysMessage($"{ri.spawnId} | {ri.entry} | [{gridX},{gridY}] | {GetZoneName(ri.zoneId, handler.GetSessionDbcLocale())} ({ri.zoneId}) | {(map.IsSpawnGroupActive(data.spawnGroupData.groupId) ? respawnTime : "inactive")}"); + handler.SendSysMessage($"{ri.spawnId} | {ri.entry} | [{gridX},{gridY}] | {GetZoneName(ri.zoneId, handler.GetSessionDbcLocale())} ({ri.zoneId}) | {respawnTime}{(map.IsSpawnGroupActive(data.spawnGroupData.groupId) ? "" : " (inactive)")}"); } respawns.Clear(); @@ -624,7 +624,7 @@ namespace Game.Chat.Commands uint gridX = ri.gridId % MapConst.MaxGrids; string respawnTime = ri.respawnTime > GameTime.GetGameTime() ? Time.secsToTimeString((ulong)(ri.respawnTime - GameTime.GetGameTime()), true) : stringOverdue; - handler.SendSysMessage($"{ri.spawnId} | {ri.entry} | [{gridX},{gridY}] | {GetZoneName(ri.zoneId, handler.GetSessionDbcLocale())} ({ri.zoneId}) | {(map.IsSpawnGroupActive(data.spawnGroupData.groupId) ? respawnTime : "inactive")}"); + handler.SendSysMessage($"{ri.spawnId} | {ri.entry} | [{gridX},{gridY}] | {GetZoneName(ri.zoneId, handler.GetSessionDbcLocale())} ({ri.zoneId}) | {respawnTime}{(map.IsSpawnGroupActive(data.spawnGroupData.groupId) ? "" : " (inactive)")}"); } return true; } diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 23c448e5f..30954dfa0 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -3163,14 +3163,32 @@ namespace Game.Entities if (m_respawnTime == 0 && !map.IsSpawnGroupActive(data.spawnGroupData.groupId)) { - // @todo pools need fixing! this is just a temporary crashfix, but they violate dynspawn principles - Cypher.Assert(m_respawnCompatibilityMode || Global.PoolMgr.IsPartOfAPool(spawnId) != 0, $"Creature (SpawnID {spawnId}) trying to load in inactive spawn group {data.spawnGroupData.name}."); + if (!m_respawnCompatibilityMode) + { + // @todo pools need fixing! this is just a temporary thing, but they violate dynspawn principles + if (Global.PoolMgr.IsPartOfAPool(spawnId) == 0) + { + Log.outError(LogFilter.Unit, $"Creature (SpawnID {spawnId}) trying to load in inactive spawn group '{data.spawnGroupData.name}'"); + return false; + } + } + m_respawnTime = GameTime.GetGameTime() + RandomHelper.URand(4, 7); } - if (m_respawnTime != 0) // respawn on UpdateLoadCreatureFromDB + if (m_respawnTime != 0) { - Cypher.Assert(m_respawnCompatibilityMode || Global.PoolMgr.IsPartOfAPool(spawnId) != 0, $"Creature (SpawnID {spawnId}) trying to load despite a respawn timer in progress."); + if (!m_respawnCompatibilityMode) + { + // @todo same as above + if (Global.PoolMgr.IsPartOfAPool(spawnId) == 0) + { + Log.outError(LogFilter.Unit, $"Creature (SpawnID {spawnId}) trying to load despite a respawn timer in progress"); + return false; + } + } + + // compatibility mode creatures will be respawned in ::Update() m_deathState = DeathState.Dead; if (CanFly()) { diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index 2648aa022..3cc888eb7 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -2708,9 +2708,9 @@ namespace Game.Maps } long respawnTime = GetRespawnTime(data.type, data.spawnId); - if (respawnTime != 0 && respawnTime > GameTime.GetGameTime()) + if (respawnTime != 0) { - if (!force && !ignoreRespawn) + if (!force && !ignoreRespawn && respawnTime > GameTime.GetGameTime()) continue; // we need to remove the respawn time, otherwise we'd end up double spawning