aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2020-04-21 22:22:31 +0200
committerjackpoz <giacomopoz@gmail.com>2020-04-21 22:22:31 +0200
commit740afc71358c32257540350a6d7d4071a851452f (patch)
tree14a96348582da4f00f7ff25aa85ca10397169229
parent9407f9bdfa7c8f3cad52f892aef4e31a1781930a (diff)
Core/Spells: Fix assertion triggered
-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 2f2c7f23cd1..874294f5809 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -4396,10 +4396,21 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex)
// 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 = m_spellInfo->Effects[effIndex].MiscValue ? m_spellInfo->Effects[effIndex].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);
}
@@ -4420,11 +4431,22 @@ void Spell::EffectPullTowardsDest(SpellEffIndex effIndex)
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 = m_spellInfo->Effects[effIndex].MiscValue ? m_spellInfo->Effects[effIndex].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);
}