commit 8ba67415c509e683f7925144dd924a5047ccc068
parent bfe4aa47a211ea5d91053e24c8bb6d130649e6a1
Author: anon <anon@example.com>
Date: Sun, 25 Oct 2026 12:53:53 +0000
Preserve trained RunSpeed in native actor snapshots
Diffstat:
6 files changed, 271 insertions(+), 5 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -895,10 +895,13 @@ disconnect retention and succession policy still need period corroboration.
## Travel
-- [ ] Audit compact actor-spawn Run Speed. The byte after HeadMesh is applied
- to native stat 156; the server currently sends a constant 100. Recover its
- complete compact encoding and verify that a late observer receives the
- correct speed after training, equipment changes and reconnect.
+- [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
+ modifiers, removal, late observers, owner reconnect and cold server recovery.
+ Simultaneous native forward speeds both read 6.085 m/s. NPC speed policy is
+ unchanged; the original server's encoding preference remains unknown. See
+ [actor Run Speed](docs/actor-run-speed.md).
- [x] Synchronize rotation while a character stands still. Check: turning with
keys or the mouse updates another native client promptly, without requiring
walking, a later packet or reconnect. Cover start/stop, final facing, late
diff --git a/docs/actor-run-speed.md b/docs/actor-run-speed.md
@@ -0,0 +1,106 @@
+# Actor snapshot Run Speed
+
+SimpleCharFullUpdate (`0x271b3a6b`) supplies the player's trained RunSpeed
+stat 156. FullCharacter supplies the same raw stat to the owner. Equipment
+OnWear and active nano replay then contribute their modifiers once. Sending
+an effective skill here would duplicate modifiers; including ability trickle
+would also disagree with the native movement getter's mode 3.
+
+The actor snapshot previously used raw 100 for every player. A newly created
+observer could therefore predict different movement from the owner even when
+both received the same movement controls. The server now uses the player's
+stored raw skill. NPC snapshots retain this server's fixed 100 movement
+foundation, matching its existing 4.5 m/s chase policy; this change does not
+establish historical species-specific NPC speed.
+
+## Original receiver contract
+
+Original target: `anarchy-vanilla-14.9.1/kkr.dll`, SHA-256
+`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`.
+Addresses below use original image base `0x10000000`.
+
+The field follows the vehicle stream and optional HeadMesh. Reader
+`10082da0`, at `10083681..100836a7`, selects its representation using the
+message flags:
+
+| Flag `0x2000` | Wire field | Meaning |
+| --- | --- | --- |
+| Clear | One unsigned byte | Raw value 0 through 255 |
+| Set | One big-endian signed short | Raw value -32768 through 32767 |
+
+The reader stores a word at message offset `0x190`. Activation `100821d0`,
+at `1008251b..1008252c`, sign-extends it and sets raw stat 156 through
+`1006e030`. No scaling or clamping occurs. Narrow `ff` is positive 255;
+wide `0100` is 256 and `012c` is 300. Values above 32767 cannot represent a
+positive stat through this field.
+
+The mode-3 stat getter (`1006dfb0` / `10075cd0`) adds the separate modifier
+map to the raw table. Movement getter `10047be0` requests that mode for
+RunSpeed. Skill-window values can include ability trickle and should not be
+mistaken for the movement input.
+
+The message's shipped payload writer `1010def0` is an empty `ret 4` stub.
+There is no recovered original server writer choosing a representation or
+handling out-of-range input. This server's shortest-form choice, byte through
+255 and flagged short above it, is a reconstruction compatible with the
+proven receiver. It is not an original-server capture.
+
+The retained source ledger is `local/actor-speed-research/native/README.md`:
+15 complete original REA records and 10 validated citations. Principal reader
+evidence is
+`ev_9ba1ee861536b7169d3adbd6fb561ea6e850f0c230ea1bbb9d80c38d02a5dc59`;
+activation is
+`ev_d1c6525d8047faf81030e0b0e00f69e3bec7b13e1e1c8c84779183724bffb2ba`.
+Supporting maintained-source checks and their limits remain explicit in that
+ledger. No new binary analysis session was opened.
+
+## Server and automated verification
+
+`characterPacket` selects the width and flag before writing its header.
+`targetPacket` accounts for the extra byte when locating and converting the
+following material list. Both compact and wide players retain all nine
+materials, including the vehicle surfaces.
+
+`server/actor_speed_test.go` covers raw values 0, 5, 254, 255, 256, 1000 and
+32767, both NPC appearances, unchanged NPC speed, accepted training across
+255, a worn Kodaik's +150 and Swiftness's +10. An actual world handshake to a
+late observer, repeated after database restore, verifies raw 256 and one
+separate equipment/nano replay. The regressions fail against the previous
+constant field.
+
+Focused actor/appearance/vehicle/movement checks passed in 48.729 seconds.
+Three race-detector repetitions passed in 100.749 seconds. Vet passed.
+The full Go suite passed 4870 tests and subtests: server 729.108 seconds and
+game data 8.860 seconds.
+
+## Actual WASM verification
+
+Two owned Chromium clients on the GPU reproduced raw 300 on the owner
+and 100 on its observer before the fix. The other player's owner/observer
+values were 5/100. After updating the single preview, both views agreed at
+300 and 5. Captured snapshots used the wide field for 300 and the compact
+field for 5 and 255, without corrupting the subsequent material list.
+
+Native skill-window training crossed from 255 to 257 and persisted the raw
+value and IP charge. Swiftness added 10 and the Kodaik added 150, producing
+417 in both clients' movement inputs. A fresh observer, owner replacement and
+actual server restart all retained raw 257 plus exactly 160 in modifiers.
+Simultaneous read-only samples while holding W measured native maximum
+forward velocity 6.085000038 m/s on both clients. Their sampled positions
+differed by 0.073835 m; stopped horizontal positions agreed within the
+0.125-metre compact coordinate step.
+
+Removing the Kodaik retained the nano's 10; cancelling Swiftness then restored
+257 in both views. Another observer reconnect retained 257 with no residual
+modifier. SQLite retained raw 257, the returned vehicle's original identity,
+and no active nano. Both clients rendered and accepted input without browser
+errors or unsupported adapters. No client rebuild or native behavior change
+was required.
+
+The wire, native heaps, SQLite snapshots, screenshots, GPU identity and
+`verification.json` are under `local/actor-speed-smoke/`. All game actions
+used native keyboard/mouse input; public control routes supplied owned
+fixtures, and the probes only read memory. Both test clients were closed.
+Cleanup removed only players 53/54 and their remaining vehicle, with matching
+unrelated-row hashes and SQLite integrity/foreign-key checks. Existing players
+8/24 remain, and one shared preview serves the default ports.
diff --git a/docs/movement.md b/docs/movement.md
@@ -1,5 +1,9 @@
# Player movement and stationary facing
+Actor snapshots use the trained movement foundation and the recovered compact
+or wide RunSpeed field. Source evidence and late-observer checks are in
+[actor Run Speed](actor-run-speed.md).
+
The 14.9.1 client sends keyboard movement through CharDCMoveIIR_t
(`0x54111123`) and right-button body rotation through CharMouseMoveIIR_t
(`0x25327751`). Both update the authoritative in-memory pose and relay to
diff --git a/server/actor_speed_test.go b/server/actor_speed_test.go
@@ -0,0 +1,137 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "net"
+ "testing"
+ "time"
+)
+
+func TestActorSpawnRunSpeedUsesNativeWidthsWithoutMovingMaterials(t *testing.T) {
+ for _, scenario := range []struct {
+ speed uint16
+ wide bool
+ wire []byte
+ }{
+ {0, false, []byte{0}}, {5, false, []byte{5}},
+ {254, false, []byte{254}}, {255, false, []byte{255}},
+ {256, true, []byte{1, 0}}, {1000, true, []byte{3, 232}},
+ {32767, true, []byte{127, 255}},
+ } {
+ t.Run(fmt.Sprint(scenario.speed), func(t *testing.T) {
+ player := &character{id: 1, name: "Runner", appearance: 0x515, level: 1, stats: testCharacterStats()}
+ player.stats.Speed.RunSpeed = scenario.speed
+
+ packet := targetPacket(characterPacket(player))
+
+ flags := binary.BigEndian.Uint32(packet[30:34])
+ if (flags&0x2000 != 0) != scenario.wide || !bytes.Equal(packet[143:143+len(scenario.wire)], scenario.wire) {
+ t.Fatalf("RunSpeed encoding: flags=%x field=%x", flags, packet[143:147])
+ }
+ materials := 143 + len(scenario.wire)
+ if binary.BigEndian.Uint32(packet[materials:]) != 10090 || bytes.Index(packet, []byte("arms\x00")) != materials+4 {
+ t.Fatalf("RunSpeed width displaced the native material list: %x", packet[143:])
+ }
+ for _, name := range []string{"hands", "body", "Material #2b", "Material #8"} {
+ if !bytes.Contains(packet, append([]byte(name), make([]byte, 32-len(name))...)) {
+ t.Fatalf("RunSpeed width corrupted material %s", name)
+ }
+ }
+ })
+ }
+}
+
+func TestNPCSpawnRetainsItsConfiguredMovementFoundation(t *testing.T) {
+ for _, appearance := range []uint16{0x515, 0x61} {
+ t.Run(fmt.Sprint(appearance), func(t *testing.T) {
+ npc := &character{id: 1000000, name: "Runner", npc: true, appearance: appearance, level: 1, stats: testCharacterStats()}
+ npc.stats.Speed.RunSpeed = 1000
+
+ packet := targetPacket(characterPacket(npc))
+
+ offset := 131
+ if appearance == 0x515 {
+ offset = 135
+ }
+ if binary.BigEndian.Uint32(packet[30:34])&0x2000 != 0 || packet[offset] != 100 {
+ t.Fatalf("NPC movement policy changed: %x", packet)
+ }
+ })
+ }
+}
+
+func TestLateActorSpawnKeepsTrainedSpeedSeparateFromEquipmentAndNanos(t *testing.T) {
+ world, _ := newVehicleWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.name, player.level = "Runner", 100
+ player.stats.Abilities = characterAbilitiesStats{400, 400, 400, 400, 400, 400}
+ player.stats.Speed.RunSpeed = 255
+ player.nano = 100
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ player.inventory.LearnedNanos = []uint32{27172}
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ castTestBuff(t, world, 1, 1, 27172)
+ if err := world.handleInventory(client, inventoryMovePacket(1, 64, 1)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ observer := world.newCharacter()
+ observer.playfield = player.playfield
+ if err := world.saveUser_locked(observer); err != nil {
+ t.Fatal(err)
+ }
+ proposed := player.baseStats()
+ proposed.Speed.RunSpeed = 256
+
+ if err := world.handleSkillTraining(client, skillTrainingRequest(proposed)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ restored := newTestInventoryServer(t)
+ for _, state := range []*server{world, restored} {
+ state.clients[1] = &worldClient{id: 1, conn: &combatTestConn{}, ready: true, target: true}
+ connection, peer := net.Pipe()
+ connection.SetDeadline(time.Now().Add(5 * time.Second))
+ done := make(chan struct{})
+ go func() { defer close(done); defer peer.Close(); state.serveWorldConnection(peer) }()
+ t.Cleanup(func() { connection.Close(); <-done })
+ cookie := systemPacket(0x1b, []byte{0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0})
+ binary.BigEndian.PutUint16(cookie, 0xdfdf)
+ if _, err := connection.Write(cookie); err != nil {
+ t.Fatal(err)
+ }
+ var spawn []byte
+ wear, nanos := 0, 0
+ for {
+ packet, err := readPacket(connection)
+ if err != nil {
+ t.Fatal(err)
+ }
+ key := binary.BigEndian.Uint32(packet[16:20])
+ if key == 0x271b3a6b && binary.BigEndian.Uint32(packet[24:28]) == 1 {
+ spawn = packet
+ }
+ if key == 0x35505644 && binary.BigEndian.Uint32(packet[24:28]) == 1 {
+ wear++
+ }
+ if key == 0x5e477770 && binary.BigEndian.Uint32(packet[29:33]) == 177 {
+ nanos++
+ }
+ if key == 0x5f52412e {
+ break
+ }
+ }
+
+ if state.characters[1].stats.Speed.RunSpeed != 256 || state.characters[1].inventory.equipmentBonus(156) != 150 || state.characters[1].nanoBonus(156) != 10 ||
+ len(spawn) < 145 || binary.BigEndian.Uint32(spawn[30:34])&0x2000 == 0 || !bytes.Equal(spawn[143:145], []byte{1, 0}) || wear != 1 || nanos != 1 {
+ t.Fatalf("late actor lost training or counted modifiers in its base: speed=%d wear=%d nanos=%d spawn=%x", state.characters[1].stats.Speed.RunSpeed, wear, nanos, spawn)
+ }
+ connection.Close()
+ <-done
+ }
+}
diff --git a/server/target_protocol.go b/server/target_protocol.go
@@ -49,6 +49,9 @@ func targetPacket(packet []byte) []byte {
vehicle++
}
cursor := vehicle + 4 + int(binary.BigEndian.Uint32(packet[vehicle:])) + 9
+ if flags&0x2000 != 0 {
+ cursor++
+ }
count := int(binary.BigEndian.Uint32(packet[cursor-4:])/1009 - 1)
converted := append([]byte(nil), packet[:cursor]...)
for range count {
diff --git a/server/world.go b/server/world.go
@@ -52,6 +52,14 @@ func characterPacket(character *character) []byte {
// Include playfield and orientation; use the original compact coordinates.
body := []byte{1}
flags := uint32(0x240)
+ // Equipment and nano replay supply modifiers separately from trained RunSpeed.
+ runSpeed := uint16(100)
+ if !character.npc {
+ runSpeed = character.baseStats().Speed.RunSpeed
+ }
+ if runSpeed > 255 {
+ flags |= 0x2000
+ }
human := character.appearance>>4&7 < 6
if character.npc {
flags |= 1
@@ -125,7 +133,12 @@ func characterPacket(character *character) []byte {
head, textures = character.appearanceAssets()
body = binary.BigEndian.AppendUint32(body, head)
}
- body = append(body, 100)
+ // kkr.dll 10083681: flag 0x2000 selects a short instead of an unsigned byte.
+ if flags&0x2000 != 0 {
+ body = binary.BigEndian.AppendUint16(body, runSpeed)
+ } else {
+ body = append(body, byte(runSpeed))
+ }
if human {
// Keep the body materials and replace the hand material with original skin.
if character.npc {