aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 6f309a148ce..a9961e06cbc 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3024,7 +3024,12 @@ void Spell::cancel()
void Spell::cast(bool skipCheck)
{
// update pointers base at GUIDs to prevent access to non-existed already object
- UpdatePointers();
+ if (!UpdatePointers())
+ {
+ // cancel the spell if UpdatePointers() returned false, something wrong happened there
+ cancel();
+ return;
+ }
// cancel at lost explicit target during cast
if (m_targets.GetObjectTargetGUID() && !m_targets.GetObjectTarget())
@@ -3274,7 +3279,12 @@ void Spell::handle_immediate()
uint64 Spell::handle_delayed(uint64 t_offset)
{
- UpdatePointers();
+ if (!UpdatePointers())
+ {
+ // finish the spell if UpdatePointers() returned false, something wrong happened there
+ finish(false);
+ return 0;
+ }
if (m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
@@ -3429,7 +3439,12 @@ void Spell::SendSpellCooldown()
void Spell::update(uint32 difftime)
{
// update pointers based at it's GUIDs
- UpdatePointers();
+ if (!UpdatePointers())
+ {
+ // cancel the spell if UpdatePointers() returned false, something wrong happened there
+ cancel();
+ return;
+ }
if (m_targets.GetUnitTargetGUID() && !m_targets.GetUnitTarget())
{
@@ -4283,6 +4298,7 @@ void Spell::TakeCastItem()
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
+ m_castItemGUID = 0;
}
}
@@ -4521,6 +4537,7 @@ void Spell::TakeReagents()
}
m_CastItem = NULL;
+ m_castItemGUID = 0;
}
// if GetItemTarget is also spell reagent
@@ -6336,7 +6353,7 @@ void Spell::DelayedChannel()
SendChannelUpdate(m_timer);
}
-void Spell::UpdatePointers()
+bool Spell::UpdatePointers()
{
if (m_originalCasterGUID == m_caster->GetGUID())
m_originalCaster = m_caster;
@@ -6348,13 +6365,18 @@ void Spell::UpdatePointers()
}
if (m_castItemGUID && m_caster->GetTypeId() == TYPEID_PLAYER)
+ {
m_CastItem = m_caster->ToPlayer()->GetItemByGuid(m_castItemGUID);
+ // cast item not found, somehow the item is no longer where we expected
+ if (!m_CastItem)
+ return false;
+ }
m_targets.Update(m_caster);
// further actions done only for dest targets
if (!m_targets.HasDst())
- return;
+ return true;
// cache last transport
WorldObject* transport = NULL;
@@ -6375,6 +6397,8 @@ void Spell::UpdatePointers()
dest._position.RelocateOffset(dest._transportOffset);
}
}
+
+ return true;
}
CurrentSpellTypes Spell::GetCurrentContainer() const