Scripts/Spells: Modernize spell script internals a bit - this makes Prepare macros unneccessary

This commit is contained in:
Shauren
2023-07-24 00:27:25 +02:00
parent 576ca241ec
commit 228c56f3c5
6 changed files with 1941 additions and 1688 deletions

View File

@@ -1350,8 +1350,8 @@ void ScriptMgr::FillSpellSummary()
UnitAI::FillAISpellInfo();
}
template<typename T, typename F, typename O>
void CreateSpellOrAuraScripts(uint32 spellId, std::vector<T*>& scriptVector, F&& extractor, O* objectInvoker)
template<typename T, typename O>
void CreateSpellOrAuraScripts(uint32 spellId, std::vector<T*>& scriptVector, T*(SpellScriptLoader::*extractor)() const, O* objectInvoker)
{
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
for (auto itr = bounds.first; itr != bounds.second; ++itr)
@@ -1364,11 +1364,11 @@ void CreateSpellOrAuraScripts(uint32 spellId, std::vector<T*>& scriptVector, F&&
if (!tmpscript)
continue;
T* script = (*tmpscript.*extractor)();
T* script = (tmpscript->*extractor)();
if (!script)
continue;
script->_Init(&tmpscript->GetName(), spellId);
script->_Init(tmpscript->GetName(), spellId);
if (!script->_Load(objectInvoker))
{
delete script;