Core/Scripts: Allow spell script ValidateSpellInfo to work with any container type

This commit is contained in:
Shauren authored and Ovahlord committed 2021-05-28 18:42:26 +02:00
1 parent 1064209eaf
commit d5c0fda096
2 files changed
+21 -12

No files matched your search

+6 -11
View File
@@ -34,20 +34,15 @@ bool _SpellScript::_Validate(SpellInfo const* entry)
return true;
}
bool _SpellScript::_ValidateSpellInfo(uint32 const* begin, uint32 const* end)
bool _SpellScript::_ValidateSpellInfo(uint32 spellId)
{
bool allValid = true;
while (begin != end)
if (!sSpellMgr->GetSpellInfo(spellId))
{
if (!sSpellMgr->GetSpellInfo(*begin))
{
TC_LOG_ERROR("scripts.spells", "_SpellScript::ValidateSpellInfo: Spell %u does not exist.", *begin);
allValid = false;
}
++begin;
TC_LOG_ERROR("scripts.spells", "_SpellScript::ValidateSpellInfo: Spell %u does not exist.", spellId);
return false;
}
return allValid;
return true;
}
void _SpellScript::_Register()
+15 -1
View File
@@ -443,7 +443,21 @@ class TC_GAME_API _SpellScript
}
private:
static bool _ValidateSpellInfo(uint32 const* begin, uint32 const* end);
template<typename Iterator>
static bool _ValidateSpellInfo(Iterator begin, Iterator end)
{
bool allValid = true;
while (begin != end)
{
if (!_ValidateSpellInfo(*begin))
allValid = false;
++begin;
}
return allValid;
}
static bool _ValidateSpellInfo(uint32 spellId);
};
// SpellScript interface - enum used for runtime checks of script function calls