From 523dab764b0b3ebe76f957115e976b36fb79987e Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 28 Dec 2017 12:12:58 -0300 Subject: Core/AI: Added a way to specify if certain AI types mustn't be allowed on DB Ref 072c884ed86a9bf895cd5f53b0f6480ae14c3059 Ref 2c7e921cdc14527bd99d6976793e69999f262f9d (cherry picked from commit a998bba5c239d6bae8426b989ec96475efb969ae) --- src/server/game/Globals/ObjectMgr.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/server/game/Globals/ObjectMgr.cpp') diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 387910ee1e0..12f14c6bbcb 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -946,16 +946,23 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) const_cast(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(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(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(cInfo)->AIName.clear(); + } + else + { + DBPermit const* permit = dynamic_cast(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(cInfo)->AIName.clear(); + } + } } FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction); -- cgit v1.2.3