From 9edc62f2850469f2a800ad0d3f4faef1b6915d38 Mon Sep 17 00:00:00 2001 From: joschiwald Date: Thu, 12 Jan 2017 23:03:08 +0100 Subject: Core/SpellScripts: Added helper method to validate spells (cherry picked from commit 2b5d7eef3a091e67c27e853d43ac0bebbfa67531) --- src/server/game/Spells/SpellScript.cpp | 12 ++++++++++++ src/server/game/Spells/SpellScript.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index 28d2b81a44f..c56fb6ce0ef 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -18,6 +18,7 @@ #include "Spell.h" #include "ScriptMgr.h" #include "SpellAuras.h" +#include "SpellMgr.h" #include "SpellScript.h" #include "SpellMgr.h" #include @@ -32,6 +33,17 @@ bool _SpellScript::_Validate(SpellInfo const* entry) return true; } +bool _SpellScript::ValidateSpellInfo(std::vector spellIds) +{ + for (uint32 spellId : spellIds) + if (!sSpellMgr->GetSpellInfo(spellId)) + { + TC_LOG_ERROR("scripts.spells", "_SpellScript::ValidateSpellInfo: Spell %u does not exist.", spellId); + return false; + } + return true; +} + void _SpellScript::_Register() { m_currentScriptState = SPELL_SCRIPT_STATE_REGISTRATION; diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index 4dc39370b1e..51d3c2a85ab 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -132,6 +132,8 @@ class TC_GAME_API _SpellScript // Function called when script is destroyed // use for: deallocating memory allocated by script virtual void Unload() { } + // Helpers + static bool ValidateSpellInfo(std::vector spellIds); }; // SpellScript interface - enum used for runtime checks of script function calls -- cgit v1.2.3