aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellEffects.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
-rw-r--r--src/server/game/Spells/SpellEffects.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 6d8ec6685ab..43fb5bf68ef 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -4010,10 +4010,21 @@ void Spell::EffectPullTowards()
// This is a blizzlike mistake: this should be 2D distance according to projectile motion formulas, but Blizzard erroneously used 3D distance.
float distXY = unitTarget->GetExactDist(pos);
+
+ // Avoid division by 0
+ if (distXY < 0.001)
+ return;
+
float distZ = pos.GetPositionZ() - unitTarget->GetPositionZ();
float speedXY = effectInfo->MiscValue ? effectInfo->MiscValue / 10.0f : 30.0f;
float speedZ = (2 * speedXY * speedXY * distZ + Movement::gravity * distXY * distXY) / (2 * speedXY * distXY);
+ if (!std::isfinite(speedZ))
+ {
+ TC_LOG_ERROR("spells", "Spell %u with SPELL_EFFECT_PULL_TOWARDS called with invalid speedZ. %s", m_spellInfo->Id, GetDebugInfo().c_str());
+ return;
+ }
+
unitTarget->JumpTo(speedXY, speedZ, true, pos);
}
@@ -4034,11 +4045,22 @@ void Spell::EffectPullTowardsDest()
Position const* pos = m_targets.GetDstPos();
// This is a blizzlike mistake: this should be 2D distance according to projectile motion formulas, but Blizzard erroneously used 3D distance
float distXY = unitTarget->GetExactDist(pos);
+
+ // Avoid division by 0
+ if (distXY < 0.001)
+ return;
+
float distZ = pos->GetPositionZ() - unitTarget->GetPositionZ();
float speedXY = effectInfo->MiscValue ? effectInfo->MiscValue / 10.0f : 30.0f;
float speedZ = (2 * speedXY * speedXY * distZ + Movement::gravity * distXY * distXY) / (2 * speedXY * distXY);
+ if (!std::isfinite(speedZ))
+ {
+ TC_LOG_ERROR("spells", "Spell %u with SPELL_EFFECT_PULL_TOWARDS_DEST called with invalid speedZ. %s", m_spellInfo->Id, GetDebugInfo().c_str());
+ return;
+ }
+
unitTarget->JumpTo(speedXY, speedZ, true, *pos);
}