mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 11:25:42 +00:00
fix(Core/Movement): Implement order counters (#23015)
This commit is contained in:
@@ -1337,9 +1337,10 @@ void Player::SendTeleportAckPacket()
|
||||
{
|
||||
WorldPacket data(MSG_MOVE_TELEPORT_ACK, 41);
|
||||
data << GetPackGUID();
|
||||
data << uint32(0); // this value increments every time
|
||||
data << GetSession()->GetOrderCounter(); // movement counter
|
||||
BuildMovementPacket(&data);
|
||||
GetSession()->SendPacket(&data);
|
||||
GetSession()->IncrementOrderCounter();
|
||||
}
|
||||
|
||||
bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options /*= 0*/, Unit* target /*= nullptr*/, bool newInstance /*= false*/)
|
||||
@@ -4425,27 +4426,29 @@ void Player::DeleteOldRecoveryItems(uint32 keepDays)
|
||||
void Player::SetMovement(PlayerMovementType pType)
|
||||
{
|
||||
WorldPacket data;
|
||||
const PackedGuid& guid = GetPackGUID();
|
||||
switch (pType)
|
||||
{
|
||||
case MOVE_ROOT:
|
||||
data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size() + 4);
|
||||
data.Initialize(SMSG_FORCE_MOVE_ROOT, guid.size() + 4);
|
||||
break;
|
||||
case MOVE_UNROOT:
|
||||
data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size() + 4);
|
||||
data.Initialize(SMSG_FORCE_MOVE_UNROOT, guid.size() + 4);
|
||||
break;
|
||||
case MOVE_WATER_WALK:
|
||||
data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size() + 4);
|
||||
data.Initialize(SMSG_MOVE_WATER_WALK, guid.size() + 4);
|
||||
break;
|
||||
case MOVE_LAND_WALK:
|
||||
data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size() + 4);
|
||||
data.Initialize(SMSG_MOVE_LAND_WALK, guid.size() + 4);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("entities.player", "Player::SetMovement: Unsupported move type ({}), data not sent to client.", pType);
|
||||
return;
|
||||
}
|
||||
data << GetPackGUID();
|
||||
data << uint32(0);
|
||||
data << guid;
|
||||
data << GetSession()->GetOrderCounter(); // movement counter
|
||||
GetSession()->SendPacket(&data);
|
||||
GetSession()->IncrementOrderCounter();
|
||||
}
|
||||
|
||||
/* Preconditions:
|
||||
@@ -11701,13 +11704,56 @@ void Player::SendInitialPacketsAfterAddToMap()
|
||||
if (HasStunAura())
|
||||
SetMovement(MOVE_ROOT);
|
||||
|
||||
WorldPacket setCompoundState(SMSG_MULTIPLE_MOVES, 100);
|
||||
setCompoundState << uint32(0); // size placeholder
|
||||
|
||||
// manual send package (have code in HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); that must not be re-applied.
|
||||
if (HasRootAura())
|
||||
if (IsImmobilizedState())
|
||||
{
|
||||
WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10);
|
||||
data2 << GetPackGUID();
|
||||
data2 << (uint32)2;
|
||||
SendMessageToSet(&data2, true);
|
||||
auto const counter = GetSession()->GetOrderCounter();
|
||||
setCompoundState << uint8(2 + GetPackGUID().size() + 4);
|
||||
setCompoundState << uint16(SMSG_FORCE_MOVE_ROOT);
|
||||
setCompoundState << GetPackGUID();
|
||||
setCompoundState << uint32(counter);
|
||||
GetSession()->IncrementOrderCounter();
|
||||
}
|
||||
|
||||
if (HasAuraType(SPELL_AURA_FEATHER_FALL))
|
||||
{
|
||||
auto const counter = GetSession()->GetOrderCounter();
|
||||
setCompoundState << uint8(2 + GetPackGUID().size() + 4);
|
||||
setCompoundState << uint16(SMSG_MOVE_FEATHER_FALL);
|
||||
setCompoundState << GetPackGUID();
|
||||
setCompoundState << uint32(counter);
|
||||
GetSession()->IncrementOrderCounter();
|
||||
}
|
||||
|
||||
if (HasAuraType(SPELL_AURA_WATER_WALK))
|
||||
{
|
||||
auto const counter = GetSession()->GetOrderCounter();
|
||||
setCompoundState << uint8(2 + GetPackGUID().size() + 4);
|
||||
setCompoundState << uint16(SMSG_MOVE_WATER_WALK);
|
||||
setCompoundState << GetPackGUID();
|
||||
setCompoundState << uint32(counter);
|
||||
GetSession()->IncrementOrderCounter();
|
||||
}
|
||||
|
||||
if (HasAuraType(SPELL_AURA_HOVER))
|
||||
{
|
||||
auto const counter = GetSession()->GetOrderCounter();
|
||||
setCompoundState << uint8(2 + GetPackGUID().size() + 4);
|
||||
setCompoundState << uint16(SMSG_MOVE_SET_HOVER);
|
||||
setCompoundState << GetPackGUID();
|
||||
setCompoundState << uint32(counter);
|
||||
GetSession()->IncrementOrderCounter();
|
||||
}
|
||||
|
||||
// TODO: Pending mount protocol
|
||||
|
||||
if (setCompoundState.size() > 4)
|
||||
{
|
||||
setCompoundState.put<uint32>(0, setCompoundState.size() - 4);
|
||||
SendDirectMessage(&setCompoundState);
|
||||
}
|
||||
|
||||
SendEnchantmentDurations(); // must be after add to map
|
||||
@@ -15932,8 +15978,9 @@ bool Player::SetDisableGravity(bool disable, bool packetOnly /*= false*/, bool /
|
||||
|
||||
WorldPacket data(disable ? SMSG_MOVE_GRAVITY_DISABLE : SMSG_MOVE_GRAVITY_ENABLE, 12);
|
||||
data << GetPackGUID();
|
||||
data << uint32(0); //! movement counter
|
||||
data << GetSession()->GetOrderCounter(); // movement counter
|
||||
SendDirectMessage(&data);
|
||||
GetSession()->IncrementOrderCounter();
|
||||
|
||||
data.Initialize(MSG_MOVE_GRAVITY_CHNG, 64);
|
||||
data << GetPackGUID();
|
||||
@@ -15942,91 +15989,6 @@ bool Player::SetDisableGravity(bool disable, bool packetOnly /*= false*/, bool /
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::SetCanFly(bool apply, bool packetOnly /*= false*/)
|
||||
{
|
||||
sScriptMgr->AnticheatSetCanFlybyServer(this, apply);
|
||||
|
||||
if (!packetOnly && !Unit::SetCanFly(apply))
|
||||
return false;
|
||||
|
||||
if (!apply)
|
||||
SetFallInformation(GameTime::GetGameTime().count(), GetPositionZ());
|
||||
|
||||
WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12);
|
||||
data << GetPackGUID();
|
||||
data << uint32(0); //! movement counter
|
||||
SendDirectMessage(&data);
|
||||
|
||||
data.Initialize(MSG_MOVE_UPDATE_CAN_FLY, 64);
|
||||
data << GetPackGUID();
|
||||
BuildMovementPacket(&data);
|
||||
SendMessageToSet(&data, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::SetHover(bool apply, bool packetOnly /*= false*/, bool /*updateAnimationTier = true*/)
|
||||
{
|
||||
// moved inside, flag can be removed on landing and wont send appropriate packet to client when aura is removed
|
||||
if (!packetOnly /* && !Unit::SetHover(apply)*/)
|
||||
{
|
||||
Unit::SetHover(apply);
|
||||
// return false;
|
||||
}
|
||||
|
||||
WorldPacket data(apply ? SMSG_MOVE_SET_HOVER : SMSG_MOVE_UNSET_HOVER, 12);
|
||||
data << GetPackGUID();
|
||||
data << uint32(0); //! movement counter
|
||||
SendDirectMessage(&data);
|
||||
|
||||
data.Initialize(MSG_MOVE_HOVER, 64);
|
||||
data << GetPackGUID();
|
||||
BuildMovementPacket(&data);
|
||||
SendMessageToSet(&data, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::SetWaterWalking(bool apply, bool packetOnly /*= false*/)
|
||||
{
|
||||
// moved inside, flag can be removed on landing and wont send appropriate packet to client when aura is removed
|
||||
if (!packetOnly /* && !Unit::SetWaterWalking(apply)*/)
|
||||
{
|
||||
Unit::SetWaterWalking(apply);
|
||||
// return false;
|
||||
}
|
||||
|
||||
WorldPacket data(apply ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK, 12);
|
||||
data << GetPackGUID();
|
||||
data << uint32(0); //! movement counter
|
||||
SendDirectMessage(&data);
|
||||
|
||||
data.Initialize(MSG_MOVE_WATER_WALK, 64);
|
||||
data << GetPackGUID();
|
||||
BuildMovementPacket(&data);
|
||||
SendMessageToSet(&data, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::SetFeatherFall(bool apply, bool packetOnly /*= false*/)
|
||||
{
|
||||
// Xinef: moved inside, flag can be removed on landing and wont send appropriate packet to client when aura is removed
|
||||
if (!packetOnly/* && !Unit::SetFeatherFall(apply)*/)
|
||||
{
|
||||
Unit::SetFeatherFall(apply);
|
||||
//return false;
|
||||
}
|
||||
|
||||
WorldPacket data(apply ? SMSG_MOVE_FEATHER_FALL : SMSG_MOVE_NORMAL_FALL, 12);
|
||||
data << GetPackGUID();
|
||||
data << uint32(0); //! movement counter
|
||||
SendDirectMessage(&data);
|
||||
|
||||
data.Initialize(MSG_MOVE_FEATHER_FALL, 64);
|
||||
data << GetPackGUID();
|
||||
BuildMovementPacket(&data);
|
||||
SendMessageToSet(&data, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild* Player::GetGuild() const
|
||||
{
|
||||
uint32 guildId = GetGuildId();
|
||||
|
||||
Reference in New Issue
Block a user