diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-12-28 12:12:58 -0300 | 
|---|---|---|
| committer | funjoker <funjoker109@gmail.com> | 2021-04-15 05:53:27 +0200 | 
| commit | 523dab764b0b3ebe76f957115e976b36fb79987e (patch) | |
| tree | 58915173a1e50194338174f47092b7470c1ac481 /src/server/game/Globals/ObjectMgr.cpp | |
| parent | a7883380ce4c827db103b0c43faca6632c3d1f66 (diff) | |
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)
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 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<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);  | 
