fix: MSG_MOVE_START_DESCEND never set DESCENDING flag

Only ASCENDING was cleared — the DESCENDING flag was never toggled,
so outgoing movement packets during flight descent had incorrect flags.
Also clears DESCENDING on start-ascend and stop-ascend for symmetry.

Replaces static heartbeat log counter with member variable (was shared
across instances and not thread-safe) and demotes to LOG_DEBUG.
This commit is contained in:
Kelsi 2026-03-29 18:28:49 -07:00
parent b0aa4445a0
commit 4e0e234ae9
2 changed files with 11 additions and 5 deletions

View file

@ -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;

View file

@ -457,12 +457,18 @@ void MovementHandler::sendMovement(Opcode opcode) {
break;
case Opcode::MSG_MOVE_START_ASCEND:
movementInfo.flags |= static_cast<uint32_t>(MovementFlags::ASCENDING);
movementInfo.flags &= ~static_cast<uint32_t>(MovementFlags::DESCENDING);
break;
case Opcode::MSG_MOVE_STOP_ASCEND:
movementInfo.flags &= ~static_cast<uint32_t>(MovementFlags::ASCENDING);
movementInfo.flags &= ~static_cast<uint32_t>(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<uint32_t>(MovementFlags::ASCENDING);
movementInfo.flags |= static_cast<uint32_t>(MovementFlags::DESCENDING);
break;
default:
break;
@ -597,10 +603,9 @@ 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,
// 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, ")");
}