Core/Movement: Fix players still able to fly on SPELL_AURA_FLY and SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED unapply.

Closes #5731
This commit is contained in:
Machiavelli
2012-03-16 17:10:01 +01:00
parent bea8fcfbfa
commit f8c04b1bc5
5 changed files with 83 additions and 26 deletions
@@ -25173,3 +25173,21 @@ bool Player::SetHover(bool enable)
return true;
}
void Player::SendMovementSetCanFly(bool apply)
{
WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12);
data.append(GetPackGUID());
data << uint32(0); //! movement counter
SendDirectMessage(&data);
}
void Player::SendMovementSetCanTransitionBetweenSwimAndFly(bool apply)
{
WorldPacket data(apply ?
SMSG_MOVE_SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY :
SMSG_MOVE_UNSET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY, 12);
data.append(GetPackGUID());
data << uint32(0); //! movement counter
SendDirectMessage(&data);
}
+7
View File
@@ -2483,6 +2483,13 @@ class Player : public Unit, public GridObject<Player>
#pragma region Player Movement
/*! These methods send different packets to the client in apply and unapply case.
These methods are only sent to the current unit.
*/
void SendMovementSetCanFly(bool apply);
void SendMovementSetCanTransitionBetweenSwimAndFly(bool apply);
bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }
//! Return collision height sent to client
+33
View File
@@ -17541,3 +17541,36 @@ void Unit::SendMovementFeatherFall()
BuildMovementPacket(&data);
SendMessageToSet(&data, true);
}
void Unit::SendMovementGravityChange()
{
WorldPacket data(MSG_MOVE_GRAVITY_CHNG, 64);
data.append(GetPackGUID());
BuildMovementPacket(&data);
SendMessageToSet(&data, true);
}
void Unit::SendMovementCanFlyChange()
{
/*!
if ( a3->MoveFlags & MOVEMENTFLAG_CAN_FLY )
{
v4->MoveFlags |= 0x1000000u;
result = 1;
}
else
{
if ( v4->MoveFlags & MOVEMENTFLAG_FLYING )
CMovement::DisableFlying(v4);
v4->MoveFlags &= 0xFEFFFFFFu;
result = 1;
}
*/
if (GetTypeId() == TYPEID_PLAYER)
ToPlayer()->SendMovementSetCanFly(CanFly());
WorldPacket data(MSG_MOVE_UPDATE_CAN_FLY, 64);
data.append(GetPackGUID());
BuildMovementPacket(&data);
SendMessageToSet(&data, true);
}
+9
View File
@@ -1631,9 +1631,18 @@ class Unit : public WorldObject
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
void SendMonsterMoveTransport(Unit* vehicleOwner);
void SendMovementFlagUpdate();
/*! These methods send the same packet to the client in apply and unapply case.
The client-side interpretation of this packet depends on the presence of relevant movementflags
which are sent with movementinfo. Furthermore, these packets are broadcast to nearby players as well
as the current unit.
*/
void SendMovementHover();
void SendMovementFeatherFall();
void SendMovementWaterWalking();
void SendMovementGravityChange();
void SendMovementCanFlyChange();
bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY);}
bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING);}
virtual bool SetWalk(bool enable);
@@ -2844,21 +2844,14 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode
return;
}
if (target->GetTypeId() == TYPEID_UNIT)
target->SetCanFly(apply);
//! Not entirely sure if this should be sent for creatures as well, but I don't think so.
target->SetCanFly(apply);
Player* player = target->ToPlayer();
if (!player)
player = target->m_movedPlayer;
if (Player* player = target->m_movedPlayer)
{
// allow flying
WorldPacket data;
if (apply)
data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
else
data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
data.append(target->GetPackGUID());
data << uint32(0); // movement counter
player->SendDirectMessage(&data);
}
if (player)
player->SendMovementCanFlyChange();
}
void AuraEffect::HandleAuraWaterWalk(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -3231,25 +3224,22 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp,
Unit* target = aurApp->GetTarget();
// Enable Fly mode for flying mounts
//! Update ability to fly
if (GetAuraType() == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK && (apply || (!target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !target->HasAuraType(SPELL_AURA_FLY))))
{
if (Player* player = target->m_movedPlayer)
{
WorldPacket data;
if (apply)
data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
else
data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
data.append(player->GetPackGUID());
data << uint32(0); // unknown
player->SendDirectMessage(&data);
}
target->SetCanFly(apply);
Player* player = target->ToPlayer();
if (!player)
player = target->m_movedPlayer;
if (player)
player->SendMovementCanFlyChange();
}
//! Someone should clean up these hacks and remove it from this function. It doesn't even belong here.
if (mode & AURA_EFFECT_HANDLE_REAL)
{
//Players on flying mounts must be immune to polymorph