From caaa77deb285d65b1bc3a0c6f7b5f88ec3508d0c Mon Sep 17 00:00:00 2001 From: QAston Date: Mon, 4 Oct 2010 17:44:49 +0200 Subject: Core/ScriptSystem: Add basic code for runtime checks of function calls in AuraScripts Make AuraScript::PreventDefaultAction() do not take parameters and add description for the function Remove PreventDefaultEffect() from aura script, use PreventDefaultAction() instead Unload aura scripts memory on aura delete --HG-- branch : trunk --- src/server/game/Spells/SpellScript.h | 59 ++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 13 deletions(-) (limited to 'src/server/game/Spells/SpellScript.h') diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index dea3ebbfc8d..f152fe28e98 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -41,13 +41,26 @@ class WorldObject; #define SPELL_EFFECT_ANY (uint16)-1 #define SPELL_AURA_ANY (uint16)-1 +enum SpellScriptState +{ + SPELL_SCRIPT_STATE_NONE = 0, + SPELL_SCRIPT_STATE_REGISTRATION, + SPELL_SCRIPT_STATE_LOADING, + SPELL_SCRIPT_STATE_UNLOADING, +}; +#define SPELL_SCRIPT_STATE_END SPELL_SCRIPT_STATE_UNLOADING + 1 + // helper class from which SpellScript and SpellAura derive, use these classes instead class _SpellScript { // internal use classes & functions // DO NOT OVERRIDE THESE IN SCRIPTS protected: - virtual bool _Validate(SpellEntry const * entry, const char * scriptname); + virtual bool _Validate(SpellEntry const * entry); + public: + virtual void _Register(); + virtual void _Unload(); + virtual void _Init(const std::string * scriptname, uint32 spellId); protected: class EffectHook { @@ -78,6 +91,10 @@ class _SpellScript private: uint16 effAurName; }; + + uint8 m_currentScriptState; + const std::string * m_scriptName; + uint32 m_scriptSpellId; public: // // SpellScript/AuraScript interface base @@ -116,7 +133,7 @@ class SpellScript : public _SpellScript }; typedef SpellHitFnType HitHandler; public: - bool _Validate(SpellEntry const * entry, const char * scriptname); + bool _Validate(SpellEntry const * entry); bool _Load(Spell * spell); void _InitHit(); bool _IsEffectPrevented(SpellEffIndex effIndex) {return m_hitPreventEffectMask & (1< OnEffectCalcSpellMod; #define AuraEffectCalcSpellModFn(F, I, N) EffectCalcSpellModHandler((AuraEffectCalcSpellModFnType)&F, I, N) + // AuraScript interface - hook/effect execution manipulators + + // prevents default action of a hook from being executed (works only while called in a hook which default action can be prevented) + void PreventDefaultAction(); + // AuraScript interface - functions which are redirecting to Aura class // returns proto of the spell -- cgit v1.2.3