mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Core/SpellScripts: Added helper method to validate spells
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "Spell.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellScript.h"
|
||||
|
||||
#include <string>
|
||||
@@ -32,6 +33,17 @@ bool _SpellScript::_Validate(SpellInfo const* entry)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _SpellScript::ValidateSpellInfo(std::vector<uint32> 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;
|
||||
|
||||
@@ -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<uint32> spellIds);
|
||||
};
|
||||
|
||||
// SpellScript interface - enum used for runtime checks of script function calls
|
||||
|
||||
Reference in New Issue
Block a user