Skip to content

Commit

Permalink
Core/Movement: Fix pushback issues and client freeze.
Browse files Browse the repository at this point in the history
  • Loading branch information
Machiavell1 committed Apr 8, 2012
1 parent 1922314 commit e636531
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 13 deletions.
24 changes: 24 additions & 0 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25550,3 +25550,27 @@ void Player::SendMovementSetCanTransitionBetweenSwimAndFly(bool apply)
data << uint32(0); //! movement counter
SendDirectMessage(&data);
}

void Player::SendMovementSetHover(bool apply)
{
WorldPacket data(apply ? SMSG_MOVE_SET_HOVER : SMSG_MOVE_UNSET_HOVER, 12);
data.append(GetPackGUID());
data << uint32(0); //! movement counter
SendDirectMessage(&data);
}

void Player::SendMovementSetWaterWalking(bool apply)
{
WorldPacket data(apply ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK, 12);
data.append(GetPackGUID());
data << uint32(0); //! movement counter
SendDirectMessage(&data);
}

void Player::SendMovementSetFeatherFall(bool apply)
{
WorldPacket data(apply ? SMSG_MOVE_FEATHER_FALL : SMSG_MOVE_NORMAL_FALL, 12);
data.append(GetPackGUID());
data << uint32(0); //! movement counter
SendDirectMessage(&data);
}
3 changes: 3 additions & 0 deletions src/server/game/Entities/Player/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,9 @@ class Player : public Unit, public GridObject<Player>
*/
void SendMovementSetCanFly(bool apply);
void SendMovementSetCanTransitionBetweenSwimAndFly(bool apply);
void SendMovementSetHover(bool apply);
void SendMovementSetWaterWalking(bool apply);
void SendMovementSetFeatherFall(bool apply);

bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }

Expand Down
19 changes: 14 additions & 5 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17598,34 +17598,43 @@ bool Unit::SetHover(bool enable)

void Unit::SendMovementHover()
{
if (GetTypeId() == TYPEID_PLAYER)
ToPlayer()->SendMovementSetHover(HasUnitMovementFlag(MOVEMENTFLAG_HOVER));

WorldPacket data(MSG_MOVE_HOVER, 64);
data.append(GetPackGUID());
BuildMovementPacket(&data);
SendMessageToSet(&data, true);
SendMessageToSet(&data, false);
}

void Unit::SendMovementWaterWalking()
{
if (GetTypeId() == TYPEID_PLAYER)
ToPlayer()->SendMovementSetWaterWalking(HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING));

WorldPacket data(MSG_MOVE_WATER_WALK, 64);
data.append(GetPackGUID());
BuildMovementPacket(&data);
SendMessageToSet(&data, true);
SendMessageToSet(&data, false);
}

void Unit::SendMovementFeatherFall()
{
if (GetTypeId() == TYPEID_PLAYER)
ToPlayer()->SendMovementSetFeatherFall(HasUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW));

WorldPacket data(MSG_MOVE_FEATHER_FALL, 64);
data.append(GetPackGUID());
BuildMovementPacket(&data);
SendMessageToSet(&data, true);
SendMessageToSet(&data, false);
}

void Unit::SendMovementGravityChange()
{
WorldPacket data(MSG_MOVE_GRAVITY_CHNG, 64);
data.append(GetPackGUID());
BuildMovementPacket(&data);
SendMessageToSet(&data, true);
SendMessageToSet(&data, false);
}

void Unit::SendMovementCanFlyChange()
Expand All @@ -17650,5 +17659,5 @@ void Unit::SendMovementCanFlyChange()
WorldPacket data(MSG_MOVE_UPDATE_CAN_FLY, 64);
data.append(GetPackGUID());
BuildMovementPacket(&data);
SendMessageToSet(&data, true);
SendMessageToSet(&data, false);
}
3 changes: 3 additions & 0 deletions src/server/game/Entities/Unit/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,9 @@ enum MovementFlags
MOVEMENTFLAG_MASK_TURNING =
MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT,

MOVEMENTFLAG_MASK_MOVING_FLY =
MOVEMENTFLAG_FLYING | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING,

//! TODO if needed: add more flags to this masks that are exclusive to players
MOVEMENTFLAG_MASK_PLAYER_ONLY =
MOVEMENTFLAG_FLYING,
Expand Down
6 changes: 6 additions & 0 deletions src/server/game/Movement/MotionMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ void MotionMaster::MoveFall(uint32 id/*=0*/)
if (fabs(_owner->GetPositionZ() - tz) < 0.1f)
return;

if (_owner->GetTypeId() == TYPEID_PLAYER)
{
_owner->AddUnitMovementFlag(MOVEMENTFLAG_FALLING);
_owner->m_movementInfo.SetFallTime(0);
}

Movement::MoveSplineInit init(*_owner);
init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), tz);
init.SetFall();
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Server/WorldSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,8 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo* mi)
in conjunction with any of the moving movement flags such as MOVEMENTFLAG_FORWARD.
It will freeze clients that receive this player's movement info.
*/
REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_ROOT) && mi->HasMovementFlag(MOVEMENTFLAG_MASK_MOVING),
MOVEMENTFLAG_MASK_MOVING);
REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_ROOT),
MOVEMENTFLAG_ROOT);

//! Cannot hover without SPELL_AURA_HOVER
REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_HOVER) && !GetPlayer()->HasAuraType(SPELL_AURA_HOVER),
Expand Down
8 changes: 2 additions & 6 deletions src/server/game/Spells/Auras/SpellAuraEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2856,9 +2856,8 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode
target->SetCanFly(apply);
if (!apply)
{
target->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
target->AddUnitMovementFlag(MOVEMENTFLAG_FALLING);
target->m_movementInfo.SetFallTime(0);
target->RemoveUnitMovementFlag(MOVEMENTFLAG_MASK_MOVING_FLY);
target->GetMotionMaster()->MoveFall();
}

Player* player = target->ToPlayer();
Expand Down Expand Up @@ -2889,10 +2888,7 @@ void AuraEffect::HandleAuraWaterWalk(AuraApplication const* aurApp, uint8 mode,
if (apply)
target->AddUnitMovementFlag(MOVEMENTFLAG_WATERWALKING);
else
{
target->RemoveUnitMovementFlag(MOVEMENTFLAG_WATERWALKING);
target->AddUnitMovementFlag(MOVEMENTFLAG_FALLING);
}

target->SendMovementWaterWalking();
}
Expand Down

6 comments on commit e636531

@Vincent-Michael
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :)

@Warpten
Copy link
Contributor

@Warpten Warpten commented on e636531 Apr 8, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, seen the gists today, thanks machi

@ringixx
Copy link

@ringixx ringixx commented on e636531 Apr 8, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Working fine.

@Expecto
Copy link

@Expecto Expecto commented on e636531 Apr 8, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Machiavell1 The Best!

@Havenard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amsjunior1/FaceCore@b1bf242
amsjunior1/FaceCore@682bfd7

I fixed this...
__Hipster glasses on**
Before it was cool.

@Machiavell1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you did an exemplary job reverting my changes, David Caruso.

Please sign in to comment.