commit 6a1e4d03b06548294daa57388c81d6f33b741731
parent 3ff33b75b8400cd028afd3c7809511e8a1c27621
Author: anon <anon@example.com>
Date: Mon, 26 Oct 2026 14:33:38 +0000
Share native movement mode admission across controls and flight effects
Reject seated locomotion, swimming strafe starts and walk/run changes, and
repeated walk/run requests before they change cached controls or component
history. Preserve supported packets' native pose, follow and relay ordering.
Add regression coverage for seated forward held through explicit standing,
water entry and exit with both preferred modes, rejected controls, admitted
turning and mode changes, and common pose/observer processing. Update TODO
and movement evidence, retaining the steep-bank water classification follow-up.
Validation: all 1315 server roots / 14321 results; 54 focused roots / 126
results; 144 race roots / 409 results; data tests and go vet. Four new
regression roots fail against the previous production implementation.
Paired headed GPU WASM tests verify ordinary seated, ground and water
inputs, preferred run mode and a late observer without page errors. The
held-forward/stand case eliminates 1.60m of hidden server motion. Cleaned
owned fixtures and retained one HTTPS preview with the verified build.
Diffstat:
5 files changed, 271 insertions(+), 14 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -1290,7 +1290,12 @@ disconnect retention and succession policy still need period corroboration.
mode7 although the helper accepts it). Extend the verified jump-to-flight
overlap to longer falls and other effects. Test water rejection followed by
leaving water and late observer initialization,
- and curved-flight cadence with synchronized samples. A concurrent race-test
+ and curved-flight cadence with synchronized samples. Retain the live steep-bank
+ boundary trace: after stopping near489.60,87.73, native owner mode3 differs
+ from observer mode4 at the compact packet position489.5,87.625. Check water
+ classification near this threshold without conflating it with rejected inputs.
+ Captures: `local/player-movement-mode/runtime/pair-fixed-shore-*.json`.
+ A concurrent race-test
run measured a transient 0.846 m difference with up to 57 ms between native and
server samples; settled forward/reverse errors were below 0.07 m. Keep timing
bounds explicit instead of claiming exact trajectory equivalence.
@@ -1301,12 +1306,19 @@ disconnect retention and succession policy still need period corroboration.
state/observer/persistence and native transport tests pass, alongside paired
WASM flight, live removal with the same persisted item, and ground/posture
checks. See [incoming actions](docs/player-movement.md#incoming-movement-actions).
-- [ ] Complete native movement mode admission and callback coverage. Audit
- swimming/sitting gates, repeated walk/run requests, and walk/run while flying
- against helper predicate36044640 and the complete builder/callback table.
- In the native seated fixture, W emits movement1/2 but both helpers stay idle
- in mode8; test holding W while explicitly standing before its release so
- rejected input cannot leave cached forward motion on the server.
+- [x] Share native primary-mode admission between movement controls and authored
+ flight effects. Reject seated locomotion, swimming strafe starts and walk/run
+ changes, and repeated walk/run requests before changing cached controls or
+ component history. Preserve common pose/follow processing and observer relay
+ for supported packets rejected by the physical helper. Verify holding W while
+ explicitly standing before release, water exit with both preferred modes,
+ and ordinary admitted turning/walk/run. See
+ [physical admission](docs/player-movement.md#physical-movement-admission).
+- [ ] Complete native movement callbacks and posture admission. Check sit28's
+ forward/strafe/turn state gate, stand33's Features4 handling, and walk/run
+ while flying against the complete builder/callback table. Walk and run have
+ different orientation restoration when leaving flight. Complete the frozen
+ and sneak state lifecycles before claiming the whole helper state machine.
Trace the complete sneak flow before admitting movement26/32; ordinary
sit/stand86/87 uses helper28/33 instead. Crawl25 is only bound to an exported
API, and no ordinary elevation15/16 producer is established. The helper's
diff --git a/docs/player-movement.md b/docs/player-movement.md
@@ -83,8 +83,8 @@ state gates and cached-control quirks. No ordinary keyboard producer for them
is established. Camera Up/Down callbacks do not establish actor elevation input.
Backspace selects run/walk through a special-action entry whose availability
also matters. In the captured flying client it emits no22/23 and leaves flight
-unchanged; ordinary ground Backspace does toggle2/3. Full physical mode
-admission and callbacks remain a separate TODO.
+unchanged; ordinary ground Backspace does toggle2/3. Physical mode admission
+is shared below; complete mode callbacks remain a separate TODO.
`local/player-flight-input/research/helpers/` retains117 complete bodies, all35
builder entries,1,024 predicate cases and29 callback bindings. The independent
@@ -104,6 +104,48 @@ to inventory slot64 and is present there in SQLite. Source/packet/state checks
are retained under `local/player-flight-input/`; cleanup removes three owned
visitors and the fixture, preserving unrelated rows and the single LAN preview.
+## Physical movement admission
+
+The controller and authored flight transitions share the native primary-mode
+predicate, `client/game/kkr.dll/lifted-0022.c` / `sub_36044640`. It runs before
+the transition's component-state checks and
+before copying old strafe state into elevation state. Rejected controls cannot
+change forward/strafe caches, jump state, the preferred walking/running mode or
+that component history. Sitting admits turning but rejects locomotion; swimming
+rejects strafe starts and walk/run changes. Already-walking22 and already-running23
+are rejected, too. This predicate does not expand the supported incoming actions.
+
+Supported movement packets still place their reported pose and cancel follow
+before helper admission, and still reach observers. Native activation has that
+same ordering. Rejecting the whole packet would incorrectly discard those common
+effects. Unknown and equipment-only incoming actions remain rejected earlier by
+the separate request support check.
+
+The paired WASM baseline demonstrates why caching a rejected input matters:
+holding W while seated sends1, then explicitly standing with X restores mode2.
+Both native helpers remain idle, while the previous Go controller starts moving
+until W release reports the original pose. Regression tests cover that sequence,
+water entry/rejected controls/exit with both preferred modes, rejected stop and
+jump controls, repeated walk/run history, admitted turning and ordinary mode
+changes, and preserved pose/follow/relay ordering.
+
+All 1,315 server roots (14,321 results), 54 focused roots (126 results), 144 race
+roots (409 results), data tests and go vet pass. Four new regression roots fail
+against the previous implementation. Paired GPU WASM captures measure 1.60m
+of hidden server movement before the fix and no displacement after it. Ordinary
+water keys emit 5/6, 7/8 and 22 while both native helpers reject those transitions;
+preferred mode 3 remains unchanged. A reloaded observer receives idle swimming.
+Both clients report no page errors. The steep-bank trace separately records a
+native owner/observer mode difference at rounded packet coordinates; water-edge
+classification remains in TODO and is not claimed as exact trajectory parity.
+
+The predicate retains the source's eight-mode rules. Existing server lifecycle
+support remains walking/running, swimming, flying and sitting; copying the
+predicate does not implement frozen/sneak transitions. Sit/stand builder gates
+and flight-to-walk/run callbacks remain explicit TODOs. The verified source
+tables remain under `local/player-flight-input/research/helpers/`; this
+milestone's tests and paired traces are under `local/player-movement-mode/`.
+
## Flight transitions and facing
The shared OnWear iterator consumes authored function 53138 in order with shape
diff --git a/server/player_flight.go b/server/player_flight.go
@@ -5,9 +5,11 @@ import "math"
func (player *character) changeFlight(remove bool) {
movement := &player.movement
movement.prepare(player, movement.updatedAt)
- // KKR PlayerVehicle Submit(27/35) rejects inactive, swimming and sitting modes.
- mode := movement.components[0]
- if mode == 1 || mode == 4 || mode == 8 {
+ action := uint32(27)
+ if remove {
+ action = 35
+ }
+ if !movement.admits(action) {
return
}
movement.components[5] = movement.components[3]
diff --git a/server/player_movement.go b/server/player_movement.go
@@ -314,8 +314,36 @@ func (player *character) advanceMovement(now time.Time, target [3]float32) bool
return heightLimited
}
+func (movement *playerMovement) admits(action uint32) bool {
+ // KKR helper predicate36044640 runs before transition construction.
+ // This is physical admission; incoming packets have a separate support check.
+ switch movement.components[0] {
+ case 1:
+ return action == 9 || action == 10 || action == 11 || action == 12 || action == 14 || action == 34
+ case 2:
+ return action != 22 && action != 33 && (action != 28 || movement.components[1] != 3)
+ case 3:
+ return action != 23 && (action != 28 || movement.components[1] != 3)
+ case 4:
+ switch action {
+ case 5, 7, 13, 22, 23, 26, 27, 28, 29, 32, 35:
+ return false
+ }
+ case 5:
+ return action != 13
+ case 7:
+ return action != 26 && action != 28
+ case 8:
+ return action == 9 || action == 10 || action == 11 || action == 12 || action == 24 || action == 26 || action == 33
+ }
+ return true
+}
+
func (movement *playerMovement) action(player *character, action uint32) bool {
movement.prepare(player, movement.updatedAt)
+ if !movement.admits(action) {
+ return false
+ }
old := movement.components
accepted := true
switch action {
@@ -400,13 +428,13 @@ func (movement *playerMovement) action(player *character, action uint32) bool {
movement.components[7], movement.components[8] = 1, 0
}
case 13:
- accepted = old[0] != 1 && old[0] != 4 && old[0] != 5 && old[0] != 8 && (old[9] != 4 || old[0] == 7)
+ accepted = old[9] != 4 || old[0] == 7
if accepted {
movement.components[9] = 4
player.jump()
}
case 14:
- accepted = old[0] != 8 && old[9] == 4
+ accepted = old[9] == 4
if accepted && old[0] != 7 {
movement.components[9] = 1
}
diff --git a/server/player_movement_mode_test.go b/server/player_movement_mode_test.go
@@ -0,0 +1,173 @@
+package main
+
+import (
+ "encoding/binary"
+ "fmt"
+ "testing"
+ "time"
+)
+
+func TestPlayerMovementModeRejectionPreservesControls(t *testing.T) {
+ for _, mode := range []byte{2, 3, 4, 8} {
+ actions := []uint32{22}
+ if mode == 3 {
+ actions = []uint32{23}
+ } else if mode == 4 {
+ actions = []uint32{5, 7, 13, 22, 23}
+ } else if mode == 8 {
+ actions = []uint32{1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 22, 23}
+ }
+ for _, action := range actions {
+ t.Run(fmt.Sprintf("mode%d/action%d", mode, action), func(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.inventory = playerInventory{}
+ player.running, player.sitting = mode == 3, mode == 8
+ player.movement.prepare(player, time.Now())
+ player.movement.deepWater = mode == 4
+ player.movement.components[5] = 5
+ player.movement.components[9] = 4
+ if action == 2 || action == 4 {
+ player.movement.components[1], player.movement.components[2] = 3, byte(action/2)
+ player.movement.forward = 1
+ }
+ if action == 6 || action == 8 {
+ player.movement.components[3], player.movement.components[4] = 3, 4
+ if action == 8 {
+ player.movement.components[4] = 3
+ }
+ player.movement.strafe = 2
+ }
+ before := player.movement
+ before.components[0] = mode
+
+ if err := world.handleMovement(client, playerMovementRequest(player, action)); err != nil {
+ t.Fatal(err)
+ }
+
+ if player.running != (mode == 3) || player.movement.forward != before.forward || player.movement.strafe != before.strafe || player.movement.turn != before.turn || player.movement.vertical != before.vertical || player.movement.components != before.components {
+ t.Fatal("mode rejection changed cached controls or committed component history", before, player.movement, player.running)
+ }
+ })
+ }
+ }
+}
+
+func TestPlayerStandingDoesNotActivateRejectedSeatedForward(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.inventory = playerInventory{}
+ posture := make([]byte, 36)
+ binary.BigEndian.PutUint32(posture[16:20], 86)
+ if err := world.handlePosture(client, posture); err != nil {
+ t.Fatal(err)
+ }
+ position := player.position
+
+ if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil {
+ t.Fatal(err)
+ }
+ binary.BigEndian.PutUint32(posture[16:20], 87)
+ if err := world.handlePosture(client, posture); err != nil {
+ t.Fatal(err)
+ }
+ world.advancePlayerMovement(player.movement.updatedAt.Add(time.Second))
+ standing := player.position
+ if err := world.handleMovement(client, playerMovementRequest(player, 2)); err != nil {
+ t.Fatal(err)
+ }
+ world.advancePlayerMovement(player.movement.updatedAt.Add(time.Second))
+
+ if standing != position || player.position != position || player.sitting || player.movement.forward != 0 || player.movement.components[1] != 1 {
+ t.Fatal("standing activated a forward start rejected while seated", position, standing, player.position, player.movement)
+ }
+}
+
+func TestPlayerSwimmingRejectsControlsBeforeLeavingWater(t *testing.T) {
+ for _, running := range []bool{false, true} {
+ t.Run(fmt.Sprint(running), func(t *testing.T) {
+ world := newPlayerCollisionWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.running = running
+ player.position, player.rotation = [3]float32{100, 8, 25}, [4]float32{0, 0, 0, 1}
+ submerged := *player
+ submerged.position[1] = 6.5
+ if err := world.handleMovement(client, playerMovementRequest(&submerged, 20)); err != nil {
+ t.Fatal(err)
+ }
+ if !player.movement.deepWater {
+ t.Fatal("fixture must enter native deep water", player.position, player.movement)
+ }
+ action := uint32(23)
+ if running {
+ action = 22
+ }
+
+ for _, input := range []uint32{5, 7, action} {
+ if err := world.handleMovement(client, playerMovementRequest(player, input)); err != nil {
+ t.Fatal(err)
+ }
+ }
+ outside := *player
+ outside.position[1] = 8
+ if err := world.handleMovement(client, playerMovementRequest(&outside, 20)); err != nil {
+ t.Fatal(err)
+ }
+ world.advancePlayerMovement(player.movement.updatedAt.Add(100 * time.Millisecond))
+
+ mode := byte(2)
+ if running {
+ mode = 3
+ }
+ if player.running != running || player.movement.deepWater || player.movement.components[0] != mode || player.movement.strafe != 0 || player.movement.components[3] != 1 || player.position[0] != 100 || player.position[2] != 25 {
+ t.Fatal("rejected swimming inputs changed the preferred mode or activated land strafing", player.position, player.movement, player.running)
+ }
+ })
+ }
+}
+
+func TestPlayerRejectedSeatedControlStillPlacesAndRelaysPose(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.inventory, player.sitting = playerInventory{}, true
+ observer := &combatTestConn{}
+ world.characters[2] = &character{id: 2, playfield: player.playfield, health: 100}
+ world.clients[2] = &worldClient{id: 2, ready: true, target: true, conn: observer}
+ player.followTarget = 1000000
+ reported := *player
+ reported.position = [3]float32{2, 14, 4}
+
+ if err := world.handleMovement(client, playerMovementRequest(&reported, 1)); err != nil {
+ t.Fatal(err)
+ }
+
+ if player.position != reported.position || player.followTarget != 0 || player.movement.forward != 0 || len(observer.packets) != 1 || observer.packets[0][29] != 1 {
+ t.Fatal("physical rejection rolled back common native pose/follow processing or relay", player.position, player.followTarget, player.movement, observer.packets)
+ }
+}
+
+func TestPlayerSeatedTurningAndGroundModeChangesRemainAdmitted(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.inventory, player.sitting, player.running = playerInventory{}, true, false
+
+ if err := world.handleMovement(client, playerMovementRequest(player, 9)); err != nil {
+ t.Fatal(err)
+ }
+ turn := player.movement.turn
+ if err := world.handleMovement(client, playerMovementRequest(player, 10)); err != nil {
+ t.Fatal(err)
+ }
+ player.sitting = false
+ if err := world.handleMovement(client, playerMovementRequest(player, 23)); err != nil {
+ t.Fatal(err)
+ }
+ running := player.running && player.movement.components[0] == 3
+ if err := world.handleMovement(client, playerMovementRequest(player, 22)); err != nil {
+ t.Fatal(err)
+ }
+
+ if turn != 3.5 || player.movement.turn != 0 || !running || player.running || player.movement.components[0] != 2 {
+ t.Fatal("mode gates rejected native seated turning or ground walk/run transitions", turn, running, player.movement)
+ }
+}