*Fix the bug that knockback cause client crash.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-17 11:27:47 -06:00
parent 3510eb4896
commit d11c80ec54
+14 -5
View File
@@ -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());