Core/ScriptSystem: Add missing script call preparation for SpellScripts - fixes issues with core false alarms after recent changes

--HG--
branch : trunk
This commit is contained in:
QAston
2010-10-05 08:17:10 +02:00
parent b345dc5061
commit cac4cfda42
3 changed files with 20 additions and 0 deletions

View File

@@ -7219,6 +7219,7 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex)
bool preventDefault = false;
for(std::list<SpellScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_EFFECT);
std::list<SpellScript::EffectHandler>::iterator effEndItr = (*scritr)->OnEffect.end(), effItr = (*scritr)->OnEffect.begin();
for(; effItr != effEndItr ; ++effItr)
{
@@ -7228,6 +7229,7 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex)
}
if (!preventDefault)
preventDefault = (*scritr)->_IsDefaultEffectPrevented(effIndex);
(*scritr)->_FinishScriptCall();
}
return preventDefault;
}
@@ -7236,11 +7238,13 @@ void Spell::CallScriptBeforeHitHandlers()
{
for(std::list<SpellScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_HIT);
std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
for(; hookItr != hookItrEnd ; ++hookItr)
{
((*scritr)->*(*hookItr))();
}
(*scritr)->_FinishScriptCall();
}
}
@@ -7248,11 +7252,13 @@ void Spell::CallScriptOnHitHandlers()
{
for(std::list<SpellScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_HIT);
std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->OnHit.end(), hookItr = (*scritr)->OnHit.begin();
for(; hookItr != hookItrEnd ; ++hookItr)
{
((*scritr)->*(*hookItr))();
}
(*scritr)->_FinishScriptCall();
}
}
@@ -7260,10 +7266,12 @@ void Spell::CallScriptAfterHitHandlers()
{
for(std::list<SpellScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_HIT);
std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->AfterHit.end(), hookItr = (*scritr)->AfterHit.begin();
for(; hookItr != hookItrEnd ; ++hookItr)
{
((*scritr)->*(*hookItr))();
}
(*scritr)->_FinishScriptCall();
}
}

View File

@@ -195,6 +195,16 @@ void SpellScript::_InitHit()
m_hitPreventDefaultEffectMask = 0;
}
void SpellScript::_PrepareScriptCall(SpellScriptHookType hookType)
{
m_currentScriptState = hookType;
}
void SpellScript::_FinishScriptCall()
{
m_currentScriptState = SPELL_SCRIPT_STATE_NONE;
}
Unit * SpellScript::GetCaster()
{
return m_spell->GetCaster();

View File

@@ -152,6 +152,8 @@ class SpellScript : public _SpellScript
void _InitHit();
bool _IsEffectPrevented(SpellEffIndex effIndex) {return m_hitPreventEffectMask & (1<<effIndex);};
bool _IsDefaultEffectPrevented(SpellEffIndex effIndex) {return m_hitPreventDefaultEffectMask & (1<<effIndex);};
void _PrepareScriptCall(SpellScriptHookType hookType);
void _FinishScriptCall();
bool IsInHitPhase() { return (m_currentScriptState >= HOOK_SPELL_HIT_START && m_currentScriptState < HOOK_SPELL_HIT_END); };
bool IsInEffectHook() { return (m_currentScriptState == SPELL_SCRIPT_HOOK_EFFECT); };
private: