diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-05-27 15:51:58 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-05-27 15:51:58 +0200 |
commit | f2f0aeb562dfc1a78b04d13a14e3c37a58367619 (patch) | |
tree | 477b4676dd546503063fe5596e22f5d01e18ce4f | |
parent | 302c60d3dd8e2734b32d239142c72b1add22aad9 (diff) |
Core/Scripts: Allow spell script ValidateSpellInfo to work with any container type
-rw-r--r-- | src/server/game/Spells/SpellScript.cpp | 17 | ||||
-rw-r--r-- | src/server/game/Spells/SpellScript.h | 16 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index 136b5a525b9..25cdb64d19f 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -35,20 +35,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() diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index b1c3288b325..683b3094c18 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -153,7 +153,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 |