mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 23:50:44 +01:00
Core/ScriptMgr: use vector instead of list to contain Spell and Aura scripts and hooks
(cherry picked from commit cbb5c073ce)
This commit is contained in:
@@ -1207,12 +1207,11 @@ void ScriptMgr::FillSpellSummary()
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename F>
|
||||
void CreateSpellOrAuraScripts(uint32 spellId, std::list<T*>& scriptVector, F&& extractor)
|
||||
template<typename T, typename F, typename O>
|
||||
void CreateSpellOrAuraScripts(uint32 spellId, std::vector<T*>& scriptVector, F&& extractor, O* objectInvoker)
|
||||
{
|
||||
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
|
||||
|
||||
for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
|
||||
for (auto itr = bounds.first; itr != bounds.second; ++itr)
|
||||
{
|
||||
// When the script is disabled continue with the next one
|
||||
if (!itr->second.second)
|
||||
@@ -1223,24 +1222,28 @@ void CreateSpellOrAuraScripts(uint32 spellId, std::list<T*>& scriptVector, F&& e
|
||||
continue;
|
||||
|
||||
T* script = (*tmpscript.*extractor)();
|
||||
|
||||
if (!script)
|
||||
continue;
|
||||
|
||||
script->_Init(&tmpscript->GetName(), spellId);
|
||||
if (!script->_Load(objectInvoker))
|
||||
{
|
||||
delete script;
|
||||
continue;
|
||||
}
|
||||
|
||||
scriptVector.push_back(script);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector)
|
||||
void ScriptMgr::CreateSpellScripts(uint32 spellId, std::vector<SpellScript*>& scriptVector, Spell* invoker) const
|
||||
{
|
||||
CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetSpellScript);
|
||||
CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetSpellScript, invoker);
|
||||
}
|
||||
|
||||
void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector)
|
||||
void ScriptMgr::CreateAuraScripts(uint32 spellId, std::vector<AuraScript*>& scriptVector, Aura* invoker) const
|
||||
{
|
||||
CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetAuraScript);
|
||||
CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetAuraScript, invoker);
|
||||
}
|
||||
|
||||
SpellScriptLoader* ScriptMgr::GetSpellScriptLoader(uint32 scriptId)
|
||||
|
||||
Reference in New Issue
Block a user