From 18f50212b05fbc5fa67c5dc924824b8dea9150f4 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 7 Jun 2009 11:49:50 -0500 Subject: *Fix a crash in spell::cast --HG-- branch : trunk --- src/game/Spell.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index cb67391dcbf..ecd2852dd7c 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2238,6 +2238,9 @@ void Spell::cancel() void Spell::cast(bool skipCheck) { + // update pointers base at GUIDs to prevent access to non-existed already object + UpdatePointers(); + if(m_targets.getUnitTarget() && m_targets.getUnitTarget()->isAlive() && !m_targets.getUnitTarget()->isVisibleForOrDetect(m_caster, true)) { cancel(); @@ -2247,9 +2250,6 @@ void Spell::cast(bool skipCheck) SetExecutedCurrently(true); uint8 castResult = 0; - // update pointers base at GUIDs to prevent access to non-existed already object - UpdatePointers(); - // cancel at lost main target unit if(!m_targets.getUnitTarget() && m_targets.getUnitTargetGUID() && m_targets.getUnitTargetGUID() != m_caster->GetGUID()) { -- cgit v1.2.3 From 5e87f3144cca2cae1add4acd18affcfbb2d981e5 Mon Sep 17 00:00:00 2001 From: krz Date: Sun, 7 Jun 2009 19:06:51 +0200 Subject: Fix crash in Aura::Update. Check if target has Invisibility or Stealth aura before checking IsVisibleForOrDetect to allow cast spells on invisible triggers and fix pet linked spells. Send correct message to client if target is not visible for caster. Sorry for my previous buging commits. --HG-- branch : trunk --- src/game/Spell.cpp | 12 +++++++----- src/game/SpellAuras.cpp | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index ecd2852dd7c..411a130539e 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2241,11 +2241,13 @@ void Spell::cast(bool skipCheck) // update pointers base at GUIDs to prevent access to non-existed already object UpdatePointers(); - if(m_targets.getUnitTarget() && m_targets.getUnitTarget()->isAlive() && !m_targets.getUnitTarget()->isVisibleForOrDetect(m_caster, true)) - { - cancel(); - return; - } + if(Unit *pTarget = m_targets.getUnitTarget()) + if(pTarget->isAlive() && (pTarget->HasAuraType(SPELL_AURA_MOD_STEALTH) || pTarget->HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) && !pTarget->IsFriendlyTo(m_caster) && !pTarget->isVisibleForOrDetect(m_caster, true)) + { + SendCastResult(SPELL_FAILED_BAD_TARGETS); + finish(false); + return; + } SetExecutedCurrently(true); uint8 castResult = 0; diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 5fa6e5843fc..937833eab7d 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -543,7 +543,10 @@ void Aura::Update(uint32 diff) } // Channeled aura required check distance from caster except in possessed cases - Unit *pRealTarget = (GetSpellProto()->EffectApplyAuraName[m_effIndex] == SPELL_AURA_PERIODIC_TRIGGER_SPELL && !IsAreaOfEffectSpell(sSpellStore.LookupEntry(GetSpellProto()->EffectTriggerSpell[m_effIndex])) && GetTriggerTarget()) ? GetTriggerTarget() : m_target; + Unit *pRealTarget = (GetSpellProto()->EffectApplyAuraName[m_effIndex] == SPELL_AURA_PERIODIC_TRIGGER_SPELL && + sSpellStore.LookupEntry(GetSpellProto()->EffectTriggerSpell[m_effIndex]) && + !IsAreaOfEffectSpell(sSpellStore.LookupEntry(GetSpellProto()->EffectTriggerSpell[m_effIndex])) && + GetTriggerTarget()) ? GetTriggerTarget() : m_target; if(IsChanneledSpell(m_spellProto) && !pRealTarget->isPossessed() && pRealTarget->GetGUID() != GetCasterGUID()) -- cgit v1.2.3