aorecomp

Anarchy Online classic in the browser

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


commit 4293a14a4a7b9136fd9f0466f20b9a7acdbf026b
parent 40eb4da0e52e918a735e4868fed099f486e1eb73
Author: anon <anon@example.com>
Date:   Thu, 22 Oct 2026 21:05:18 +0000

Enable the authored Borealis Grid round trip

Diffstat:
MTODO.md | 10++++++++--
Mdocs/zoning.md | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/grid_test.go | 163+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/insurance.go | 27++++++++++++++++++++++++---
Mserver/zoning.go | 15+++++++++++++++
Atools/data/extract_grid.py | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 358 insertions(+), 5 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -338,9 +338,9 @@ checks are recorded in [treatment kits](docs/treatment-kit.md). - [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 +- [x] Enter the Grid through one access point. Check: eligibility is enforced and the native client arrives in the correct playfield. -- [ ] Leave the Grid through one exit. Check: the exit's requirements and +- [x] Leave the Grid through one exit. Check: the exit's requirements and destination are correct and the character remains usable after reconnect. - [ ] Use one ground vehicle. Check: equipping/using it changes movement speed under the applicable requirements and ending use restores ordinary movement. @@ -354,6 +354,12 @@ 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). +The Borealis ordinary Grid terminal and return beam enforce effective Computer +Literacy above 90. Two WASM clients verified denial at 90, entry at 91, native +Grid form, restart persistence, exit and usable reconnect. Authored records +and the provisional exit envelope are in +[the Borealis Grid route](docs/zoning.md#1491-borealis-grid-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 @@ -256,3 +256,87 @@ door `0xc01102c1`, then returning to that same entrance. A separate windowed client also walked into the outdoor portal near `[1025, 16.4, 505]`, loaded Omni Forest (716), and subsequently reported coordinates near `[217.625, 9.81, 2307.875]`, consistent with the paired arrival line. + +## 14.9.1 Borealis Grid route + +Borealis SimpleItem `51005:0xc0040320`, template 95350, has an OnUse event +with TeleportProxy2 function 53083. Its requirements are stat 410 equal to +zero AND Computer Literacy 161 strictly greater than 90. The accompanying +text explicitly says "91 or better" and rejects use during combat. The +ordinary Grid's Borealis exit `51005:0xc04c0098`, template 95351, runs +LineTeleport 53059 on collision (event 3), also requiring CL > 90. These +are effective skills including Intelligence trickle-down, rather than the +trained values alone. + +| Trigger | Authored XYZ | Destination / packed arrival line | +| --- | --- | --- | +| Borealis 800 terminal | 636.402588, 66.810020, 728.809387 | Grid 152 / `0x00260098` | +| Grid 152 exit beam | 242.313232, 4.199992, 199.412231 | Borealis 800 / `0x000e0320` | + +The entry's seven arguments are `51102,152,0,0,100001,0x00260098,500`; +`kkr.dll 0x100bc1f5` reads all seven DWORDs into native keys 94 through 100. +The last word's meaning and units remain unknown. No fee or delay is inferred +from it. The exit arguments are `100001,0x000e0320,800,0`. The template's +separate conditional Fixer Grid route does not describe this statel's ordinary +OnUse route and is not enabled here. + +Run `python3 tools/data/extract_grid.py` to reproduce the exact requirements, +functions, arguments, complete descriptors and arrival endpoints in +`local/reports/grid-14.9.1.json`. The selected entry record SHA-256 is +`d32016540207410a9f9d8313949b64b8559dcbf31364f7e78bab5c164fed3ed8`; +the exit record is +`0fcb1ff28740922bd5101b17dc6f832df0d8a3c8bb26cc58cc2a93a48ed44202`. +The index and original kkr.dll digests match the whom-pah evidence above. +Native procedure references and original bytes are retained in +`local/grid-smoke/native-source-audit.json`. + +Use sends the existing native GenericCmd action 3 with the statel identity. +A successful acknowledgement precedes the normal teleport and redirect. +The native client recognizes the Grid from the playfield's district name +"Grid". Original `llr.dll n3Playfield_t::AddChildDynel`, at `0x1002a1b1`, +calls virtual slot +0x54; `kkr.dll 0x1006e930` applies vehicle feature 0x800 +and model 99902. This happens on normal actor attachment and clears on exit; +no additional invented form message is needed. The native attachment audit +is `local/grid-smoke/native-grid-form-attachment.json`. + +Arrival uses the same explicit midpoint, half-metre human clearance and +left-normal heading policy as the whom-pah route: Grid +`[242.3208,4.6000195,193.26456]`, Borealis +`[620.773,67.30926,720.8844]`. Both clear interior return context. Terminal +range uses the existing five-metre use policy. The exit uses a provisional +two-metre three-dimensional envelope around its authored beam; the full +collision footprint of mesh 90549 is unresolved. The existing combat policy +rejects outgoing and incoming attacks; the exact original server producer +of stat 410 is unresolved. Grid-specific movement speed remains unverified. +These reconstruction policies should not be mistaken for recovered server +code. + +`TestGrid*` checks the strict 90/91 skill boundary, combat, use distance and +height, wrong world/object/client, dead/loading/unready sessions, stale Use, +continuous backward entry into the exit, persisted arrivals, cleared return +context and one teleport/redirect per leg. + +Shipped `cd_image/text/TipOfTheDay.txt:172` confirms that Grid travel requires +Computer Literacy. A [May 22, 2001 firsthand demonstration report](https://www.gamespot.com/articles/e3-2001-hands-onanarchy-online/1100-2762459/) +describes access kiosks and blue pyramid avatars. That report concerns a +prelaunch build; the exact 14.9.1 scripts and native form code above establish +this implementation's thresholds and form. The independent historical ledger +is `local/grid-smoke/source-ledger.json`. + +Two WASM clients exercised the native terminal Use command at effective CL 90 +and 91: the first stayed in Borealis while the second entered Grid 152 at the +authored arrival. A read-only native stat lookup found model 99902 and vehicle +features 0x806; the Borealis observer lost the traveler from its native dynel +directory. After the normal save interval, a server restart and page reload +retained the Grid arrival and native form. Ordinary backward movement reached +the Borealis beam and returned to the authored outdoor position. Native model +359 cleared to zero, feature 0x800 cleared, and the observer again resolved +the traveler. Another reconnect retained Borealis, and ordinary movement still +worked. Both inventories and health were preserved. The isolated run retained +20 evidence checks, screenshots, packet logs, fixture digest and expected +restart connection errors in `local/grid-smoke/verification.json`. No native +adapter error occurred; all test clients and the temporary server were closed. + +The maintained full server suite passed in 91.025 seconds. Five race-enabled +passes covering Grid travel, shared terminal rejection/sequencing and the +whom-pah round trip passed in 99.392 seconds. diff --git a/server/grid_test.go b/server/grid_test.go @@ -0,0 +1,163 @@ +package main + +import ( + "encoding/binary" + "testing" + "time" +) + +func newGridWorld(t *testing.T) (*server, *combatTestConn) { + t.Helper() + world, conn := newCombatWorld() + player := world.newCharacter() + player.playfield = 800 + player.position = [3]float32{637, 67.3, 728} + player.stats.ComputerLiteracy = 89 // Effective 91 with Intelligence 10. + player.returnDoor = &doorOrigin{1183, 0xc000049f} + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + return world, conn +} + +func gridUseRequest(sequence uint32) []byte { + request := insuranceUseRequest(sequence)[20:] + binary.BigEndian.PutUint32(request[44:48], 0xc0040320) + return request +} + +func TestGridTerminalEntersTheOrdinaryGridAndPersists(t *testing.T) { + t.Chdir(t.TempDir()) + world, conn := newGridWorld(t) + client := world.clients[1] + + if err := world.handleTerminalUse(client, gridUseRequest(1)); err != nil { + t.Fatal(err) + } + if err := world.flushPositions(time.Now().Add(20 * time.Second)); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if restored.playfield != 152 || restored.position != [3]float32{242.3208, 4.6000195, 193.26456} || restored.returnDoor != nil || len(conn.packets) != 3 || + binary.BigEndian.Uint32(conn.packets[0][16:20]) != 0x52526858 || binary.BigEndian.Uint32(conn.packets[0][29:33]) != 1 || + binary.BigEndian.Uint32(conn.packets[1][16:20]) != 0x43197d22 || binary.BigEndian.Uint32(conn.packets[2][16:20]) != 0x3c { + t.Fatal("ordinary Grid use did not acknowledge and persist one native teleport") + } +} + +func TestGridTerminalRejectsIneligibleUse(t *testing.T) { + for _, scenario := range []string{"skill 90", "outgoing combat", "incoming combat", "distance", "height", "wrong playfield", "original client", "dead", "loading", "not ready", "stale session", "wrong identity"} { + t.Run(scenario, func(t *testing.T) { + t.Chdir(t.TempDir()) + world, conn := newGridWorld(t) + player, client := world.characters[1], world.clients[1] + request := gridUseRequest(1) + switch scenario { + case "skill 90": + player.stats.ComputerLiteracy = 88 + case "outgoing combat": + player.fighting = 1000000 + case "incoming combat": + world.characters[1000000].fighting = 1 + world.fighting[1000000] = world.characters[1000000] + case "distance": + player.position[0] += 6 + case "height": + player.position[1] += 6 + case "wrong playfield": + player.playfield = 705 + case "original client": + client.target = false + case "dead": + player.health = 0 + case "loading": + client.loading = true + case "not ready": + client.ready = false + case "stale session": + world.clients[1] = &worldClient{id: 1} + case "wrong identity": + binary.BigEndian.PutUint32(request[44:48], 0xc0040321) + } + before := player.playfield + + if err := world.handleTerminalUse(client, request); err != nil { + t.Fatal(err) + } + + stateOffset := 29 + if !client.target { + stateOffset = 36 + } + if player.playfield != before || len(conn.packets) > 1 || len(conn.packets) == 1 && binary.BigEndian.Uint32(conn.packets[0][stateOffset:stateOffset+4]) != 2 { + t.Fatal("ineligible terminal use teleported or acknowledged success") + } + }) + } +} + +func TestGridExitHeldMovementRoundTripAndReplay(t *testing.T) { + t.Chdir(t.TempDir()) + world, first := newGridWorld(t) + player, old := world.characters[1], world.clients[1] + request := gridUseRequest(1) + + if err := world.handleTerminalUse(old, request); err != nil { + t.Fatal(err) + } + second := &combatTestConn{} + client := &worldClient{id: 1, conn: second, target: true, ready: true, forward: -1, movementStarted: time.Now()} + world.clients[1] = client + if err := world.handleTerminalUse(old, request); err != nil { + t.Fatal(err) + } + world.advanceZoneCrossings(client.movementStarted) + if player.playfield != 152 || len(second.packets) != 0 || len(first.packets) != 3 { + t.Fatal("entry bounced immediately or an old session replayed Use") + } + world.advanceZoneCrossings(client.movementStarted.Add(3 * time.Second)) + if err := world.flushPositions(time.Now().Add(20 * time.Second)); err != nil { + t.Fatal(err) + } + restored := newTestInventoryServer(t).characters[1] + + if restored.playfield != 800 || restored.position != [3]float32{620.773, 67.30926, 720.8844} || restored.returnDoor != nil || + len(second.packets) != 2 || binary.BigEndian.Uint32(second.packets[0][16:20]) != 0x43197d22 || binary.BigEndian.Uint32(second.packets[1][16:20]) != 0x3c { + t.Fatal("held movement did not persist the Borealis exit through native teleport") + } +} + +func TestGridExitRequiresSkillAndNearbyLivingSession(t *testing.T) { + for _, scenario := range []string{"skill 91", "skill 90", "distance", "height", "original client", "dead", "loading", "not ready"} { + t.Run(scenario, func(t *testing.T) { + t.Chdir(t.TempDir()) + world, _ := newGridWorld(t) + player, client := world.characters[1], world.clients[1] + player.playfield, player.position = 152, [3]float32{242.31323, 4.7, 199.41223} + client.forward, client.movementStarted = 1, time.Now() + switch scenario { + case "skill 90": + player.stats.ComputerLiteracy = 88 + case "distance": + player.position[0] += 3 + case "height": + player.position[1] += 3 + case "original client": + client.target = false + case "dead": + player.health = 0 + case "loading": + client.loading = true + case "not ready": + client.ready = false + } + + world.advanceZoneCrossings(client.movementStarted) + + if (player.playfield == 800) != (scenario == "skill 91") { + t.Fatal("exit ignored its skill, distance or session requirement") + } + }) + } +} diff --git a/server/insurance.go b/server/insurance.go @@ -32,12 +32,30 @@ func (server *server) handleTerminalUse(client *worldClient, body []byte) error binary.BigEndian.Uint32(body[40:44]) == 51005 && binary.BigEndian.Uint32(body[44:48]) == 0xc00202c1 && x*x+y*y+z*z <= 5*5 reclaim := binary.BigEndian.Uint32(body[40:44]) == 51059 - if reclaim { + grid := binary.BigEndian.Uint32(body[40:44]) == 51005 && binary.BigEndian.Uint32(body[44:48]) == 0xc0040320 + var destination userData + if grid { + // Borealis statel 0xc0040320 requires Computer Literacy > 90 and no combat. + x, y, z := position[0]-636.4026, position[1]-66.81002, position[2]-728.8094 + accepted = client.target && player.playfield == 800 && x*x+y*y+z*z <= 5*5 && player.fighting == 0 && + player.stats.effectiveSkill(player.stats.ComputerLiteracy, [6]uint32{0, 0, 0, 100, 0, 0}) > 90 + for _, attacker := range server.fighting { + if attacker.fighting == player.id { + accepted = false + break + } + } + destination = player.userData() + destination.Playfield = 152 + destination.Position = [3]float32{242.3208, 4.6000195, 193.26456} + destination.Rotation = [4]float32{0, -0.9999775, 0, 0.006704932} + destination.ReturnDoor = nil + } else if reclaim { accepted = client.target && binary.BigEndian.Uint32(body[44:48]) == 0xc00902c1 && server.nearReclaim_locked(client) } else { accepted = accepted && len(player.inventory.Reclaim) == 0 } - if accepted && !reclaim { + if accepted && !reclaim && !grid { // Persist the scanner before acknowledging use or changing live state. updated := *player updated.resurrectionTerminal = 0xc00202c1 @@ -49,7 +67,7 @@ func (server *server) handleTerminalUse(client *worldClient, body []byte) error } server.mutex.Unlock() - // Complete native Use before sending any insurance confirmation. + // Complete native Use before its effect or insurance confirmation. reply := append([]byte(nil), body[16:]...) binary.BigEndian.PutUint32(reply, 2) if accepted { @@ -58,6 +76,9 @@ func (server *server) handleTerminalUse(client *worldClient, body []byte) error if err := client.send(n3Packet(0x52526858, 50000, client.id, reply)); err != nil { return err } + if accepted && grid { + return server.updateUser_locked(destination) + } if accepted && !reclaim { var action []byte for _, value := range []uint32{79, 0, 0, 0, 0} { diff --git a/server/zoning.go b/server/zoning.go @@ -64,6 +64,21 @@ func readZoneLinks() (map[string]map[uint32]zoneLinks, error) { } func (server *server) zoneDestination_locked(character *character, client *worldClient) *userData { + // Grid statel 0xc04c0098 runs LineTeleport on collision with its exit beam. + // Use a provisional two-metre envelope until the native mesh is recovered. + if client.target && character.playfield == 152 && + character.stats.effectiveSkill(character.stats.ComputerLiteracy, [6]uint32{0, 0, 0, 100, 0, 0}) > 90 { + x, y, z := character.position[0]-242.31323, character.position[1]-4.199992, character.position[2]-199.41223 + if x*x+y*y+z*z <= 2*2 { + destination := character.userData() + destination.Playfield = 800 + destination.Position = [3]float32{620.773, 67.30926, 720.8844} + destination.Rotation = [4]float32{0, 0.61582947, 0, 0.78787947} + destination.ReturnDoor = nil + return &destination + } + } + version := "original" if client.target { version = "target" diff --git a/tools/data/extract_grid.py b/tools/data/extract_grid.py @@ -0,0 +1,64 @@ +import hashlib +import json +import math +import pathlib +import struct + +import ao_database +import extract_whompahs + + +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, instance, template, destination, packed in [ + (800, 0xc0040320, 95350, 152, 0x260098), + (152, 0xc04c0098, 95351, 800, 0x000e0320)]: + # Select the two authored SimpleItems, preserving their complete scripts. + 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) != (51005, instance): + continue + assert struct.unpack_from('<I', raw, 56)[0] == template + descriptor = raw[64:] + assert struct.unpack_from('>5I', descriptor) == (102, 103, 1009, 1, 2) + event, _, function, _, _, count = struct.unpack_from('>6I', descriptor, 20) + requirements = [struct.unpack_from('>3I', descriptor, 44 + i * 12) for i in range(count)] + assert requirements == ([(410, 0, 0), (161, 90, 2), (0, 0, 4)] if playfield == 800 else [(161, 90, 2)]) + argument_offset = 44 + count * 12 + assert struct.unpack_from('>4I', descriptor, argument_offset) == (1, 0, 2, 0) + arguments = struct.unpack_from('>7I' if playfield == 800 else '>4I', descriptor, argument_offset + 16) + assert (event, function, arguments) == ((0, 53083, (51102, 152, 0, 0, 100001, 0x260098, 500)) if playfield == 800 else (3, 53059, (100001, 0x000e0320, 800, 0))) + + # Midpoint, human clearance and facing away are reconstruction policy. + destination_payload = database.read(1000001, destination) + start, end = extract_whompahs.destination_lines(destination_payload, destination)[packed] + 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, instance=instance, template=template, + position=list(struct.unpack_from('<3f', raw, 24)), event=event, function=function, + requirements=requirements, arguments=arguments, 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 + output = pathlib.Path('local/reports/grid-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()