commit 28a8a599c779b65a91579d3b8e3d529ab3d53d35
parent 14367a9330b84a65c8649fe3c0c2124d9e732c14
Author: anon <anon@example.com>
Date: Mon, 26 Oct 2026 15:51:29 +0000
Apply native posture admission and simulate seated movement
Route sit/stand through the shared helper predicate and component transitions.
Apply sit's entry Halt once while preserving gravity, turning, jump state and
the preferred ground mode. Keep frozen and seated-water lifecycles explicit.
Verify 1329 server roots, 167 race roots, eight failing prior-code regressions,
source ledgers and eight paired GPU WASM cases. Remove owned fixtures and
retain one verified HTTPS8443 preview.
Diffstat:
5 files changed, 314 insertions(+), 10 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -1321,15 +1321,28 @@ disconnect retention and succession policy still need period corroboration.
authored flight OnWear replay, followed by a pose-only anchor. Include idle
actors and following actors. See
[ground requests during flight](docs/player-movement.md#ground-mode-requests-during-flight).
-- [ ] Complete native movement callbacks and posture admission. Check sit28's
- forward/strafe/turn state gate and stand33's Features4 handling. Complete the frozen
- and sneak state lifecycles before claiming the whole helper state machine.
+- [x] Apply ordinary sit/stand through helper admission. Sit28 rejects active
+ forward/strafe/turn component states and disallowed primary modes before granting
+ rest. Halt once on entry, preserving independent gravity and controls; simulate
+ seated turning, falling and landing. Normal stand33 restores preferred walk/run
+ without Halt. Keep posture acknowledgements for both native consumers even when
+ their physical helpers reject. See [posture](docs/player-movement.md#sit-and-stand).
+- [ ] Complete frozen and sneak movement callbacks and lifecycles before claiming
+ the whole helper state machine. Features4-clear stand33 currently preserves
+ seated actor state but does not enter frozen helper1. Recover RestrictAction's
+ internal21/34 transitions, stationary state, control cleanup, and the distinction
+ between helper primary and raw MovementMode173/posture430. Cover overlapping
+ restrictions, expiry/removal, death and late observers.
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
elevation callbacks use+3/-0.8, including cached-state quirks; do not invent
flight up/down bindings from those names. Source ledgers:
`local/player-flight-input/research/{helpers,producers}/`.
+- [ ] Verify seated water entry/exit independently of actor posture430. The native
+ water helper can replace8 with4 without the ordinary stand callback. Compare
+ forward steering, recovery modifiers, preferred-mode restoration and late
+ observers; the server still derives seated simulation from its actor flag.
- [x] Simulate ordinary outdoor jumping and physical landing. Movement13 uses raw
Strength/Agility, the native upward ceiling probe and mass/impulse float stores.
Preserve horizontal controls, reject swimming/sitting and repeated airborne
diff --git a/docs/player-movement.md b/docs/player-movement.md
@@ -141,11 +141,58 @@ 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
-remain explicit TODOs. The verified source
+predicate does not implement frozen/sneak transitions. 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/`.
+## Sit and stand
+
+Ordinary CharacterAction86/87 submits helper28/33 through the same primary-mode
+predicate as movement. Sit additionally rejects active forward state3, strafe
+state3 or turn state5. It tests component state, independently of cached scalar
+controls, current speed, gravity or jump phase. A rejected sit cannot grant the
+server's seated recovery multiplier or treatment eligibility. Its acknowledgement
+still reaches both clients, whose native helpers apply their own admission.
+
+Accepted sit changes primary to8, preserves preferred walk/run and copies the
+usual old strafe state into elevation history. Entry calls Halt once: ordinary
+velocity and cached speed clear only when cached speed is nonzero. Independent
+gravity, falling, controls, orientation and jump phase remain. Seated physics
+blocks longitudinal manual/follow steering while retaining direct lateral input,
+turning, gravity and contact. A seated landing clears physical jump height but
+cannot submit helper14 through primary8; its secondary4 remains until another
+admitted transition changes it.
+
+Normal stand restores the preferred ground mode from8, preserves motion and
+performs no Halt or position lift. Features4-clear stand leaves the seated actor
+flag intact. The complete frozen lifecycle remains unsupported: native33 would
+enter helper1 while retaining actor stats173/425/430, whereas the server currently
+keeps its existing helper. RestrictAction53068 mask4 controls that same permission.
+Do not equate the physical helper with raw MovementMode173 in that branch.
+
+Seated water entry/exit also remains a separate TODO: native helper24 can replace8
+with4 without calling normal stand. The server's current actor flag still drives
+its seated steering gate and ground-mode derivation. Verify that mixed lifecycle
+before claiming swimming/posture parity.
+
+Sources: `client/game/kkr.dll/lifted-0022.c`, `sub_36046B40`, `sub_36046C90`,
+`sub_36046D60`, `sub_360447C0`; `client/game/kkr.dll/lifted-0023.c`,
+`sub_360497A0`; `client/game/qqr.dll/lifted-0006.c`, `sub_42011BC0`.
+Complete source bodies and independent action/physics checks are retained under
+`local/player-posture/research/{actions,physics}/`.
+
+The posture change passes all 1,329 server roots (14,366 results), 35 focused roots
+(115 results), 167 race roots (534 results), the data packages and `go vet`.
+All eight new regression roots fail against the earlier implementation. Exact
+source manifests, source checks and paired GPU WASM captures are retained in
+`local/player-posture/`.
+
+Eight final ordinary-keyboard cases verify rejected moving sit, idle sit, seated
+turning, stand, mid-jump sit/landing, preferred running, seated late join and
+running stand. Both native helpers and raw stats173/425/430 agree with server
+posture, with no WASM page errors. These captures establish the selected state
+and final-contact checks; they do not claim bit-identical intermediate motion.
+
## Ground mode requests during flight
Accepted walk22/run23 requests leave flight while keeping the item worn, its
diff --git a/server/player_movement.go b/server/player_movement.go
@@ -170,7 +170,7 @@ func (player *character) advanceMovement(now time.Time, target [3]float32) bool
return heightLimited
}
movement.prepare(player, now)
- if player.movementRestricted() || player.sitting {
+ if player.movementRestricted() {
movement.velocity = [3]float32{}
movement.speed = 0
return heightLimited
@@ -188,14 +188,14 @@ func (player *character) advanceMovement(now time.Time, target [3]float32) bool
speed := float32(1.5)
if movement.deepWater {
speed = player.swimmingMovementSpeed()
- } else if player.running || player.flying() {
+ } else if movement.components[0] == 3 || movement.components[0] == 7 {
speed = player.runningMovementSpeed(movement.components[2] != 1)
}
forceLimit := min(float32(10000), 2*(bodyMass+float32(carriedMass)*float32(.001))*speed)
forward, right := bodyAxes(player.rotation)
force := [3]float32{}
steering := false
- if player.followTarget != 0 {
+ if !player.sitting && player.followTarget != 0 {
// KKR48430 / QQR15fe0,15e90: four-unit arrival point, damping and Halt.
delta := [3]float32{target[0] - player.position[0], target[1] - player.position[1], target[2] - player.position[2]}
distance := vectorLength(delta)
@@ -222,7 +222,7 @@ func (player *character) advanceMovement(now time.Time, target [3]float32) bool
force[axis] = 4 * bodyMass * (delta[axis]/distance*min(speed, 4*distance) - movement.velocity[axis])
}
}
- } else if movement.forward != 0 {
+ } else if !player.sitting && movement.forward != 0 {
steering = true
// QQR159a0/159f0 uses full signed force, independently of arrival damping.
sign := float32(1)
@@ -448,6 +448,24 @@ func (movement *playerMovement) action(player *character, action uint32) bool {
} else {
movement.prepare(player, movement.updatedAt)
}
+ case 28:
+ // KKR helper360497A0 checks component states, independently of cached speed.
+ accepted = old[1] != 3 && old[3] != 3 && old[7] != 5
+ if accepted {
+ player.sitting = true
+ movement.components[0] = 8
+ // QQR Halt42011BC0 leaves gravity and controls intact, including stale V at S0.
+ if movement.speed != 0 {
+ movement.velocity, movement.speed = [3]float32{}, 0
+ }
+ }
+ case 33:
+ // Features4-clear stand retains seated actor state; its frozen helper is pending.
+ accepted = !player.movementRestricted()
+ if accepted {
+ player.sitting = false
+ movement.prepare(player, movement.updatedAt)
+ }
case 20:
return true
}
diff --git a/server/player_posture_test.go b/server/player_posture_test.go
@@ -0,0 +1,221 @@
+package main
+
+import (
+ "encoding/binary"
+ "fmt"
+ "math"
+ "testing"
+ "time"
+)
+
+func TestPlayerSitUsesComponentAdmissionBeforeChangingRest(t *testing.T) {
+ for _, scenario := range []struct {
+ name string
+ components [10]byte
+ sitting bool
+ }{
+ {"walking", [10]byte{2, 1, 0, 1, 0, 5, 4, 1, 0, 1}, true},
+ {"running", [10]byte{3, 1, 0, 1, 0, 5, 4, 1, 0, 1}, true},
+ {"forward", [10]byte{2, 3, 1, 1, 0, 5, 4, 1, 0, 1}, false},
+ {"reverse", [10]byte{3, 3, 2, 1, 0, 5, 4, 1, 0, 1}, false},
+ {"strafe", [10]byte{2, 1, 0, 3, 4, 5, 4, 1, 0, 1}, false},
+ {"turn", [10]byte{2, 1, 0, 1, 0, 5, 4, 5, 3, 1}, false},
+ {"swimming", [10]byte{4, 1, 0, 1, 0, 5, 4, 1, 0, 1}, false},
+ {"flight", [10]byte{7, 1, 0, 1, 0, 5, 4, 1, 0, 1}, false},
+ {"seated", [10]byte{8, 1, 0, 1, 0, 5, 4, 1, 0, 1}, true},
+ } {
+ t.Run(scenario.name, func(t *testing.T) {
+ world, owner := newCombatWorld()
+ player := world.characters[1]
+ player.running, player.sitting = scenario.components[0] == 3, scenario.components[0] == 8
+ player.movement.prepare(player, time.Now().Add(time.Second))
+ player.movement.components = scenario.components
+ player.movement.deepWater = scenario.components[0] == 4
+ observer := &combatTestConn{}
+ world.characters[2] = &character{id: 2, playfield: 950, health: 100}
+ world.clients[2] = &worldClient{id: 2, ready: true, target: true, conn: observer}
+ request := make([]byte, 36)
+ binary.BigEndian.PutUint32(request[16:], 86)
+
+ if err := world.handlePosture(world.clients[1], request); err != nil {
+ t.Fatal(err)
+ }
+
+ want := scenario.components
+ if scenario.sitting && scenario.components[0] != 8 {
+ want[0], want[5] = 8, want[3]
+ }
+ if player.sitting != scenario.sitting || player.movement.components != want {
+ t.Fatal("sit ignored helper admission or changed history on rejection", player.sitting, player.movement.components, want)
+ }
+ if len(owner.packets) != 1 || len(observer.packets) != 1 || binary.BigEndian.Uint32(owner.packets[0][29:]) != 86 || binary.BigEndian.Uint32(observer.packets[0][29:]) != 86 {
+ t.Fatal("native acknowledgement must reach both helper consumers even on physical rejection", owner.packets, observer.packets)
+ }
+ })
+ }
+}
+
+func TestPlayerSitHaltPreservesGravityAndIndependentControls(t *testing.T) {
+ for _, speed := range []float32{0, 5} {
+ t.Run(fmt.Sprint(speed), func(t *testing.T) {
+ world, _ := newCombatWorld()
+ player := world.characters[1]
+ player.rotation = [4]float32{0, 0, 0, 1}
+ player.followTarget = 1000000
+ player.movement.prepare(player, time.Now().Add(time.Second))
+ player.movement.components = [10]byte{2, 1, 0, 1, 0, 5, 4, 1, 0, 4}
+ player.movement.velocity, player.movement.speed = [3]float32{3, 0, 4}, speed
+ player.movement.forward, player.movement.strafe, player.movement.turn, player.movement.vertical = 1, 2, 3.5, 6
+ player.movement.verticalVelocity, player.movement.jumpHeight, player.movement.fallHeight, player.movement.falling = -12, 2, 60, true
+ request := make([]byte, 36)
+ binary.BigEndian.PutUint32(request[16:], 86)
+
+ if err := world.handlePosture(world.clients[1], request); err != nil {
+ t.Fatal(err)
+ }
+
+ velocity := [3]float32{}
+ if speed == 0 {
+ velocity = [3]float32{3, 0, 4}
+ }
+ if !player.sitting || player.movement.velocity != velocity || player.movement.speed != 0 || player.movement.components != [10]byte{8, 1, 0, 1, 0, 1, 4, 1, 0, 4} {
+ t.Fatal("sit Halt lost its cached-speed boundary or accepted snapshot", player.movement)
+ }
+ if player.movement.forward != 1 || player.movement.strafe != 2 || player.movement.turn != 3.5 || player.movement.vertical != 6 || player.movement.verticalVelocity != -12 || player.movement.jumpHeight != 2 || player.movement.fallHeight != 60 || !player.movement.falling || player.followTarget != 1000000 {
+ t.Fatal("sit cleared independent controls, gravity or follow", player.movement, player.followTarget)
+ }
+ })
+ }
+}
+
+func TestPlayerSeatedTurningRunsWithoutActivatingForward(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.inventory, player.sitting = playerInventory{}, true
+ player.rotation = [4]float32{0, 0, 0, 1}
+ player.movement.forward = 1
+ position := player.position
+ if err := world.handleMovement(client, playerMovementRequest(player, 9)); err != nil {
+ t.Fatal(err)
+ }
+
+ world.advancePlayerMovement(player.movement.updatedAt.Add(200 * time.Millisecond))
+
+ if player.position != position || math.Abs(float64(player.rotation[1])-.3428978) > .00001 || math.Abs(float64(player.rotation[3])-.9393727) > .00001 || !player.sitting || player.movement.forward != 1 {
+ t.Fatal("seated turning was frozen or activated longitudinal motion", player.position, player.rotation, player.movement)
+ }
+}
+
+func TestPlayerSeatedPhysicsUsesSeatedSpeedWithPreferredRunning(t *testing.T) {
+ world := newPlayerCollisionWorld(t)
+ player := world.characters[1]
+ player.running, player.sitting = true, true
+ player.position, player.rotation = [3]float32{961.625, 60, 510.75}, [4]float32{0, 0, 0, 1}
+ started := time.Now()
+ player.movement.prepare(player, started)
+ player.movement.velocity, player.movement.speed = [3]float32{3, 0, 4}, 0
+ player.movement.verticalVelocity, player.movement.falling = -12, true
+
+ world.advancePlayerMovement(started.Add(100 * time.Millisecond))
+
+ if player.movement.speed != 1.5 || math.Abs(float64(player.movement.velocity[0])-.9) > .00001 || math.Abs(float64(player.movement.velocity[2])-1.2) > .00001 || player.movement.verticalVelocity != -14 || !player.sitting || !player.running {
+ t.Fatal("seated physics used preferred running limits or lost independent gravity", player.movement)
+ }
+}
+
+func TestPlayerStandPreservesMotionAndRequiresMovementPermission(t *testing.T) {
+ for _, restricted := range []bool{false, true} {
+ for _, running := range []bool{false, true} {
+ t.Run(fmt.Sprintf("restricted%t/running%t", restricted, running), func(t *testing.T) {
+ world, _ := newCombatWorld()
+ player := world.characters[1]
+ player.sitting, player.running = true, running
+ player.movement.prepare(player, time.Now().Add(time.Second))
+ player.movement.velocity, player.movement.speed = [3]float32{3, 0, 4}, 5
+ player.movement.verticalVelocity, player.movement.falling = -12, true
+ if restricted {
+ player.activeNanos = []activeNano{{program: 42110}}
+ }
+ request := make([]byte, 36)
+ binary.BigEndian.PutUint32(request[16:], 87)
+
+ if err := world.handlePosture(world.clients[1], request); err != nil {
+ t.Fatal(err)
+ }
+
+ mode := byte(2)
+ if running {
+ mode = 3
+ }
+ if player.sitting != restricted || player.running != running || player.movement.verticalVelocity != -12 || !player.movement.falling {
+ t.Fatal("stand lost preferred mode, actor permission or retained motion", player.sitting, player.movement)
+ }
+ if !restricted && (player.movement.components[0] != mode || player.movement.velocity != [3]float32{3, 0, 4} || player.movement.speed != 5) {
+ t.Fatal("ordinary stand changed velocity or failed to restore the preferred helper", player.movement)
+ }
+ })
+ }
+ }
+}
+
+func TestPlayerRejectedSitKeepsStandingRecovery(t *testing.T) {
+ world, _, start := newRegenerationWorld()
+ player := world.characters[1]
+ player.movement.prepare(player, time.Now().Add(time.Second))
+ player.movement.components[1], player.movement.components[2], player.movement.forward = 3, 1, 1
+ request := make([]byte, 36)
+ binary.BigEndian.PutUint32(request[16:], 86)
+
+ if err := world.handlePosture(world.clients[1], request); err != nil {
+ t.Fatal(err)
+ }
+ world.advanceCombat(start.Add(14 * time.Second))
+
+ if player.sitting || player.health != 20 || player.nano != 0 {
+ t.Fatal("rejected sit granted the earlier seated recovery tick", player.sitting, player.health, player.nano)
+ }
+}
+
+func TestPlayerSitDuringJumpFallsAndLandsWhileSeated(t *testing.T) {
+ world := newPlayerCollisionWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ if err := world.handleMovement(client, playerMovementRequest(player, 13)); err != nil {
+ t.Fatal(err)
+ }
+ started := player.movement.updatedAt
+ world.advancePlayerMovement(started.Add(100 * time.Millisecond))
+ request := make([]byte, 36)
+ binary.BigEndian.PutUint32(request[16:], 86)
+
+ if err := world.handlePosture(client, request); err != nil {
+ t.Fatal(err)
+ }
+ height := player.position[1]
+ for frame := 1; frame <= 120; frame++ {
+ world.advancePlayerMovement(started.Add(100*time.Millisecond + time.Duration(frame)*time.Second/60))
+ }
+
+ if height <= 16.8 || math.Abs(float64(player.position[1])-16.41) > .02 || !player.sitting || player.movement.falling || player.movement.verticalVelocity != 0 || player.movement.jumpHeight != 0 || player.movement.components[9] != 4 {
+ t.Fatal("sit stopped gravity or incorrectly admitted jump release on landing", height, player.position, player.movement)
+ }
+}
+
+func TestPlayerRejectedSitCannotGainRestOrCauseDatabaseWrites(t *testing.T) {
+ world := newCheckpointWorld(t)
+ player := world.characters[1]
+ client := &worldClient{id: 1, ready: true, target: true, conn: &combatTestConn{}}
+ world.clients[1] = client
+ player.movement.prepare(player, time.Now().Add(time.Second))
+ player.movement.components[1], player.movement.components[2], player.movement.forward = 3, 1, 1
+ request := make([]byte, 36)
+ binary.BigEndian.PutUint32(request[16:], 86)
+ auditCheckpointWrites(t, world)
+
+ if err := world.handlePosture(client, request); err != nil {
+ t.Fatal(err)
+ }
+
+ if player.sitting || len(checkpointWrites(t, world)) != 0 {
+ t.Fatal("rejected sit granted resting eligibility or churned SQLite", player.sitting, checkpointWrites(t, world))
+ }
+}
diff --git a/server/world_actions.go b/server/world_actions.go
@@ -16,7 +16,12 @@ func (server *server) handlePosture(client *worldClient, body []byte) error {
server.mutex.Unlock()
return nil
}
- character.sitting = binary.BigEndian.Uint32(body[16:20]) == 86
+ character.anchorMovement_locked(time.Now())
+ action := uint32(28)
+ if binary.BigEndian.Uint32(body[16:20]) == 87 {
+ action = 33
+ }
+ character.movement.action(character, action)
playfield := character.playfield
server.mutex.Unlock()