aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 40eb4da0e52e918a735e4868fed099f486e1eb73
parent 0a87efbac73a313099f765dbf7a8f4d8cd616f58
Author: anon <anon@example.com>
Date:   Thu, 22 Oct 2026 20:43:42 +0000

Enable the authored Entertainment Trade whom-pah route

Diffstat:
MTODO.md | 9+++++++--
Mdocs/zoning.md | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/assets/zone_links.yaml | 8++++++++
Aserver/whompah_test.go | 140+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/zoning.go | 20++++++++++++++++++++
Atools/data/extract_whompahs.py | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 329 insertions(+), 2 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -336,7 +336,7 @@ checks are recorded in [treatment kits](docs/treatment-kit.md). ## Travel -- [ ] Enable one verified whom-pah route. Check: its trigger reaches the intended +- [x] Enable one verified whom-pah route. Check: its trigger reaches the intended destination and cannot immediately bounce the player back unintentionally. - [ ] Enter the Grid through one access point. Check: eligibility is enforced and the native client arrives in the correct playfield. @@ -346,9 +346,14 @@ checks are recorded in [treatment kits](docs/treatment-kit.md). under the applicable requirements and ending use restores ordinary movement. - [ ] Use one flying vehicle. Check: altitude and movement modes replicate to an observer and zoning does not leave the character stuck in the wrong mode. -- [ ] Resolve one currently unmapped door. Check: source evidence identifies its +- [x] Resolve one currently unmapped door. Check: source evidence identifies its eligibility and destination, and a real client can make the round trip. +The Entertainment/Trade whom-pah connection resolves the selected unmapped +LineTeleport doors in both directions. Shipped route evidence, native entry +checks, arrival-policy limits and WASM verification are in +[doors and zoning](docs/zoning.md#1491-whom-pah-route). + ## Pets - [ ] Summon one pet. Check: one owned entity appears to its owner and an diff --git a/docs/zoning.md b/docs/zoning.md @@ -52,6 +52,89 @@ packed IDs. Its 47-byte records are not a complete fixed shop routing table. Apartment ownership, missions, keys and similar server assignments remain separate from the fixed links. +## 14.9.1 whom-pah route + +The selected client authors an unconditional Entertainment/Trade connection +using template 96272, `Dummy wompah noselect`. Both type-51016 statels have a +leading OnEnter event 16 with one `LineTeleport` function 53059, no function +requirements, tick count 1, interval 0 and target 2. This differs from the +TeleportProxy 53082 shop-door path above. Only these two LineTeleport doors +are enabled; other whom-pahs remain unmapped. + +| Source playfield / door | Door XYZ | Destination / packed line | +| --- | --- | --- | +| Entertainment 705 / `0xc00502c1` | 910.119995, 16.823326, 484.509857 | Trade 710 / `0x000302c6` | +| Trade 710 / `0xc00002c6` | 381.609741, 17.423323, 382.134918 | Entertainment 705 / `0x000802c1` | + +The function's first authored argument is 100001. Its next two values match +the destination's packed arrival-line identity and playfield. The fourth word +is zero in both selected records; its wider meaning is unresolved. Resource +1000001 supplies Trade line 3 from `[388,17,384]` to +`[388,17,380.969971]`, and Entertainment line 8 from +`[908,16.4,492.003967]` to `[912,16.4,492.003662]`. These are arrival lines, +not destination door indices. + +Regenerate the selected source records and proposed arrivals with +`python3 tools/data/extract_whompahs.py`. The output, +`local/reports/whompahs-14.9.1.json`, retains statel and destination-payload +digests, full descriptors and index digest +`46e5dc54af9358cc9bff05f4358e86af630e497bc677f361c133c88073b84d71`. +Review its two routes against the target entries in +`server/assets/zone_links.yaml`; the extractor does not rewrite unrelated links. + +The native 14.9.1 handler `kkr.dll 0x100c1d10` ignores the destination arguments +and starts a teleport attempt through `0x10027c60`, emitting action 20 without +a destination. Ordinary local effect dispatch gates function 53059 off; +this handler alone does not establish every caller's entry path. The server +continues checking actual/predicted movement against mapped triggers rather +than accepting a client-supplied destination. + +Door collision `0x1008d330` calls the plane predicate `0x1008d690`: rotate +local +Z by the door quaternion and require absolute signed distance strictly +less than float32 0.8 metres. Entered-set handling `0x1008de80` dispatches +event 16 once. This follows native collision processing and does not establish +the full doorway footprint. These addresses use original base `0x10000000` +in shipped `kkr.dll`, SHA-256 +`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`. +Exact source and byte references are in +`local/whompah-smoke/native-source-audit.json`. + +The route uses that strict plane check inside the existing provisional +two-metre horizontal/eight-metre vertical entrance envelope. Arrival uses +the authored line's midpoint, adds the existing half-metre human clearance, +and faces along its left normal, away from the entrance. The line, door pose +and unconditional function are shipped evidence; midpoint selection, clearance +and heading remain reconstruction policy. They place arrivals outside the +doorway trigger and clear shared-interior return context. No unverified fare, +level or Computer Literacy requirement has been added. + +A [March 24, 2002 player account](https://arstechnica.com/civis/threads/perpetual-how-i-did-on-rubi-ka-1-last-night-thread.841242/?thutp_user_id=21599) +independently directs travel from Entertainment to Trade by stepping into the +southern set of whom-pahs along Entertainment's east wall. This supports the +route and entry interaction, while the exact 14.9.1 records establish the +selected endpoint identities. The retained source ledger is +`local/whompah-smoke/source-ledger.json`. + +`TestWhomPah*` verifies the two embedded mappings, continuous predicted entry, +the strict front/back plane boundary, the provisional entrance envelope, +dead/loading/unready rejection, stale-session input, position persistence, +cleared interior context and exactly one native teleport/redirect per leg. +The full server suite and five race-enabled runs pass. + +Two WASM clients verified the route with ordinary movement input. The traveler +walked forward into the Entertainment entrance and arrived in Trade at +`[388,17.5,382.485]`, without an immediate return. The Entertainment observer's +read-only native entity lookup changed from a valid traveler actor to none. +After the normal position-save interval, a server restart and page reload +retained the traveler in Trade. Backward movement through Trade's entrance +returned it to `[910,16.9,492.0038]`; the observer's native lookup again found +that actor. Both arrivals remained stable while idle, and the shared-interior +return context stayed empty. There were no page exceptions or adapter +failures; connection refusals occurred only during the deliberate restart. +The driver closed both browser contexts and its Go server. Logs, screenshots, +fixture sources, binary digest and checks are retained in +`local/whompah-smoke/`. + ## Outdoor boundaries Resource **1000021** contains closed vertex groups. Each 16-byte vertex is diff --git a/server/assets/zone_links.yaml b/server/assets/zone_links.yaml @@ -72149,6 +72149,10 @@ target: - id: 3221553857 position: [910.1199951171875, 16.823326110839844, 484.5098571777344] rotation: [0.0, 0.0, 0.0, 1.0] + destination: 710 + arrival: + position: [388.0, 17.5, 382.4849853515625] + rotation: [0, 0.7071067811865475, 0, 0.7071067811865476] - id: 3221750465 position: [895.7901611328125, 16.823326110839844, 470.12017822265625] rotation: [0.0, -0.70710289478302, 0.0, 0.7071106433868408] @@ -72246,6 +72250,10 @@ target: - id: 3221226182 position: [381.6097412109375, 17.423322677612305, 382.1349182128906] rotation: [0.0, 0.7009105682373047, 0.0, 0.713249146938324] + destination: 705 + arrival: + position: [910.0, 16.899999618530273, 492.0038146972656] + rotation: [0, 3.814697257298327e-05, 0, 0.9999999992724042] - id: 3221291718 position: [359.7119140625, 17.423322677612305, 369.4801940917969] rotation: [0.0, 0.968146562576294, 0.0, -0.250384122133255] diff --git a/server/whompah_test.go b/server/whompah_test.go @@ -0,0 +1,140 @@ +package main + +import ( + "encoding/binary" + "math" + "testing" + "time" +) + +func newWhomPahWorld(t *testing.T) (*server, *combatTestConn) { + t.Helper() + world, conn := newCombatWorld() + player := world.newCharacter() + player.playfield = 705 + player.position = [3]float32{910.12, 16.9, 487.01} + player.returnDoor = &doorOrigin{1183, 0xc000049f} + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + world.zoneLinks = map[string]map[uint32]zoneLinks{"target": { + 705: {Doors: []zoneDoor{{ID: 0xc00502c1, Position: [3]float32{910.12, 16.823326, 484.50986}, Rotation: [4]float32{0, 0, 0, 1}, Destination: 710, + Arrival: &zoneArrival{Position: [3]float32{388, 17.5, 382.484985}, Rotation: [4]float32{0, 0.70710677, 0, 0.70710677}}}}}, + 710: {Doors: []zoneDoor{{ID: 0xc00002c6, Position: [3]float32{381.60974, 17.423323, 382.13492}, Rotation: [4]float32{0, 0.70091057, 0, 0.71324915}, Destination: 705, + Arrival: &zoneArrival{Position: [3]float32{910, 16.9, 492.003815}, Rotation: [4]float32{0, 0.000038147, 0, 1}}}}}, + }} + return world, conn +} + +func TestWhomPahAuthoredRouteMappings(t *testing.T) { + links, err := readZoneLinks() + if err != nil { + t.Fatal(err) + } + + var routes []zoneDoor + for _, source := range []struct{ playfield, door uint32 }{{705, 0xc00502c1}, {710, 0xc00002c6}} { + for _, door := range links["target"][source.playfield].Doors { + if door.ID == source.door { + routes = append(routes, door) + } + } + } + + if len(routes) != 2 || routes[0].Destination != 710 || routes[1].Destination != 705 || routes[0].Arrival == nil || routes[1].Arrival == nil { + t.Fatal("shipped Entertainment/Trade route is not mapped in both directions") + } + if routes[0].Arrival.Position != [3]float32{388, 17.5, 382.484985} || routes[1].Arrival.Position != [3]float32{910, 16.9, 492.003815} || + routes[0].Return || routes[1].Return || routes[0].DestinationDoor != 0 || routes[1].DestinationDoor != 0 { + t.Fatal("line arrivals were confused with shared-interior door destinations") + } +} + +func TestWhomPahHeldMovementRoundTripPersistsWithoutBouncing(t *testing.T) { + t.Chdir(t.TempDir()) + world, first := newWhomPahWorld(t) + player, old := world.characters[1], world.clients[1] + now := time.Now() + old.forward, old.movementStarted = -1, now + + world.advanceZoneCrossings(now.Add(1500 * time.Millisecond)) + if player.playfield != 710 || player.position != [3]float32{388, 17.5, 382.484985} || player.returnDoor != nil { + t.Fatal("held movement failed to reach the Trade arrival line") + } + if err := world.flushPositions(now.Add(20 * time.Second)); err != nil { + t.Fatal(err) + } + if restored := newTestInventoryServer(t).characters[1]; restored.playfield != 710 || restored.position != player.position || restored.returnDoor != nil { + t.Fatal("Trade arrival did not survive restart") + } + second := &combatTestConn{} + world.clients[1] = &worldClient{id: 1, conn: second, target: true, ready: true} + stale := npcMovementPacket(player, 20)[20:] + stale = append(stale[:16:16], encodeMovement1491(stale[16:])...) + if err := world.handleMovement(old, stale); err != nil { + t.Fatal(err) + } + if err := world.handleMovement(world.clients[1], stale); err != nil || player.playfield != 710 || len(second.packets) != 0 { + t.Fatal("arrival or stale session immediately restarted zoning") + } + player.position = [3]float32{381.60974, 17.5, 382.13492} + returnMove := npcMovementPacket(player, 20)[20:] + returnMove = append(returnMove[:16:16], encodeMovement1491(returnMove[16:])...) + if err := world.handleMovement(world.clients[1], returnMove); err != nil { + t.Fatal(err) + } + if err := world.flushPositions(now.Add(40 * time.Second)); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if restored.playfield != 705 || restored.position != [3]float32{910, 16.9, 492.003815} || restored.returnDoor != nil { + t.Fatal("return trip lost the Entertainment arrival or retained an interior return context") + } + for _, conn := range []*combatTestConn{first, second} { + if len(conn.packets) != 2 || binary.BigEndian.Uint32(conn.packets[0][16:20]) != 0x43197d22 || binary.BigEndian.Uint32(conn.packets[1][16:20]) != 0x3c { + t.Fatal("route did not produce exactly one native teleport and redirect per leg") + } + } +} + +func TestWhomPahDoorPlaneAndSessionEligibility(t *testing.T) { + for _, scenario := range []struct { + name string + position [3]float32 + arrives bool + }{ + {"inside front plane", [3]float32{0, 0, math.Nextafter32(0.8, 0)}, true}, + {"front plane equality", [3]float32{0, 0, 0.8}, false}, + {"inside back plane", [3]float32{0, 0, -math.Nextafter32(0.8, 0)}, true}, + {"back plane equality", [3]float32{0, 0, -0.8}, false}, + {"outside horizontal envelope", [3]float32{2, 0, 0}, false}, + {"outside vertical envelope", [3]float32{0, 8, 0}, false}, + {"dead", [3]float32{}, false}, + {"loading", [3]float32{}, false}, + {"not ready", [3]float32{}, false}, + } { + t.Run(scenario.name, func(t *testing.T) { + t.Chdir(t.TempDir()) + world, _ := newWhomPahWorld(t) + world.zoneLinks["target"][705].Doors[0].Position = [3]float32{} + world.characters[1].position = scenario.position + client := world.clients[1] + client.forward, client.movementStarted = 1, time.Now() + switch scenario.name { + case "dead": + world.characters[1].health = 0 + case "loading": + client.loading = true + case "not ready": + client.ready = false + } + + world.advanceZoneCrossings(client.movementStarted) + + if (world.characters[1].playfield == 710) != scenario.arrives { + t.Fatal("door plane or player eligibility disagrees with the selected policy") + } + }) + } +} diff --git a/server/zoning.go b/server/zoning.go @@ -21,6 +21,13 @@ type zoneDoor struct { Destination uint32 `yaml:"destination"` DestinationDoor uint32 `yaml:"destination_door"` Return bool `yaml:"return"` + + Arrival *zoneArrival `yaml:"arrival"` +} + +type zoneArrival struct { + Position [3]float32 `yaml:"position"` + Rotation [4]float32 `yaml:"rotation"` } type zoneWall struct { @@ -75,6 +82,19 @@ func (server *server) zoneDestination_locked(character *character, client *world } } if selected != nil { + if selected.Arrival != nil { + // Check the door plane before using the authored arrival line. + x, y, z, w := selected.Rotation[0], selected.Rotation[1], selected.Rotation[2], selected.Rotation[3] + dx, dy, dz := character.position[0]-selected.Position[0], character.position[1]-selected.Position[1], character.position[2]-selected.Position[2] + plane := dx*(2*x*z+2*y*w) + dy*(2*y*z-2*x*w) + dz*(1-2*x*x-2*y*y) + if math.Abs(float64(plane)) >= float64(float32(0.8)) { + return nil + } + destination := character.userData() + destination.Playfield, destination.Position, destination.Rotation = selected.Destination, selected.Arrival.Position, selected.Arrival.Rotation + destination.ReturnDoor = nil + return &destination + } origin := doorOrigin{character.playfield, selected.ID} destinationPlayfield, destinationDoor := selected.Destination, selected.DestinationDoor if selected.Return && character.returnDoor != nil { diff --git a/tools/data/extract_whompahs.py b/tools/data/extract_whompahs.py @@ -0,0 +1,71 @@ +import hashlib +import json +import math +import pathlib +import struct + +import ao_database + + +def destination_lines(payload, playfield): + # The playfield ends with packed identities and two XYZ endpoints per line. + candidates = [] + for count in range(min(256, (len(payload) - 4) // 28) + 1): + offset = len(payload) - 4 - count * 28 + if struct.unpack_from('<I', payload, offset)[0] != count: + continue + lines = [struct.unpack_from('<I6f', payload, offset + 4 + i * 28) for i in range(count)] + if all(line[0] & 65535 == playfield and line[0] >> 24 == 0 for line in lines): + candidates.append(lines) + assert len(candidates) == 1, (playfield, len(candidates)) + return {line[0]: (list(line[1:4]), list(line[4:7])) for line in candidates[0]} + + +def main(): + client = pathlib.Path('anarchy-vanilla-14.9.1') + assert (client / 'version.id').read_text().strip() == '14.9.1' + database = ao_database.Database(client) + routes = [] + for playfield, door_id in [(705, 0xc00502c1), (710, 0xc00002c6)]: + # Retain only the selected authored, unconditional LineTeleport doors. + payload = database.read(1000026, playfield) + offset = 4 + for _ in range(struct.unpack_from('<I', payload)[0]): + size = struct.unpack_from('<I', payload, offset)[0] + offset += 4 + raw = payload[offset:offset + size] + offset += size + assert len(raw) == size and size == 64 + struct.unpack_from('<I', raw, 60)[0] + if struct.unpack_from('<II', raw) != (51016, door_id): + continue + assert struct.unpack_from('<I', raw, 56)[0] == 96272 + descriptor = raw[64:] + assert struct.unpack_from('>16I', descriptor) == (102, 103, 1009, 3, 2, 16, 2018, 53059, 0, 4, 0, 1, 0, 2, 0, 100001) + packed, destination, opaque = struct.unpack_from('>3I', descriptor, 64) + assert packed & 65535 == destination and opaque == 0 + destination_payload = database.read(1000001, destination) + start, end = destination_lines(destination_payload, destination)[packed] + + # Midpoint, human clearance and facing away are reconstruction policy. + arrival = [(first + second) / 2 for first, second in zip(start, end)] + arrival[1] += 0.5 + heading = math.atan2(start[2] - end[2], end[0] - start[0]) + routes.append(dict(playfield=playfield, door=door_id, position=list(struct.unpack_from('<3f', raw, 24)), + rotation=list(reversed(struct.unpack_from('<4f', raw, 36))), + destination=destination, destination_line=packed >> 16, arrival_start=start, arrival_end=end, + arrival=dict(position=arrival, rotation=[0, math.sin(heading / 2), 0, math.cos(heading / 2)]), + record_sha256=hashlib.sha256(raw).hexdigest(), descriptor_hex=descriptor.hex(), + destination_sha256=hashlib.sha256(destination_payload).hexdigest())) + assert offset == len(payload) + database.close() + assert len(routes) == 2 + + # Review these values against the two target entries in zone_links.yaml. + output = pathlib.Path('local/reports/whompahs-14.9.1.json') + output.parent.mkdir(parents=True, exist_ok=True) + output.write_text(json.dumps(dict(index_sha256=hashlib.sha256(database.index).hexdigest(), routes=routes), indent=2) + '\n') + print(output) + + +if __name__ == '__main__': + main()