From f094d78df13fb0f6400cccce4d8c02c1b76667b6 Mon Sep 17 00:00:00 2001 From: arcattack Date: Wed, 15 Jul 2026 07:38:33 -0500 Subject: [PATCH] MP: restore peer turn-step on the body channel -- arm turn state 4 from replicated turn (task #50) The body-channel swap (96a896a) fixed the stop-slide but regressed turn-in-place to a rotating statue: the body Standing case only enters walk/reverse/stand, never the turn clip (state 4). On the master that arming comes from the LEG Standing case cross-arming both channels (mech2.cpp:937) -- which the peer no longer runs. FIX (peer branch): arm/exit the body turn state from the replicated turn (replMppr->turnDemand, already derived from the replicated yaw rate with hysteresis): standing + turning -> SetBodyAnimation(4) so the body case 4 advances the trn clip (peer STEPS through the pivot); turn stops -> back to Standing. Walk/reverse transitions still own their own exits. Verified autonomous (forced spin): peer body channel holds state 4, trn clip advances (frmAvg 0.2-0.3, frmMax 1-2), back-steps 0, no crash. Co-Authored-By: Claude Opus 4.8 (1M context) --- game/reconstructed/mech4.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/game/reconstructed/mech4.cpp b/game/reconstructed/mech4.cpp index d8b8ef2..7b74199 100644 --- a/game/reconstructed/mech4.cpp +++ b/game/reconstructed/mech4.cpp @@ -2148,6 +2148,24 @@ void // master's exact clips. Swapping the peer to the body channel RESTORES the // original single-channel design (no new netcode). BT_PEER_LEGCH=1 = old. static const int s_peerLegCh = getenv("BT_PEER_LEGCH") ? 1 : 0; + // TURN-STEP ARMING for the body channel: the body Standing case only enters + // walk/reverse/stand -- it never arms the turn-in-place clip (state 4); on the + // master that arming comes from the LEG Standing case cross-arming both + // channels (mech2.cpp:937 note), which the peer no longer runs. Arm/exit the + // body turn state here from the replicated turn (replMppr->turnDemand, from the + // replicated yaw rate + hysteresis above): standing + turning -> state 4 (body + // case 4 then advances the trn clip -> the peer STEPS through the pivot); turn + // stops -> back to Standing. Walk/reverse transitions still own their exits. + if (!s_peerLegCh) + { + const int bs = (int)bodyStateAlarm.GetLevel(); + const bool turning = (replMppr->turnDemand > 0.05f + || replMppr->turnDemand < -0.05f); + if (turning && bs == 0) // standing + turning -> enter turn + SetBodyAnimation(4); + else if (!turning && bs == 4) // turn stopped -> back to stand + SetBodyAnimation(0); + } const Scalar replLegAdv = s_peerLegCh ? AdvanceLegAnimation(dt) // old: re-derived leg SM : AdvanceBodyAnimation(dt, 1); // authentic: body channel, mj=1 poses skeleton