Skip to content

Commit 4b86057

Browse files
committed
Core/Units: Fix movement status altering packets being sent to wrong units
(cherry picked from commit 6fd28bda9789ede9f3fe81e97a88de9820880a67)
1 parent 524e041 commit 4b86057

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11390,22 +11390,29 @@ void Unit::SetRooted(bool apply)
1139011390
else
1139111391
RemoveUnitMovementFlag(MOVEMENTFLAG_ROOT);
1139211392

11393-
static OpcodeServer const rootOpcodeTable[2][2] =
11393+
static OpcodeServer const rootOpcodeTable[2][3] =
1139411394
{
11395-
{ SMSG_SPLINE_MOVE_UNROOT, SMSG_FORCE_MOVE_UNROOT },
11396-
{ SMSG_SPLINE_MOVE_ROOT, SMSG_FORCE_MOVE_ROOT }
11395+
{ SMSG_SPLINE_MOVE_UNROOT, SMSG_FORCE_MOVE_UNROOT, MSG_MOVE_UNROOT },
11396+
{ SMSG_SPLINE_MOVE_ROOT, SMSG_FORCE_MOVE_ROOT, MSG_MOVE_ROOT }
1139711397
};
1139811398

11399-
if (GetTypeId() == TYPEID_PLAYER)
11399+
if (IsMovedByClient())
1140011400
{
11401+
Player* playerMover = GetGameClientMovingMe()->GetBasePlayer();
11402+
1140111403
WorldPacket data(rootOpcodeTable[apply][1], 10);
1140211404
data << GetPackGUID();
1140311405
data << GetMovementCounterAndInc();
11404-
SendMessageToSet(&data, true);
11406+
playerMover->SendDirectMessage(&data);
11407+
11408+
data.Initialize(rootOpcodeTable[apply][2], 64);
11409+
data << GetPackGUID();
11410+
BuildMovementPacket(&data);
11411+
SendMessageToSet(&data, playerMover);
1140511412
}
1140611413
else
1140711414
{
11408-
WorldPacket data(rootOpcodeTable[apply][0], 8);
11415+
WorldPacket data(rootOpcodeTable[apply][0], 9);
1140911416
data << GetPackGUID();
1141011417
SendMessageToSet(&data, true);
1141111418
}
@@ -13300,8 +13307,10 @@ bool Unit::SetDisableGravity(bool disable, bool updateAnimTier /*= true*/)
1330013307
{ SMSG_SPLINE_MOVE_GRAVITY_DISABLE, SMSG_MOVE_GRAVITY_DISABLE }
1330113308
};
1330213309

