aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-02-17 11:27:47 -0600
committermegamage <none@none>2009-02-17 11:27:47 -0600
commitd11c80ec54bff97235440ff50c44edd420e777f9 (patch)
treed89e762cde414f2f3f9d43e353cc78e6b721dc6f
parent3510eb4896ec0aece55f554a48349e9a016f84b5 (diff)
*Fix the bug that knockback cause client crash.
--HG-- branch : trunk
-rw-r--r--src/game/SpellEffects.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 85420fcc233..b529e5139c9 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());