From d11c80ec54bff97235440ff50c44edd420e777f9 Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 17 Feb 2009 11:27:47 -0600 Subject: [PATCH] *Fix the bug that knockback cause client crash. --HG-- branch : trunk --- src/game/SpellEffects.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 85420fcc23..b529e5139c 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -5935,7 +5935,7 @@ void Spell::EffectKnockBack(uint32 i) return; float x, y; - if(m_targets.HasDest()) + if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { x = m_targets.m_destX; y = m_targets.m_destY; @@ -5948,10 +5948,19 @@ void Spell::EffectKnockBack(uint32 i) float dx = unitTarget->GetPositionX() - x; float dy = unitTarget->GetPositionY() - y; - float dist = sqrt((dx*dx) + (dy*dy)); - - float vcos = dx / dist; - float vsin = dy / dist; + float vcos, vsin; + if(dx < 0.001f && dy < 0.001f) + { + float angle = rand_norm()*2*M_PI; + vcos = cos(angle); + vsin = sin(angle); + } + else + { + float dist = sqrt((dx*dx) + (dy*dy)); + vcos = dx / dist; + vsin = dy / dist; + } WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4)); data.append(unitTarget->GetPackGUID());