aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Examples
diff options
context:
space:
mode:
authorQAston <none@none>2010-10-08 21:33:44 +0200
committerQAston <none@none>2010-10-08 21:33:44 +0200
commit1760e42e2caa99d3de0038d1b52f64a1daeb665a (patch)
tree9d95c4a73c675b3fb59724a1b0a908e5c9c3a490 /src/server/scripts/Examples
parente5e53498cede475ae0d80623e89c4a3cbec39b62 (diff)
Core/ScriptSystem: Add compile time type check of function assigned to hooks - prevents incorrect function calls. Since this rev you have to put PrepareSpellScript(<yourscriptclassnamehere>) at the beginning of every spell script. Yes, i know it's unhandy, but unfortunately C++ preprocessor is very limited, so you have to do that extra work each time you write a script:(.
--HG-- branch : trunk
Diffstat (limited to 'src/server/scripts/Examples')
-rw-r--r--src/server/scripts/Examples/example_spell.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/server/scripts/Examples/example_spell.cpp b/src/server/scripts/Examples/example_spell.cpp
index 42126c953c3..5397cd161d8 100644
--- a/src/server/scripts/Examples/example_spell.cpp
+++ b/src/server/scripts/Examples/example_spell.cpp
@@ -33,6 +33,10 @@ class spell_ex_5581 : public SpellScriptLoader
class spell_ex_5581SpellScript : public SpellScript
{
+ // initialize script, this macro does compile time check for type of the function - prevents possible issues
+ // if you have assigned wrong type of function to a hook you'll receive type conversion error during build
+ // this line is required, otherwise you'll get XXXHandlerFunction - identifier not found errors
+ PrepareSpellScript(spell_ex_5581SpellScript)
enum Spells
{
SPELL_TRIGGERED = 18282
@@ -100,6 +104,7 @@ class spell_ex_5581 : public SpellScriptLoader
{
// we're registering our function here
// function HandleDummy will be called when unit is hit by spell, just before default effect 0 handler
+ //OnEffect += SpellEffectFn(spell_ex_5581SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
OnEffect += SpellEffectFn(spell_ex_5581SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
// this will prompt an error on startup because effect 0 of spell 49375 is set to SPELL_EFFECT_DUMMY, not SPELL_EFFECT_APPLY_AURA
//OnEffect += SpellEffectFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
@@ -265,6 +270,7 @@ class spell_ex : public SpellScriptLoader
class spell_ex_SpellScript : public SpellScript
{
+ PrepareSpellScript(spell_ex_SpellScript)
//bool Validate(SpellEntry const * spellEntry){return true;}
//bool Load(){return true;}
//void Unload(){}