From 9291637977ef85415fdd85f3e786212dd0c2f521 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 10 Mar 2026 12:37:53 -0700 Subject: [PATCH] movement: fix jumpXYSpeed to be 0 when jumping in place jumpXYSpeed should reflect actual horizontal movement at jump time: - non-zero (run/walk speed) only when movement flags indicate forward/ backward/strafe movement - zero when jumping straight up without horizontal movement This prevents the server from thinking the player launched with full run speed when they jumped in place, which could affect position prediction. --- src/game/game_handler.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 046bdb02..ef41b16e 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -7248,9 +7248,19 @@ void GameHandler::sendMovement(Opcode opcode) { const float facingRad = movementInfo.orientation; movementInfo.jumpCosAngle = std::cos(facingRad); movementInfo.jumpSinAngle = std::sin(facingRad); - // Use server run speed as the horizontal speed at jump time. - const bool isWalking = (movementInfo.flags & static_cast(MovementFlags::WALKING)) != 0; - movementInfo.jumpXYSpeed = isWalking ? 2.5f : (serverRunSpeed_ > 0.0f ? serverRunSpeed_ : 7.0f); + // Horizontal speed: only non-zero when actually moving at jump time. + const uint32_t horizFlags = + static_cast(MovementFlags::FORWARD) | + static_cast(MovementFlags::BACKWARD) | + static_cast(MovementFlags::STRAFE_LEFT) | + static_cast(MovementFlags::STRAFE_RIGHT); + const bool movingHoriz = (movementInfo.flags & horizFlags) != 0; + if (movingHoriz) { + const bool isWalking = (movementInfo.flags & static_cast(MovementFlags::WALKING)) != 0; + movementInfo.jumpXYSpeed = isWalking ? 2.5f : (serverRunSpeed_ > 0.0f ? serverRunSpeed_ : 7.0f); + } else { + movementInfo.jumpXYSpeed = 0.0f; + } } break; case Opcode::MSG_MOVE_START_TURN_LEFT: