mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 10:00:28 +00:00
feat(Core/SmartAI): add startup error for non existent SmartAI entries (#20694)
This commit is contained in:
@@ -296,10 +296,89 @@ void SmartAIMgr::LoadSmartAIFromDB()
|
||||
mEventMap[source_type][temp.entryOrGuid].push_back(temp);
|
||||
} while (result->NextRow());
|
||||
|
||||
CheckIfSmartAIInDatabaseExists();
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} SmartAI scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
void SmartAIMgr::CheckIfSmartAIInDatabaseExists()
|
||||
{
|
||||
// SMART_SCRIPT_TYPE_CREATURE
|
||||
for (auto const& [entry, creatureTemplate] : *sObjectMgr->GetCreatureTemplates())
|
||||
{
|
||||
if (creatureTemplate.AIName != "SmartAI")
|
||||
continue;
|
||||
|
||||
bool found = false;
|
||||
|
||||
// check template SAI
|
||||
if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].find(creatureTemplate.Entry) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].end())
|
||||
found = true;
|
||||
else
|
||||
{
|
||||
// check GUID SAI
|
||||
for (auto const& pair : sObjectMgr->GetAllCreatureData())
|
||||
{
|
||||
if (pair.second.id1 != creatureTemplate.Entry)
|
||||
continue;
|
||||
|
||||
if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].find((-1) * pair.first) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].end())
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
LOG_ERROR("sql.sql", "Creature entry ({}) has SmartAI enabled but no SmartAI entries in the database.", creatureTemplate.Entry);
|
||||
}
|
||||
|
||||
// SMART_SCRIPT_TYPE_GAMEOBJECT
|
||||
for (auto const& [entry, gameobjectTemplate] : *sObjectMgr->GetGameObjectTemplates())
|
||||
{
|
||||
if (gameobjectTemplate.AIName != "SmartGameObjectAI")
|
||||
continue;
|
||||
|
||||
bool found = false;
|
||||
|
||||
// check template SAI
|
||||
if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_GAMEOBJECT)].find(gameobjectTemplate.entry) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_GAMEOBJECT)].end())
|
||||
found = true;
|
||||
else
|
||||
{
|
||||
// check GUID SAI
|
||||
for (auto const& pair : sObjectMgr->GetAllGOData())
|
||||
{
|
||||
if (pair.second.id != gameobjectTemplate.entry)
|
||||
continue;
|
||||
|
||||
if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_GAMEOBJECT)].find((-1) * pair.first) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_GAMEOBJECT)].end())
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
LOG_ERROR("sql.sql", "Gameobject entry ({}) has SmartGameobjectAI enabled but no SmartAI entries in the database.", gameobjectTemplate.entry);
|
||||
}
|
||||
|
||||
// SMART_SCRIPT_TYPE_AREATRIGGER
|
||||
uint32 scriptID = sObjectMgr->GetScriptId("SmartTrigger");
|
||||
|
||||
for (auto const& pair : sObjectMgr->GetAllAreaTriggerScriptData())
|
||||
{
|
||||
if (pair.second != scriptID)
|
||||
continue;
|
||||
|
||||
if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_AREATRIGGER)].find(pair.first) == mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_AREATRIGGER)].end())
|
||||
LOG_ERROR("sql.sql", "AreaTrigger entry ({}) has SmartTrigger enabled but no SmartAI entries in the database.", pair.first);
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ bool SmartAIMgr::EventHasInvoker(SMART_EVENT event)
|
||||
{
|
||||
switch (event)
|
||||
|
||||
Reference in New Issue
Block a user