diff options
author | Meji <alvaro.megias@outlook.com> | 2024-06-08 12:48:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-08 12:48:45 +0200 |
commit | ef70cf64814341543fdb8efa403319371d9f3104 (patch) | |
tree | 7c1f87dce911eed8218effccf8b193647b8ec323 | |
parent | 7a8e0f8979669c42e6f9f2460d786e4f58f761f8 (diff) |
Core/Creatures: Validate creature.modelid on startup (#30023)
-rw-r--r-- | sql/updates/world/master/2024_06_08_00_world.sql | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 9 |
3 files changed, 12 insertions, 1 deletions
diff --git a/sql/updates/world/master/2024_06_08_00_world.sql b/sql/updates/world/master/2024_06_08_00_world.sql new file mode 100644 index 00000000000..5c5d6cc5168 --- /dev/null +++ b/sql/updates/world/master/2024_06_08_00_world.sql @@ -0,0 +1,2 @@ +-- Invalid DisplayIds +UPDATE `creature` SET `modelid`=0 WHERE `modelid` IN (1,239,251,252,370,533,959,1041,1405,2709,12346,14952,15939,16051,16622,18736,19338,21360,22106,22748,23033,23148,23504,23646,24446,24472,24922,24923,25030,25452,25572,25579,26101,26198,26223,26273,26363,26590,26762,27029,27074,27861,28283,35014); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 3a9aaf7b317..38d55b98bfa 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -522,7 +522,7 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/) CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&model, creatureInfo); if (!minfo) // Cancel load if no model defined { - TC_LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid model {} defined in table `creature_template`, can't load.", entry, model.CreatureDisplayID); + TC_LOG_ERROR("sql.sql", "Creature (Entry: {}) has invalid model {} defined in table `creature_template_model`, can't load.", entry, model.CreatureDisplayID); return false; } diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b0d86166f3d..5aed2de438a 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2228,6 +2228,15 @@ void ObjectMgr::LoadCreatures() continue; } + if (data.display.has_value()) + { + if (!GetCreatureModelInfo(data.display->CreatureDisplayID)) + { + TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with invalid `modelid` {}, ignoring.", guid, data.id, data.display->CreatureDisplayID); + data.display.reset(); + } + } + // -1 random, 0 no equipment if (data.equipmentId != 0) { |