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
+1
View File
@@ -1644,6 +1644,7 @@ public:
[[nodiscard]] virtual bool CanFly() const = 0; [[nodiscard]] virtual bool CanFly() const = 0;
[[nodiscard]] bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); } [[nodiscard]] bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); }
[[nodiscard]] bool IsFalling() const; [[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; } [[nodiscard]] float GetHoverHeight() const { return IsHovering() ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f; }
@@ -575,6 +575,12 @@ bool WorldSession::VerifyMovementInfo(MovementInfo const& movementInfo, Player*
return false; 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; return true;
} }
@@ -23,6 +23,7 @@
#include "Unit.h" #include "Unit.h"
#include "Vehicle.h" #include "Vehicle.h"
#include "WorldPacket.h" #include "WorldPacket.h"
#include "Log.h"
namespace Movement namespace Movement
{ {
@@ -103,7 +104,13 @@ namespace Movement
bool isOrientationOnly = args.path.size() == 2 && args.path[0] == args.path[1]; 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; moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;
if (!args.HasVelocity) if (!args.HasVelocity)
+2 -8
View File
@@ -92,24 +92,18 @@ public:
if (!target) if (!target)
target = handler->GetSession()->GetPlayer(); target = handler->GetSession()->GetPlayer();
WorldPacket data(12);
bool canFly = false; bool canFly = false;
if (enable.has_value()) if (enable.has_value())
{ {
data.SetOpcode(*enable ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY);
canFly = *enable; canFly = *enable;
target->SetCanFly(canFly);
} }
else else
{ {
canFly = handler->GetSession()->GetPlayer()->CanFly(); canFly = handler->GetSession()->GetPlayer()->CanFly();
data.SetOpcode(canFly ? SMSG_MOVE_UNSET_CAN_FLY : SMSG_MOVE_SET_CAN_FLY); target->SetCanFly(!canFly);
canFly = !canFly;
} }
data << target->GetPackGUID();
data << uint32(0); // unknown
target->SendMessageToSet(&data, true);
handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), canFly ? "on" : "off"); handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), canFly ? "on" : "off");
return true; return true;
} }