commit a3c0c027bdee5b1893b6dfb3df89ba212194eae3
parent 4c952348ad74b2ebf995bac9a8b69e4824250492
Author: anon <anon@example.com>
Date: Sat, 24 Oct 2026 06:53:10 +0000
Complete native social commands and replicate authored gestures
Diffstat:
5 files changed, 431 insertions(+), 1 deletion(-)
diff --git a/TODO.md b/TODO.md
@@ -572,6 +572,11 @@ disconnect retention and succession policy still need period corroboration.
after stationary mouse turns, keyboard turns, held-W mouse turns, final
release and reconnect. Facing stays in memory until the normal position
checkpoint. Captured layouts, validation and evidence: [movement](docs/movement.md).
+- [ ] Model authoritative swimming transitions. Check: original water boundaries
+ and movement modes agree between the server and native clients, including
+ movement speed, entering/leaving water and action eligibility. The native
+ social-command sender refuses gestures in swimming mode 4; current server
+ movement does not independently establish that mode.
- [x] Enable one verified whom-pah route. Check: its trigger reaches the intended
destination and cannot immediately bounce the player back unintentionally.
- [x] Enter the Grid through one access point. Check: eligibility is enforced
@@ -661,10 +666,21 @@ and unresolved indoor lifecycle are explicit in [flight](docs/vehicles.md#yalmah
## Organizations and social features
-- [ ] Support native gestures and emotes, starting with `/wave`. Check: the
+- [x] Support native gestures and emotes, starting with `/wave`. Check: the
command plays the correct authored animation for the player and nearby
observers; cover repeated gestures, interruption, movement/posture rules,
late observers and unsupported commands without persisting transient poses.
+ Native SocialActionCmd verification preserves changing references and clears
+ owner pending commands without replaying the local animation. Two hardware
+ WASM clients verified repeated wave, bow, seated wave, walking during wave,
+ completion and observer reconnect. Authentication, rejection, enum boundaries,
+ preserved posture/casting and zero SQLite writes have regression coverage.
+ Source and runtime evidence: [gestures](docs/gestures.md).
+- [ ] Identify the native social enum 63 and verify remaining eligibility rules.
+ Check: original evidence establishes its name/resource and any server-side
+ swimming, combat or other restrictions beyond the recovered client paths.
+ The reader permits 1..63 but the named table contains only 1..62; do not
+ invent a gesture, cooldown or posture change for the unresolved entry.
- [ ] Persist a friend-list entry. Check: adding/removing a friend survives
reconnect and the appropriate online-status updates reach the owner.
- [ ] Ignore one player. Check: the supported chat channels honor the saved
diff --git a/docs/gestures.md b/docs/gestures.md
@@ -0,0 +1,133 @@
+# Native gestures and social commands
+
+The original 14.9.1 client starts a gesture locally and sends SocialActionCmd
+(`0x3b290771`). The server completes that command for the owner and observers.
+No animation timer, social enum or pose is persisted or added to join snapshots;
+the native client controls playback, blending and completion.
+
+## Command format and completion
+
+The native IIR prefix has three big-endian uint32 fields (key, subject type,
+subject ID) and a one-byte pass-on flag. The Go dispatcher expands pass-on to
+uint32. Its normalized handler body is exactly 28 bytes:
+
+| Offset | Size | Field |
+| --- | --- | --- |
+| 0 | 4 | Key 0x3b290771 |
+| 4 | 4 | Subject type 50000 |
+| 8 | 4 | Sending character ID |
+| 12 | 4 | Pass-on, incoming 1 and outgoing 0 |
+| 16 | 4 | Command verification, incoming 0 and accepted completion 1 |
+| 20 | 4 | Command reference |
+| 24 | 4 | Social action enum |
+
+All multibyte fields are big endian. Native body length is 25 bytes, giving an
+outer packet length of 41, transmitted with padding to 44 bytes. The reference
+is an incrementing native command counter, not a constant or an execution-state
+flag. Preserve it verbatim, including zero and wraparound.
+
+The native constructor adds each locally originated command reference to a
+pending list. Local activation starts its animation before server completion.
+A verification-1 completion for the matching local subject/reference removes
+that pending entry without starting the animation again. The same completion
+for a foreign subject performs the gesture. Consequently, silently omitting
+an owner acknowledgement leaks pending commands, while merely rebroadcasting
+verification 0 bypasses the native completion protocol.
+
+Verification 2 removes a pending local reference without triggering social
+animation. The social local-execution function itself returns 2 on failure.
+Using that completion for a current but dead, unready or loading player is this
+server's rejection policy; the exact historical enum label and full original
+server policy have not been recovered.
+
+The handler validates owned subject identity, pass-on 1, verification 0,
+exact length, the native enum range 1..63, and the authenticated current
+session. Accepted requests receive verification 1 at the owner and ready
+observers in the same playfield. A replaced session, malformed fields or
+unsupported enum cannot animate another player. Gestures do not change held
+movement, posture, combat or a pending nano cast, and cause no SQLite writes.
+
+## Authored animations and limits
+
+The native name table contains 62 entries, including wave=61, ymca=62 and
+bow=9. Some names are internal aliases; the shipped
+`cd_image/text/help/Social Moves Commands.txt` and `EmoteHelp.txt` document
+player commands. The receiver accepts enum 63, but its usable resource and
+meaning remain unresolved. The handler follows the recovered numeric range
+without inventing a name or a special animation for it.
+
+The sender explicitly refuses social commands while swimming (movement mode
+4). The server does not yet model authoritative water transitions; that broader
+movement work remains in TODO. No additional swimming threshold, gesture
+cooldown, posture restriction or combat restriction is inferred here.
+
+The actor controller stores a social enum for the next update, clears it, and
+asks the native mesh to play the breed/sex-specific animation once. That field
+is a transient request, not the current animation. The recovered social path
+does not force standing or clear movement/combat state. Other renderer paths
+can blend or interrupt animations; the server does not duplicate those timers.
+
+## Source evidence
+
+Original image bases are 0x10000000. Targets under
+`anarchy-vanilla-14.9.1/`:
+
+| Artifact | SHA-256 |
+| --- | --- |
+| kkr.dll | a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0 |
+| llr.dll | ebb09047f6ead192388f7ddfb4795da5013a60f7c2d1c3933ec02eef58a10132 |
+| bbr.dll | 28f196f650edbb1573fb874ccaf7746453d3e4a183e1d86db1d790c1c32ecc2c |
+
+KKR sender is 0x1002b360; social constructor/reader/writer are
+0x10084e20/0x10084fd0/0x10084fa0; local execution/completion are
+0x10084ef0/0x10084f40; enum setter is 0x10050810. SimpleChar update consumes
+the enum at 0x1006f87c and plays it through 0x100185f0. Name registration is
+0x100dda40. LLR base command constructor, activation and reader are
+0x100167d0, 0x100168f0 and 0x100169c0.
+
+The complete ledger, catalog and REA exports are in `local/gesture-research/`.
+Principal evidence IDs:
+`ev_bbdccaa35219cb2606f05d80b1778b4e03b6fa3574022bee97a1cbdcc8b63ae1`
+(sender),
+`ev_3c07ce549cf15ce70d6e3eb31b6af07a34f86f97a073acc6c615fbfdec1c402f`
+(command lifecycle), and
+`ev_2054f0aa439e8c96526ba055122930471aef5259efd1a795362645188b958e9e`
+(reference allocation). These establish client behavior, not the original
+server's undisclosed acceptance policy.
+
+## Verification
+
+`server/social_actions_test.go` covers native framing, captured TCP dispatch,
+owner completion, arbitrary references and repeated commands, enum boundaries,
+malformed and unauthorized requests, stale/dead/loading sessions, observer
+filtering, late joins, unchanged posture/held input/casting, and zero database
+writes through SQLite audit triggers.
+
+Runtime evidence is retained under `local/gesture-smoke/`. Read-only native
+probes follow the actual mesh animation list and the pending-command list;
+they do not call guest functions or modify game memory. LLR's pending count
+is guest 0x3806eac8. QQR/LLR body probes and BBR FindAnim/IsAnimDone determine
+actor facing, animation resources, handles, loop count and raw integer time.
+An animation's started flag alone does not prove it remains active. Repeated
+commands can also restart an existing native handle, so distinct handles are
+not required for valid repetition.
+
+Two hardware Chromium WASM clients verified repeated `/wave`, `/bow`, a seated
+wave, walking during a wave, final idle, an unsupported command and an observer
+reconnect. In this character's authored animation set, both clients played
+wave resource 13089 and bow resource 10153. A seated wave returned to seated
+idle resource 13591; walking used resource 10146 and then returned to standing
+idle. The server introduced no animation cancellation or posture change.
+
+Five actual native requests used references 1..5. Each received one matching
+verification-1 completion at the owner and observer, and native pending-command
+counts stayed at zero after processing. A sampled single wave used one social
+animation handle per client, with no second owner playback after the reply.
+Late observers received no prior gesture. Page errors were empty. The checked
+report is `local/gesture-smoke/verification.json`.
+
+The full Go server suite and focused social/movement/posture race checks pass,
+as does vet with the repository's existing stdversion exception. Test cleanup
+removed only players 33/34 and their four owned chat-history rows; all other
+database rows were unchanged and integrity/foreign-key checks passed. The
+published WASM artifact required no changes.
diff --git a/server/main.go b/server/main.go
@@ -460,6 +460,10 @@ func (server *server) serveWorldClient(client *worldClient) error {
decodeInventory1491(body)
}
switch binary.BigEndian.Uint32(body[0:4]) {
+ case 0x3b290771:
+ if err := server.handleSocialAction(client, body); err != nil {
+ return err
+ }
case 0x36284f6e:
if err := server.handleShopTrade(client, body); err != nil {
return err
diff --git a/server/social_actions.go b/server/social_actions.go
@@ -0,0 +1,40 @@
+package main
+
+import (
+ "encoding/binary"
+ "fmt"
+)
+
+func (server *server) handleSocialAction(client *worldClient, body []byte) error {
+ if len(body) != 28 {
+ return fmt.Errorf("invalid social action length")
+ }
+ // Unverified SocialActionCmd requests carry an arbitrary command reference.
+ action := binary.BigEndian.Uint32(body[24:28])
+ if !client.target || binary.BigEndian.Uint32(body[4:8]) != 50000 || binary.BigEndian.Uint32(body[8:12]) != client.id ||
+ binary.BigEndian.Uint32(body[12:16]) != 1 || binary.BigEndian.Uint32(body[16:20]) != 0 || action < 1 || action > 63 {
+ return nil
+ }
+ server.updateMutex.Lock()
+ defer server.updateMutex.Unlock()
+ server.mutex.Lock()
+ player := server.characters[client.id]
+ if server.clients[client.id] != client {
+ server.mutex.Unlock()
+ return nil
+ }
+ verification := uint32(1)
+ if !client.ready || client.loading || player.health == 0 {
+ verification = 2
+ }
+ playfield := player.playfield
+ server.mutex.Unlock()
+
+ // Verification completes the owner's pending command without replaying it.
+ response := n3Packet(0x3b290771, 50000, client.id, body[16:])
+ binary.BigEndian.PutUint32(response[36:40], verification)
+ if verification == 1 {
+ server.broadcast(playfield, client.id, response)
+ }
+ return client.send(response)
+}
diff --git a/server/social_actions_test.go b/server/social_actions_test.go
@@ -0,0 +1,237 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "encoding/hex"
+ "net"
+ "testing"
+ "time"
+)
+
+func socialActionRequest(action uint32) []byte {
+ // Captured /wave command with the handler's normalized IIR prefix.
+ body, _ := hex.DecodeString("3b2907710000c350000000010000000100000000000000010000003d")
+ binary.BigEndian.PutUint32(body[24:28], action)
+ return body
+}
+
+func TestSocialActionNativeDispatchDoesNotReplayGesturesToLateObservers(t *testing.T) {
+ world := newCheckpointWorld(t)
+ client := connectZoningClient(t, world, true)
+ observer := &combatTestConn{}
+ observerClient := &worldClient{id: 2, target: true, ready: true, conn: observer}
+ world.mutex.Lock()
+ world.newCharacter_locked().playfield = 950
+ world.clients[2] = observerClient
+ world.mutex.Unlock()
+ captured, _ := hex.DecodeString("dfdf000a0001002900000001000000023b2907710000c350000000010100000000000000010000003d000000")
+ ping := systemPacket(1, nil)
+ binary.BigEndian.PutUint16(ping[2:4], 11)
+
+ if _, err := client.Write(captured); err != nil {
+ t.Fatal(err)
+ }
+ client.Write(ping)
+ acknowledgement, err := readPacket(client)
+ if err != nil {
+ t.Fatal(err)
+ }
+ reply, err := readPacket(client)
+ if err != nil {
+ t.Fatal(err)
+ }
+ world.mutex.Lock()
+ world.newCharacter_locked().playfield = 950
+ world.mutex.Unlock()
+ late, peer := net.Pipe()
+ defer late.Close()
+ late.SetDeadline(time.Now().Add(5 * time.Second))
+ go func() { defer peer.Close(); world.serveWorldConnection(peer) }()
+ cookie, _ := hex.DecodeString("dfdf00010001002000000003000000020000001b000000030000000000000000")
+ late.Write(cookie)
+ var keys []uint32
+ for {
+ packet, err := readPacket(late)
+ if err != nil {
+ t.Fatal(err)
+ }
+ key := binary.BigEndian.Uint32(packet[16:20])
+ keys = append(keys, key)
+ if key == 0x5f52412e {
+ break
+ }
+ }
+
+ if binary.BigEndian.Uint32(acknowledgement[16:20]) != 0x3b290771 || binary.BigEndian.Uint32(acknowledgement[29:33]) != 1 || binary.BigEndian.Uint32(acknowledgement[33:37]) != 1 {
+ t.Fatalf("owner did not complete the native command: %x", acknowledgement)
+ }
+ if binary.BigEndian.Uint16(reply[2:4]) != 11 {
+ t.Fatalf("owner received an extra gesture response instead of its ping: %x", reply)
+ }
+ observerClient.mutex.Lock()
+ received := len(observer.packets) != 0 && binary.BigEndian.Uint32(observer.packets[0][16:20]) == 0x3b290771
+ observerClient.mutex.Unlock()
+ if !received {
+ t.Fatal("native request did not reach the social-action handler")
+ }
+ for _, key := range keys {
+ if key == 0x3b290771 {
+ t.Fatal("late observer replayed a transient gesture")
+ }
+ }
+}
+
+func TestSocialActionCompletesNativeCommandsWithoutDatabaseWrites(t *testing.T) {
+ world := newCheckpointWorld(t)
+ owner, observer := &combatTestConn{}, &combatTestConn{}
+ client := &worldClient{id: 1, target: true, ready: true, conn: owner}
+ world.clients[1] = client
+ world.characters[2] = &character{id: 2, playfield: 950, health: 100}
+ world.clients[2] = &worldClient{id: 2, target: true, ready: true, conn: observer}
+ auditCheckpointWrites(t, world)
+
+ for index, action := range []uint32{1, 61, 61, 63} {
+ body := socialActionRequest(action)
+ binary.BigEndian.PutUint32(body[20:24], []uint32{0, 1, 2, 0xffffffff}[index])
+ if err := world.handleSocialAction(client, body); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ if len(owner.packets) != 4 || len(observer.packets) != 4 {
+ t.Fatalf("gesture replies owner=%d observer=%d", len(owner.packets), len(observer.packets))
+ }
+ for index, action := range []uint32{1, 61, 61, 63} {
+ expected := socialActionRequest(action)
+ binary.BigEndian.PutUint32(expected[16:20], 1)
+ binary.BigEndian.PutUint32(expected[20:24], []uint32{0, 1, 2, 0xffffffff}[index])
+ for _, packet := range [][]byte{owner.packets[index], observer.packets[index]} {
+ if len(packet) != 44 || binary.BigEndian.Uint16(packet[6:8]) != 41 ||
+ binary.BigEndian.Uint32(packet[16:20]) != 0x3b290771 || binary.BigEndian.Uint32(packet[24:28]) != 1 ||
+ packet[28] != 0 || !bytes.Equal(packet[29:41], expected[16:28]) {
+ t.Fatalf("native gesture fields: %x", packet)
+ }
+ }
+ }
+ if writes := checkpointWrites(t, world); len(writes) != 0 {
+ t.Fatalf("gesture rewrote durable state: %v", writes)
+ }
+}
+
+func TestSocialActionRejectsMalformedUnauthorizedAndUnsupportedRequests(t *testing.T) {
+ for _, scenario := range []string{"short prefix", "short command", "trailing data", "foreign owner", "wrong type", "wrong pass-on", "verified response", "unknown verification", "zero action", "unknown action", "replaced", "unready", "loading", "dead", "unsupported client"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, owner := newCombatWorld()
+ client := world.clients[1]
+ observer := &combatTestConn{}
+ world.characters[2] = &character{id: 2, playfield: 950, health: 100}
+ world.clients[2] = &worldClient{id: 2, target: true, ready: true, conn: observer}
+ body := socialActionRequest(61)
+ malformed := false
+ switch scenario {
+ case "short prefix":
+ body, malformed = body[:12], true
+ case "short command":
+ body, malformed = body[:27], true
+ case "trailing data":
+ body, malformed = append(body, 0), true
+ case "foreign owner":
+ binary.BigEndian.PutUint32(body[8:12], 2)
+ case "wrong type":
+ binary.BigEndian.PutUint32(body[4:8], 51035)
+ case "wrong pass-on":
+ binary.BigEndian.PutUint32(body[12:16], 0)
+ case "verified response":
+ binary.BigEndian.PutUint32(body[16:20], 1)
+ case "unknown verification":
+ binary.BigEndian.PutUint32(body[16:20], 6)
+ case "zero action":
+ binary.BigEndian.PutUint32(body[24:28], 0)
+ case "unknown action":
+ binary.BigEndian.PutUint32(body[24:28], 64)
+ case "replaced":
+ world.clients[1] = &worldClient{id: 1}
+ case "unready":
+ client.ready = false
+ case "loading":
+ client.loading = true
+ case "dead":
+ world.characters[1].health = 0
+ case "unsupported client":
+ client.target = false
+ }
+ before := world.characters[1].vitals()
+
+ err := world.handleSocialAction(client, body)
+
+ rejected := scenario == "unready" || scenario == "loading" || scenario == "dead"
+ expectedReplies := 0
+ if rejected {
+ expectedReplies = 1
+ }
+ if (err != nil) != malformed || len(owner.packets) != expectedReplies || len(observer.packets) != 0 || world.characters[1].vitals() != before {
+ t.Fatalf("invalid gesture changed state: error=%v owner=%d observer=%d", err, len(owner.packets), len(observer.packets))
+ }
+ if rejected && (binary.BigEndian.Uint32(owner.packets[0][29:33]) != 2 || binary.BigEndian.Uint32(owner.packets[0][33:37]) != 1) {
+ t.Fatal("rejected gesture did not finish its owner's pending command")
+ }
+ })
+ }
+}
+
+func TestSocialActionExcludesOtherPlayfieldsAndUnreadyObservers(t *testing.T) {
+ for _, scenario := range []string{"other playfield", "unready observer"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, owner := newCombatWorld()
+ observer := &combatTestConn{}
+ world.characters[2] = &character{id: 2, playfield: 950, health: 100}
+ world.clients[2] = &worldClient{id: 2, target: true, ready: true, conn: observer}
+ if scenario == "other playfield" {
+ world.characters[2].playfield = 705
+ } else {
+ world.clients[2].ready = false
+ }
+
+ err := world.handleSocialAction(world.clients[1], socialActionRequest(61))
+
+ if err != nil || len(owner.packets) != 1 || len(observer.packets) != 0 {
+ t.Fatal("gesture reached an unavailable observer")
+ }
+ })
+ }
+}
+
+func TestSocialActionKeepsPostureAndHeldMovement(t *testing.T) {
+ world, _ := newCombatWorld()
+ player, client := world.characters[1], world.clients[1]
+ player.sitting, player.running = true, true
+ client.forward, client.strafing, client.turning = 1, true, true
+
+ err := world.handleSocialAction(client, socialActionRequest(61))
+
+ if err != nil || !player.sitting || !player.running || client.forward != 1 || !client.strafing || !client.turning {
+ t.Fatal("gesture changed posture or held movement")
+ }
+}
+
+func TestSocialActionDoesNotInterruptAnAdmittedNano(t *testing.T) {
+ world, _ := newNanoCastingWorld(t)
+ client := world.clients[1]
+ if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, 1000000, 53019, 29618})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if client.nanoCast == nil {
+ t.Fatal("cast was not admitted")
+ }
+ deadline := client.nanoCast.readyAt
+
+ if err := world.handleSocialAction(client, socialActionRequest(61)); err != nil {
+ t.Fatal(err)
+ }
+ world.advanceNanos(deadline.Add(time.Nanosecond))
+
+ if world.characters[1000000].health >= 100 || world.characters[1].nano != 21 || client.nanoCast != nil {
+ t.Fatal("gesture changed the admitted nano outcome")
+ }
+}