From 87d88de68154d2f5e6f047238fd2baecd3f62182 Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Sun, 25 Aug 2024 21:30:13 -0400 Subject: [PATCH] Core/Creatures: Validate creature.modelid on startup Port From (https://github.com/TrinityCore/TrinityCore/commit/ef70cf64814341543fdb8efa403319371d9f3104) --- Source/Game/Entities/Creature/Creature.cs | 2 +- Source/Game/Globals/ObjectManager.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 2ca574533..c8749472f 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -237,7 +237,7 @@ namespace Game.Entities CreatureModelInfo minfo = Global.ObjectMgr.GetCreatureModelRandomGender(ref model, creatureInfo); if (minfo == null) // Cancel load if no model defined { - Log.outError(LogFilter.Sql, "Creature (Entry: {0}) has invalid model {1} defined in table `creature_template`, can't load.", entry, model.CreatureDisplayID); + Log.outError(LogFilter.Sql, "Creature (Entry: {0}) has invalid model {1} defined in table `creature_template_model`, can't load.", entry, model.CreatureDisplayID); return false; } diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 7a37954ae..4a1c9c68b 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -3538,6 +3538,15 @@ namespace Game continue; } + if (data.display != null) + { + if (GetCreatureModelInfo(data.display.CreatureDisplayID) == null) + { + Log.outError(LogFilter.Sql, $"Table `creature` has creature (GUID: {guid} Entry: {data.Id}) with invalid `modelid` {data.display.CreatureDisplayID}, ignoring."); + data.display = null; + } + } + // -1 random, 0 no equipment, if (data.equipmentId != 0) {