commit e23f8d31c788a3f4467e39922b5bf0f2c153f50a
parent f4beee688df784f66fbc1be1a652ec5dc91ff253
Author: anon <anon@example.com>
Date: Mon, 26 Oct 2026 11:12:14 +0000
Apply native movement yaw offsets and pose-placement order
Compose ordinary action20 yaw with the native wrap and left quaternion
product while preserving the original pose/scalar for observer relay.
Share native placement ordering across movement paths, retaining direction
and reorienting velocity around contact without misreading MouseMove data.
Verify 1,279 server tests, 387 focused race results, data packages and vet.
Paired GPU WASM clients exercise positive/negative first-person camera
offsets and normal mouse turns, with facing differences below .004 degrees.
Diffstat:
7 files changed, 266 insertions(+), 23 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -1257,11 +1257,15 @@ disconnect retention and succession policy still need period corroboration.
Tests cover ceiling clearance, scale, raw versus modified abilities, irrelevant
packet scalars, a fresh jump during an ordinary fall and missing-provider
landing. Native owner/observer verification: [player geometry](docs/player-geometry.md).
-- [ ] Apply the native action20 yaw-offset scalar when anchoring a movement pose.
+- [x] Apply the native action20 yaw-offset scalar when anchoring a movement pose.
Its compact signed-short/2048 field is passed to VehicleForwardUpdate, which
composes a Y-axis quaternion with the supplied orientation. It is unrelated to
- jump height and is currently ignored by the server; verify nonzero values and
- normal zero-offset motion against the native client.
+ jump height. Preserve native left multiplication, wrap/stores and two-placement
+ ordering, retaining the original quaternion/scalar for observer relay. Tests
+ cover signed/wrapped offsets, a tilted body, reverse velocity, mouse opaque
+ floats and contact/history order. First-person Ctrl+RMB captures the nonzero
+ producer; a companion mouse update can mask the earlier ignored offset in the
+ final pose. See [movement](docs/movement.md).
- [x] Audit compact actor-spawn Run Speed. Send trained stat 156 as an unsigned
byte through 255 or a flagged short above it, preserving following materials.
Two GPU WASM clients verified training across 255, separate equipment/nano
diff --git a/docs/movement.md b/docs/movement.md
@@ -37,7 +37,8 @@ start after a 16-byte prefix; the native prefix occupies 13 bytes.
The reader normalizes the decoded quaternion. A normalized handler body is
63 bytes; its native body is 60 bytes, or 76 including the outer packet
-header. The shared compact pose is 15 bytes. CharDCMove adds a two-byte rate;
+header. The shared compact pose is 15 bytes. CharDCMove adds a signed two-byte
+yaw offset divided by2048;
CharMouseMove instead adds the two four-float groups. These layouts must not
be decoded interchangeably.
@@ -128,3 +129,62 @@ cleanup; all other database rows were unchanged by cleanup. No WASM rebuild
or adapter change was needed. The full Go server suite, focused movement/
casting/checkpoint race checks, and vet with the existing stdversion exception
passed.
+
+## Ordinary action20 yaw and placement
+
+CharDCMove action20 passes its extra scalar to VehicleForwardUpdate. The native
+receiver constructs a Y-axis rotation and left-multiplies the supplied quaternion:
+`(cX+sZ,cY+sW,cZ-sX,cW-sY)`. Other actions ignore this scalar. CharMouseMove passes
+zero to the same method; its eight opaque floats are preserved independently.
+
+For angles in[0,2*pi), the half-angle is a*.5. Other finite received angles use
+the native float32 reciprocal-of-2*pi, float32 scratch, double floor and float32
+pi path. The sine spills to float32 while cosine remains wide through quaternion
+composition. There is no quaternion normalization or sign canonicalization in
+this method; a negative offset can produce the opposite signed representative
+of an equivalent quaternion. Compact pose decoding still performs its own
+existing normalization before this operation.
+
+Both message paths first place the unmodified packet pose, then place the
+original packet position with the composed quaternion. An unchanged pose does
+no work. A changed quaternion reorients velocity before contact; a changed
+position records incoming history before contact. Either changed placement
+aligns the body, then reorients the remaining velocity again. This ordering lets
+landing clear vertical motion before the final rewrite. Native direction and
+cached speed remain intact except for effects of the contact callbacks. Even
+zero-offset updates can require a second alignment when the first projection
+moves the body away from the packet position.
+
+The server uses one placement routine for these paths. It stores the composed
+facing in memory while relaying the original quaternion and scalar, allowing the
+native observer to compose the offset once. Checkpoint and casting policies are
+unchanged. Public-handler regressions cover zero/positive/negative/wrapped yaw,
+a tilted body, the captured .1875 offset, forward/reverse speed, original relay
+fields, opaque mouse fields, incoming fall height and position-only landing.
+
+The source-supported nonzero producer is first-person camera mouse look with
+Ctrl held. Releasing Ctrl or ending that look sends fmod(accumulatedYaw,pi).
+Headed native capture verifies Ctrl+RMB selects mode9, accumulates camera yaw
+.1875 and resets it on release; the corresponding compact scalar is384 (0x0180).
+A companion mouse-turn packet can correct final facing in the same captured
+millisecond, which masks the ignored-field defect when only the final pose is
+examined. This does not make the first action20 packet redundant for simulation.
+
+`local/player-geometry-research/pose-yaw/` binds32 maintained bodies, initialized
+receiver/placement bindings and their source-only verifier.
+`local/player-geometry-research/yaw-producer/` binds66 bodies,556 maintained C
+files,33 initializer inventories, producer/control flow and the passive camera
+capture. These ledgers distinguish source rules from measured runtime state.
+
+The yaw/placement milestone passes all 1,279 top-level server tests (14,208
+results), 387 focused race results, the data packages and `go vet`.
+`local/player-yaw-movement/` retains the exact-source suite manifest, binaries,
+source checks, native camera/body probes and selected wire verification. Two
+GPU WASM clients send positive/negative offsets .1875/-.1875 through ordinary
+first-person Ctrl+RMB release. Sampled owner/observer/server facing differs by at
+most 0.0035 degrees across those checks and normal third-person RMB turns.
+Orientation comparisons account for equivalent quaternion signs; the server's
+wrap operation still preserves the native signed representation. Both clients
+report no WASM page errors. Owned visitors 126-131 are removed after browser
+cleanup; unrelated SQLite rows remain unchanged and foreign-key/integrity checks
+pass. The single shared HTTPS8443 preview runs this verified build.
diff --git a/docs/player-geometry.md b/docs/player-geometry.md
@@ -305,7 +305,8 @@ callback after alignment, while complete indoor jump trajectories await indoor
geometry support.
The extra compact movement scalar is an action20 yaw offset, not a jump
-parameter. Its nonzero application remains a separate TODO. The retained native
+parameter. Its application and placement ordering are described in
+[movement](movement.md). The retained native
standing jump sends one action13 and no action14. Neither OnStartFalling nor
OnLand constructs a packet or calculates fall damage. The original server's
damage threshold, formula and immunities remain unknown; absence of a dedicated
diff --git a/server/combat_lifecycle_test.go b/server/combat_lifecycle_test.go
@@ -16,7 +16,7 @@ func TestCombatReplacedSessionCannotMoveRestOrFinishLoading(t *testing.T) {
old := &worldClient{id: 1, conn: oldOutput, ready: true}
posture := make([]byte, 36)
binary.BigEndian.PutUint32(posture[16:20], 86)
- movement := make([]byte, 48)
+ movement := make([]byte, 56)
binary.BigEndian.PutUint32(movement[20:24], 0x41200000)
if err := world.handleCharacterReady(old); err != nil {
diff --git a/server/movement_yaw_test.go b/server/movement_yaw_test.go
@@ -0,0 +1,142 @@
+package main
+
+import (
+ "encoding/binary"
+ "fmt"
+ "math"
+ "testing"
+ "time"
+)
+
+func TestMovementYawOffsetUsesNativeLeftMultiplicationAndWrap(t *testing.T) {
+ for _, scenario := range []struct {
+ name string
+ offset float32
+ rotation, expected [4]float32
+ }{
+ {"zero", 0, [4]float32{0, 0, 0, 1}, [4]float32{0, 0, 0, 1}},
+ {"positive", 1, [4]float32{0, 0, 0, 1}, [4]float32{0, .47942555, 0, .87758255}},
+ {"captured camera offset", .1875, [4]float32{0, 0, 0, 1}, [4]float32{0, .09361273, 0, .9956087}},
+ {"negative wrap", -1, [4]float32{0, 0, 0, 1}, [4]float32{0, .47942546, 0, -.8775826}},
+ {"positive wrap", 7, [4]float32{0, 0, 0, 1}, [4]float32{0, .3507832, 0, .9364567}},
+ {"tilted body", 1, [4]float32{1, 0, 0, 0}, [4]float32{.87758255, 0, -.47942555, 0}},
+ } {
+ t.Run(scenario.name, func(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.rotation = scenario.rotation
+ request := playerMovementRequest(player, 20)
+ binary.BigEndian.PutUint16(request[len(request)-2:], uint16(int16(scenario.offset*2048)))
+
+ if err := world.handleMovement(client, request); err != nil {
+ t.Fatal(err)
+ }
+
+ for axis, expected := range scenario.expected {
+ if math.Abs(float64(player.rotation[axis]-expected)) > .000001 {
+ t.Fatal("movement yaw lost native composition or quaternion sign", player.rotation, scenario.expected)
+ }
+ }
+ })
+ }
+}
+
+func TestMovementYawOffsetPreservesSpeedAndReverseDirection(t *testing.T) {
+ for _, action := range []uint32{1, 3} {
+ t.Run(fmt.Sprint(action), func(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.inventory, player.rotation, player.running = playerInventory{}, [4]float32{0, 0, 0, 1}, false
+ if err := world.handleMovement(client, playerMovementRequest(player, action)); err != nil {
+ t.Fatal(err)
+ }
+ world.advancePlayerMovement(player.movement.updatedAt.Add(100 * time.Millisecond))
+ request := playerMovementRequest(player, 20)
+ binary.BigEndian.PutUint16(request[len(request)-2:], 2048)
+
+ if err := world.handleMovement(client, request); err != nil {
+ t.Fatal(err)
+ }
+
+ sign := float32(1)
+ if action == 3 {
+ sign = -1
+ }
+ if player.movement.direction != int32(sign) || math.Abs(float64(player.movement.speed)-.3) > .00001 || math.Abs(float64(player.movement.velocity[0]-sign*.2524413)) > .00001 || math.Abs(float64(player.movement.velocity[2]-sign*.1620907)) > .00001 {
+ t.Fatal("yaw placement must reorient velocity without changing retained speed or direction", player.movement)
+ }
+ })
+ }
+}
+
+func TestMovementYawOffsetRelayKeepsTheOriginalPoseAndScalar(t *testing.T) {
+ world, owner := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.rotation = [4]float32{0, 0, 0, 1}
+ observer := &combatTestConn{}
+ world.characters[2] = &character{id: 2, playfield: player.playfield, health: 100}
+ world.clients[2] = &worldClient{id: 2, target: true, ready: true, conn: observer}
+ request := playerMovementRequest(player, 20)
+ binary.BigEndian.PutUint16(request[len(request)-2:], 2048)
+
+ if err := world.handleMovement(client, request); err != nil {
+ t.Fatal(err)
+ }
+
+ if len(owner.packets) != 0 || len(observer.packets) != 1 {
+ t.Fatal("pose must relay only to the observer", len(owner.packets), len(observer.packets))
+ }
+ packet := observer.packets[0]
+ body := decodeMovement1491(packet[29:])
+ if binary.BigEndian.Uint32(packet[16:20]) != 0x54111123 || packet[28] != 0 || math.Float32frombits(binary.BigEndian.Uint32(body[32:36])) != 1 || math.Float32frombits(binary.BigEndian.Uint32(body[28:32])) != 1 || binary.BigEndian.Uint64(body[16:24]) != 0 || binary.BigEndian.Uint32(body[24:28]) != 0 {
+ t.Fatal("relay must preserve the raw quaternion and scalar so observers compose yaw once", packet)
+ }
+}
+
+func TestMovementPoseRecordsIncomingHeightBeforeStartingToFall(t *testing.T) {
+ world := newPlayerCollisionWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ pose := *player
+ pose.position[1] = 30
+ request := playerMovementRequest(&pose, 20)
+
+ if err := world.handleMovement(client, request); err != nil {
+ t.Fatal(err)
+ }
+
+ if !player.movement.falling || player.movement.fallHeight != 30 || player.movement.previousPosition[1] != 30 {
+ t.Fatal("placement must record the incoming position before the falling callback", player.position, player.movement)
+ }
+}
+
+func TestMouseMovementDoesNotInterpretItsOpaqueFloatsAsYaw(t *testing.T) {
+ world, _ := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ request := mouseMovementRequest()
+ binary.BigEndian.PutUint32(request[31:35], math.Float32bits(1))
+
+ if err := world.handleMovement(client, request); err != nil {
+ t.Fatal(err)
+ }
+
+ if math.Abs(float64(player.rotation[1])-.47255) > .0001 || math.Abs(float64(player.rotation[3])-.8813) > .0001 {
+ t.Fatal("MouseMove must pass zero yaw independently of its opaque fields", player.rotation)
+ }
+}
+
+func TestMovementPoseReorientsVelocityAfterPositionOnlyLanding(t *testing.T) {
+ world := newPlayerCollisionWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.rotation = [4]float32{0, 0, 0, 1}
+ player.movement.velocity = [3]float32{0, -1, 1}
+ player.movement.falling = true
+ request := playerMovementRequest(player, 20)
+
+ if err := world.handleMovement(client, request); err != nil {
+ t.Fatal(err)
+ }
+
+ if player.movement.velocity != [3]float32{0, 0, 1} || player.movement.speed != 1 || player.movement.falling {
+ t.Fatal("position-only placement must land before reorienting the remaining horizontal velocity", player.movement)
+ }
+}
diff --git a/server/player_movement.go b/server/player_movement.go
@@ -73,6 +73,33 @@ func predictedPosition_locked(player *character, now time.Time) [3]float32 {
return player.predictedMovement(now).position
}
+func (player *character) reorientMovement() {
+ forward, _ := bodyAxes(player.rotation)
+ speed := float32(math.Sqrt(surfaceDot(player.movement.velocity, player.movement.velocity)))
+ for axis := range forward {
+ player.movement.velocity[axis] = forward[axis] * speed
+ player.movement.velocity[axis] *= float32(player.movement.direction)
+ }
+}
+
+func (player *character) placeMovement(position [3]float32, rotation [4]float32) {
+ // Source: client/game/qqr.dll/lifted-0005.c, sub_42010A30.
+ if player.position == position && player.rotation == rotation {
+ return
+ }
+ previous := player.position
+ if player.rotation != rotation {
+ player.rotation = rotation
+ player.reorientMovement()
+ }
+ if player.position != position {
+ player.position = position
+ player.movement.previousPosition = position
+ }
+ player.alignSurface(previous, true)
+ player.reorientMovement()
+}
+
func bodyAxes(rotation [4]float32) ([3]float32, [3]float32) {
x, y, z, w := rotation[0], rotation[1], rotation[2], rotation[3]
return [3]float32{2*x*z + 2*y*w, 2*y*z - 2*x*w, 1 - 2*x*x - 2*y*y}, [3]float32{1 - 2*y*y - 2*z*z, 2*x*y + 2*z*w, 2*x*z - 2*y*w}
diff --git a/server/world_actions.go b/server/world_actions.go
@@ -122,7 +122,7 @@ func (server *server) handleMovement(client *worldClient, body []byte) error {
}
body = append(body[:16:16], decodeMovement1491(body[16:33])...)
}
- if len(body) < 48 {
+ if len(body) < 52 {
return fmt.Errorf("short character movement message")
}
server.mutex.Lock()
@@ -135,29 +135,38 @@ func (server *server) handleMovement(client *worldClient, body []byte) error {
previousPosition := character.position
now := time.Now()
character.anchorMovement_locked(now)
- oldPosition, oldRotation := character.position, character.rotation
- for i := range character.position {
- character.position[i] = math.Float32frombits(binary.BigEndian.Uint32(body[20+i*4:]))
- }
- for i := range character.rotation {
- character.rotation[i] = math.Float32frombits(binary.BigEndian.Uint32(body[32+i*4:]))
- }
- // Native pose anchoring preserves speed, aligning velocity before the event.
- if character.position != oldPosition || character.rotation != oldRotation {
- forward, _ := bodyAxes(character.rotation)
- speed := vectorLength(character.movement.velocity) * float32(character.movement.direction)
- for axis := range forward {
- character.movement.velocity[axis] = forward[axis] * speed
+ var position [3]float32
+ var rotation [4]float32
+ for i := range position {
+ position[i] = math.Float32frombits(binary.BigEndian.Uint32(body[20+i*4:]))
+ }
+ for i := range rotation {
+ rotation[i] = math.Float32frombits(binary.BigEndian.Uint32(body[32+i*4:]))
+ }
+ character.placeMovement(position, rotation)
+ action := binary.BigEndian.Uint32(body[16:20])
+ if action == 20 {
+ // VehicleForwardUpdate composes yaw after the common placement; MouseMove uses zero.
+ angle := float32(0)
+ if key == 0x54111123 {
+ angle = math.Float32frombits(binary.BigEndian.Uint32(body[48:52]))
}
- character.alignSurface(oldPosition, true)
+ half := float64(angle) * .5
+ if angle < 0 || float64(angle) >= 2*math.Pi {
+ turns := float64(angle) * float64(float32(1/(2*math.Pi)))
+ half = (float64(float32(turns)) - math.Floor(turns)) * float64(float32(math.Pi))
+ }
+ sine, cosine := math.Sincos(half)
+ sine = float64(float32(sine))
+ x, y, z, w := float64(rotation[0]), float64(rotation[1]), float64(rotation[2]), float64(rotation[3])
+ rotation = [4]float32{float32(cosine*x + sine*z), float32(cosine*y + sine*w), float32(cosine*z - sine*x), float32(cosine*w - sine*y)}
+ character.placeMovement(position, rotation)
}
playfield := character.playfield
- action := binary.BigEndian.Uint32(body[16:20])
if action != 20 {
character.followTarget = 0
}
character.movement.action(character, action)
- character.movement.previousPosition = character.position
if client.trade != nil && !server.playerTradeAvailable_locked(client.trade.clients[0], client.trade.clients[1]) {
server.cancelPlayerTrade_locked(client)
}