13303-
if (Player* playerMover = ToPlayer())
13310+
if (IsMovedByClient())
1330413311
{
13312+
Player* playerMover = GetGameClientMovingMe()->GetBasePlayer();
13313+
1330513314
WorldPacket data(gravityOpcodeTable[disable][1], 12);
1330613315
data << GetPackGUID();
1330713316
data << uint32(0); //! movement counter
@@ -13310,7 +13319,7 @@ bool Unit::SetDisableGravity(bool disable, bool updateAnimTier /*= true*/)
1331013319
data.Initialize(MSG_MOVE_GRAVITY_CHNG, 64);
1331113320
data << GetPackGUID();
1331213321
BuildMovementPacket(&data);
13313-
SendMessageToSet(&data, false);
13322+
SendMessageToSet(&data, playerMover);
1331413323
}
1331513324
else
1331613325
{
@@ -13392,8 +13401,10 @@ bool Unit::SetCanFly(bool enable, bool packetOnly /*= false */)
1339213401
if (!enable && GetTypeId() == TYPEID_PLAYER)
1339313402
ToPlayer()->SetFallInformation(0, GetPositionZ());
1339413403

13395-
if (Player* playerMover = ToPlayer())
13404+
if (IsMovedByClient())
1339613405
{
13406+
Player* playerMover = GetGameClientMovingMe()->GetBasePlayer();
13407+
1339713408
WorldPacket data(flyOpcodeTable[enable][1], 12);
1339813409
data << GetPackGUID();
1339913410
data << uint32(0); //! movement counter
@@ -13402,7 +13413,7 @@ bool Unit::SetCanFly(bool enable, bool packetOnly /*= false */)
1340213413
data.Initialize(MSG_MOVE_UPDATE_CAN_FLY, 64);
1340313414
data << GetPackGUID();
1340413415
BuildMovementPacket(&data);
13405-
SendMessageToSet(&data, false);
13416+
SendMessageToSet(&data, playerMover);
1340613417
}
1340713418
else
1340813419
{
@@ -13430,17 +13441,19 @@ bool Unit::SetWaterWalking(bool enable)
1343013441
{ SMSG_SPLINE_MOVE_WATER_WALK, SMSG_MOVE_WATER_WALK }
1343113442
};
1343213443

13433-
if (Player* playerMover = ToPlayer())
13444+
if (IsMovedByClient())
1343413445
{
13446+
Player* playerMover = GetGameClientMovingMe()->GetBasePlayer();
13447+
1343513448
WorldPacket data(waterWalkingOpcodeTable[enable][1], 12);
1343613449
data << GetPackGUID();
1343713450
data << uint32(0); //! movement counter
13438-
playerMover->SendDirectMessage(&data);
13451+
GetGameClientMovingMe()->GetBasePlayer()->SendDirectMessage(&data);
1343913452

1344013453
data.Initialize(MSG_MOVE_WATER_WALK, 64);
1344113454
data << GetPackGUID();
1344213455
BuildMovementPacket(&data);
13443-
SendMessageToSet(&data, false);
13456+
SendMessageToSet(&data, playerMover);
1344413457
}
1344513458
else
1344613459
{
@@ -13468,8 +13481,10 @@ bool Unit::SetFeatherFall(bool enable)
1346813481
{ SMSG_SPLINE_MOVE_FEATHER_FALL, SMSG_MOVE_FEATHER_FALL }
1346913482
};
1347013483

13471-
if (Player* playerMover = ToPlayer())
13484+
if (IsMovedByClient())
1347213485
{
13486+
Player* playerMover = GetGameClientMovingMe()->GetBasePlayer();
13487+
1347313488
WorldPacket data(featherFallOpcodeTable[enable][1], 12);
1347413489
data << GetPackGUID();
1347513490
data << uint32(0); //! movement counter
@@ -13478,7 +13493,7 @@ bool Unit::SetFeatherFall(bool enable)
1347813493
data.Initialize(MSG_MOVE_FEATHER_FALL, 64);
1347913494
data << GetPackGUID();
1348013495
BuildMovementPacket(&data);
13481-
SendMessageToSet(&data, false);
13496+
SendMessageToSet(&data, playerMover);
1348213497
}
1348313498
else
1348413499
{
@@ -13522,8 +13537,10 @@ bool Unit::SetHover(bool enable, bool updateAnimTier /*= true*/)
1352213537
{ SMSG_SPLINE_MOVE_SET_HOVER, SMSG_MOVE_SET_HOVER }
1352313538
};
1352413539

13525-
if (Player* playerMover = ToPlayer())
13540+
if (IsMovedByClient())
1352613541
{
13542+
Player* playerMover = GetGameClientMovingMe()->GetBasePlayer();
13543+
1352713544
WorldPacket data(hoverOpcodeTable[enable][1], 12);
1352813545
data << GetPackGUID();
1352913546
data << uint32(0); //! movement counter
@@ -13532,7 +13549,7 @@ bool Unit::SetHover(bool enable, bool updateAnimTier /*= true*/)
1353213549
data.Initialize(MSG_MOVE_HOVER, 64);
1353313550
data << GetPackGUID();
1353413551
BuildMovementPacket(&data);
13535-
SendMessageToSet(&data, false);
13552+
SendMessageToSet(&data, playerMover);
1353613553
}
1353713554
else
1353813555
{

0 commit comments

Comments
 (0)