diff options
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index ece9bdd7015..b10f3f661c9 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -817,16 +817,23 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) const_cast<CreatureTemplate*>(cInfo)->maxgold = cInfo->mingold; } - if (cInfo->AIName == "TotemAI" || cInfo->AIName == "PetAI") + if (!cInfo->AIName.empty()) { - TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has not-allowed `AIName` '%s' set, removing", cInfo->Entry, cInfo->AIName.c_str()); - const_cast<CreatureTemplate*>(cInfo)->AIName.clear(); - } - - if (!cInfo->AIName.empty() && !sCreatureAIRegistry->HasItem(cInfo->AIName)) - { - TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has non-registered `AIName` '%s' set, removing", cInfo->Entry, cInfo->AIName.c_str()); - const_cast<CreatureTemplate*>(cInfo)->AIName.clear(); + auto registryItem = sCreatureAIRegistry->GetRegistryItem(cInfo->AIName); + if (!registryItem) + { + TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has non-registered `AIName` '%s' set, removing", cInfo->Entry, cInfo->AIName.c_str()); + const_cast<CreatureTemplate*>(cInfo)->AIName.clear(); + } + else + { + DBPermit const* permit = dynamic_cast<DBPermit const*>(registryItem); + if (!ASSERT_NOTNULL(permit)->IsScriptNameAllowedInDB()) + { + TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has not-allowed `AIName` '%s' set, removing", cInfo->Entry, cInfo->AIName.c_str()); + const_cast<CreatureTemplate*>(cInfo)->AIName.clear(); + } + } } FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction); |