mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
feat(Core/Script): Allow spell script ValidateSpellInfo to work with any container type (#6078)
* Cherry-pick f2f0aeb562
Co-authored-by: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
@@ -14,26 +14,21 @@ bool _SpellScript::_Validate(SpellInfo const* entry)
|
|||||||
{
|
{
|
||||||
if (!Validate(entry))
|
if (!Validate(entry))
|
||||||
{
|
{
|
||||||
LOG_ERROR("server", "_SpellScript::_Validate: Spell `%u` did not pass Validate() function of script `%s` - script will not be added to the spell", entry->Id, m_scriptName->c_str());
|
LOG_ERROR("scripts.spells", "_SpellScript::_Validate: Spell `%u` did not pass Validate() function of script `%s` - script will not be added to the spell", entry->Id, m_scriptName->c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _SpellScript::_ValidateSpellInfo(uint32 const* begin, uint32 const* end)
|
bool _SpellScript::_ValidateSpellInfo(uint32 spellId)
|
||||||
{
|
{
|
||||||
bool allValid = true;
|
if (!sSpellMgr->GetSpellInfo(spellId))
|
||||||
while (begin != end)
|
|
||||||
{
|
{
|
||||||
if (!sSpellMgr->GetSpellInfo(*begin))
|
LOG_ERROR("scripts.spells", "_SpellScript::ValidateSpellInfo: Spell %u does not exist.", spellId);
|
||||||
{
|
return false;
|
||||||
LOG_ERROR("server", "_SpellScript::_ValidateSpellInfo: Spell %u does not exist.", *begin);
|
|
||||||
allValid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
++begin;
|
|
||||||
}
|
}
|
||||||
return allValid;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _SpellScript::_Register()
|
void _SpellScript::_Register()
|
||||||
|
|||||||
@@ -123,7 +123,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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
|
// SpellScript interface - enum used for runtime checks of script function calls
|
||||||
|
|||||||
Reference in New Issue
Block a user