fix: speed ACK sent before validation caused client/server desync

If the server sent a NaN or out-of-range speed, the client echoed it
back in the ACK (confirming it to the server) but then rejected it
locally. This left the server believing the client accepted the speed
while the client used the old value — a desync only fixable by relog.
Moved validation before the ACK so bad speeds are rejected outright.
This commit is contained in:
Kelsi 2026-03-29 18:53:16 -07:00
parent 3f37ffcea3
commit 1a6960e3f9

View file

@ -787,6 +787,13 @@ void MovementHandler::handleForceSpeedChange(network::Packet& packet, const char
if (guid != owner_.playerGuid) return;
// Validate BEFORE sending ACK — if we echo a bad speed back to the server
// but don't apply it locally, the client and server desync on movement speed.
if (std::isnan(newSpeed) || newSpeed < 0.1f || newSpeed > 100.0f) {
LOG_WARNING("Ignoring invalid ", name, " speed: ", newSpeed);
return;
}
if (owner_.socket) {
network::Packet ack(wireOpcode(ackOpcode));
const bool legacyGuidAck =
@ -825,11 +832,6 @@ void MovementHandler::handleForceSpeedChange(network::Packet& packet, const char
owner_.socket->send(ack);
}
if (std::isnan(newSpeed) || newSpeed < 0.1f || newSpeed > 100.0f) {
LOG_WARNING("Ignoring invalid ", name, " speed: ", newSpeed);
return;
}
if (speedStorage) *speedStorage = newSpeed;
}