fix(Core/Movement): Add safeguards against root freezes (#23117)

This commit is contained in:
killerwife
2025-10-05 19:45:07 +02:00
committed by GitHub
parent 2afcd037c7
commit 0767b2edf5
4 changed files with 17 additions and 9 deletions

View File

@@ -1644,6 +1644,7 @@ public:
[[nodiscard]] virtual bool CanFly() const = 0;
[[nodiscard]] bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); }
[[nodiscard]] bool IsFalling() const;
[[nodiscard]] bool IsRooted() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_ROOT); }
[[nodiscard]] float GetHoverHeight() const { return IsHovering() ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f; }

View File

@@ -575,6 +575,12 @@ bool WorldSession::VerifyMovementInfo(MovementInfo const& movementInfo, Player*
return false;
}
}
// rooted mover sent packet without root or moving AND root - ignore, due to client crash possibility
if (opcode != CMSG_FORCE_MOVE_UNROOT_ACK)
if (mover->IsRooted() && (!movementInfo.HasMovementFlag(MOVEMENTFLAG_ROOT) || movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_MOVING)))
return false;
return true;
}

View File

@@ -23,6 +23,7 @@
#include "Unit.h"
#include "Vehicle.h"
#include "WorldPacket.h"
#include "Log.h"
namespace Movement
{
@@ -103,7 +104,13 @@ namespace Movement
bool isOrientationOnly = args.path.size() == 2 && args.path[0] == args.path[1];
if ((moveFlags & MOVEMENTFLAG_ROOT) || isOrientationOnly)
if (moveFlags & MOVEMENTFLAG_ROOT) // This case should essentially never occur - hence the trace logging - hints to issues elsewhere
{
LOG_TRACE("movement", "Invalid movement during root. Entry: {} IsImmobilized {}, moveflags {}", unit->GetEntry(), unit->IsImmobilizedState() ? "true" : "false", moveFlags);
moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;
}
if (isOrientationOnly)
moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;
if (!args.HasVelocity)

View File

@@ -92,24 +92,18 @@ public:
if (!target)
target = handler->GetSession()->GetPlayer();
WorldPacket data(12);
bool canFly = false;
if (enable.has_value())
{
data.SetOpcode(*enable ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY);
canFly = *enable;
target->SetCanFly(canFly);
}
else
{
canFly = handler->GetSession()->GetPlayer()->CanFly();
data.SetOpcode(canFly ? SMSG_MOVE_UNSET_CAN_FLY : SMSG_MOVE_SET_CAN_FLY);
canFly = !canFly;
target->SetCanFly(!canFly);
}
data << target->GetPackGUID();
data << uint32(0); // unknown
target->SendMessageToSet(&data, true);
handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), canFly ? "on" : "off");
return true;
}