diff --git a/include/game/movement_handler.hpp b/include/game/movement_handler.hpp index 25398068..fbaca1ca 100644 --- a/include/game/movement_handler.hpp +++ b/include/game/movement_handler.hpp @@ -211,6 +211,7 @@ private: uint32_t fallStartMs_ = 0; // Heartbeat timing + int heartbeatLogCount_ = 0; // periodic position audit counter float timeSinceLastMoveHeartbeat_ = 0.0f; float moveHeartbeatInterval_ = 0.5f; uint32_t lastHeartbeatSendTimeMs_ = 0; diff --git a/src/game/movement_handler.cpp b/src/game/movement_handler.cpp index 0e895742..eb5b6210 100644 --- a/src/game/movement_handler.cpp +++ b/src/game/movement_handler.cpp @@ -457,12 +457,18 @@ void MovementHandler::sendMovement(Opcode opcode) { break; case Opcode::MSG_MOVE_START_ASCEND: movementInfo.flags |= static_cast(MovementFlags::ASCENDING); + movementInfo.flags &= ~static_cast(MovementFlags::DESCENDING); break; case Opcode::MSG_MOVE_STOP_ASCEND: movementInfo.flags &= ~static_cast(MovementFlags::ASCENDING); + movementInfo.flags &= ~static_cast(MovementFlags::DESCENDING); break; case Opcode::MSG_MOVE_START_DESCEND: + // Must set DESCENDING so outgoing movement packets carry the correct + // flag during flight descent. Only clearing ASCENDING left the flag + // field ambiguous (neither ascending nor descending). movementInfo.flags &= ~static_cast(MovementFlags::ASCENDING); + movementInfo.flags |= static_cast(MovementFlags::DESCENDING); break; default: break; @@ -597,11 +603,10 @@ void MovementHandler::sendMovement(Opcode opcode) { wireInfo.y = serverPos.y; wireInfo.z = serverPos.z; - // Log outgoing position periodically to detect coordinate bugs - static int heartbeatLogCounter = 0; - if (opcode == Opcode::MSG_MOVE_HEARTBEAT && ++heartbeatLogCounter % 30 == 0) { - LOG_WARNING("HEARTBEAT pos canonical=(", movementInfo.x, ",", movementInfo.y, ",", movementInfo.z, - ") wire=(", wireInfo.x, ",", wireInfo.y, ",", wireInfo.z, ")"); + // Periodic position audit — DEBUG to avoid flooding production logs. + if (opcode == Opcode::MSG_MOVE_HEARTBEAT && ++heartbeatLogCount_ % 30 == 0) { + LOG_DEBUG("HEARTBEAT pos canonical=(", movementInfo.x, ",", movementInfo.y, ",", movementInfo.z, + ") wire=(", wireInfo.x, ",", wireInfo.y, ",", wireInfo.z, ")"); } wireInfo.orientation = core::coords::canonicalToServerYaw(wireInfo.orientation);