aorecomp

Anarchy Online classic in the browser

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


commit 187ba79d6fcda9e1a5382d06178d1609049ecaae
parent 43712e85851afef65c67fddb62ab2844a26859ff
Author: anon <anon@example.com>
Date:   Fri, 30 Oct 2026 10:35:40 +0000

Verify native mission targets and earned starter progression

Diffstat:
MDEVELOPERS.md | 11+++++++++--
MTODO.md | 26++++++++++++++++++++++++++
Mclient/runtime/browser_testing.c | 3++-
Mclient/tests/browser_testing.c | 11+++++++++++
Mdocs/mission-terminals.md | 28++++++++++++++++++++++++++++
Mdocs/starter-progression.md | 47+++++++++++++++++++++++++++++++++++++++++++++++
Mserver/browser_game_test.go | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/client/test_starter_mission_targets.mjs | 113+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 302 insertions(+), 3 deletions(-)

diff --git a/DEVELOPERS.md b/DEVELOPERS.md @@ -452,7 +452,7 @@ available (`node` on PATH, `playwright` installed locally or on NODE_PATH, `/usr/bin/chromium` installed): ```sh -AO_GAME_TEST=1 go test ./server -run '^TestBrowser(GameHarness|StarterEquipment)$' -count=1 -timeout=15m -v +AO_GAME_TEST=1 go test ./server -run '^TestBrowser(GameHarness|StarterEquipment|StarterMissionTargets)$' -count=1 -timeout=15m -v ``` This starts an HTTP server on a random loopback port and uses a disposable @@ -472,6 +472,11 @@ items or change character stats, cash or enemies. This is the equipment slice of the larger progression regression; earned combat, purchases and recovery remain separate checks. +`TestBrowserStarterMissionTargets` walks a normally created starter through its +training exit to Backyard1. It checks the distinct booth56001, entrance56006 and +scene-door51005 identities sharing a numeric ID, then uses the actual booth and +cancels its window without changing inventory, cash or progression. + For a new scenario, attach before navigation so protocol capture includes the initial stream handshake: @@ -515,6 +520,8 @@ The driver provides: offscreen targets should fail visibly rather than bypass picking. - `save(directory)` writes `trace.json` and `screen.png`. Keep it inside a `finally` with browser cleanup, as in the example. + Event history is bounded; `game.errors` retains errors independently so later + waits still fail after history rolls over. Trace reports include that list. For burst input, focus-loss and timing regressions, drive Playwright's mouse and keyboard directly while keeping `GameTest` attached for observation. The @@ -523,7 +530,7 @@ for rendering and UI correctness as well as asserting underlying game state. Snapshots include frame number, render size, browser focus/visibility, selected/hovered identities, camera angles, visible native UI regions, and loaded -characters, world items, machines +characters, world items, machines, mission booths/entrances and corpses. Actor fields include global position, rotation, playfield, deletion and combat state. Characters expose the 1024 raw stat values by native stat ID; these are the dictionary values, not a reconstruction of all effective modifiers. diff --git a/TODO.md b/TODO.md @@ -2965,6 +2965,18 @@ with payloads and known client/server provenance. ## Thorough gameplay regression testing +- [x] Include original mission booths and entrances in native frame snapshots. + Their shared n3Dynel layout and typed directory identity are recovered from + the client. A WASM fixture distinguishes equal numeric IDs, and an ordinary + browser starter walks to Backyard1, picks the actual booth, receives its + successful native Use callback and cancels without changing progress. + `TestBrowserStarterMissionTargets` passes against the published client. +- [x] Retain browser and protocol errors after the bounded gameplay trace rolls + over. A reproduced error followed by 2,048 ordinary events previously vanished + and let an otherwise satisfied wait pass. The harness now keeps its error list + independently, fails later waits and writes the errors into each trace report. + The focused public-driver regression fails against the old code and passes + with the fix; the event/snapshot history remains bounded. - [x] Resolve the browser snapshot's incorrect local identity for normally created characters. The first repeatable starter run reported local ID1 while directory actor2 had seven issued items and exchanged CharacterReady. @@ -2996,6 +3008,12 @@ with payloads and known client/server provenance. opener goroutines from earlier fixtures. Audit shared fixture helpers and verify bounded open handles/goroutines across a full run. New mission movement fixtures explicitly close their world database. + The ordinary two-client progression fixture also exposed late disconnect + writes: closing browser streams does not wait for `serveWorldClient` to save + active nano durations. Two stopped runs logged `Saving nano durations: sql: + database is closed`. Include session-writer draining before database cleanup; + retained captures are in `local/todo-progression-play/`. Its resumed manual + fixture now waits for connected clients to retire before closing SQLite. - [ ] [P3] Reproduce stale shop interaction state after a live control-panel inventory edit. In the restoration smoke run, a nearby original terminal reported "Too far away" after the edit, while a fresh page could use it. @@ -3317,6 +3335,14 @@ and server restarts. Turn every reproduced bug into a focused regression test. issued bat's equip/remove/re-equip, owner reconnect and cold ownership checks against production training-ground resources. This is an automated equipment slice; it does not complete the earned combat, purchases or recovery gate. + A new two-client harness run now connects seven full-health ordinary kills, + an earned Monster Part sale and funded mission request to all five private + encounters, exact-book hand-in and earned QL1 Metaplast body armor. Rejected + wear, normal Agility training, removal/re-wear, page reconnect and cold recovery + retain all 17 items, 700 XP, 1,087 IP, 33 credits and unchanged observer progress. + The native Stats window retains AC 5/5/5. This same-character run still needs + level-up/new IP, funded purchase/use, next-level combat and recovery cases; + see [two-client progression](docs/starter-progression.md#two-client-native-harness-progression). A subsequent normal Omni Enforcer run trained Body Development/Stamina, equipped the issued bat/shirt and used a startup treatment lab. Solo combat ended in death; a two-player kill generated real loot/cash but its leading diff --git a/client/runtime/browser_testing.c b/client/runtime/browser_testing.c @@ -88,7 +88,8 @@ static void directory(FILE *output, uint32_t node, uint32_t nil, uint32_t local, if (node == nil) return; directory(output, MEM32(node), nil, local, count, local_id); uint32_t type = MEM32(node + 12), id = MEM32(node + 16), object = MEM32(node + 20); - if ((type == 50000 || type == 51005 || type == 51035 || type == 51050) && MEM32(object + 0x60)) { + if ((type == 50000 || type == 51005 || type == 51035 || type == 51050 || + type == 56001 || type == 56006) && MEM32(object + 0x60)) { if ((*count)++) fputc(',', output); actor(output, object, type, id, object == local); if (object == local) *local_id = id; diff --git a/client/tests/browser_testing.c b/client/tests/browser_testing.c @@ -51,6 +51,15 @@ static void snapshot_copies_native_state_without_changing_guest_registers(void) MEM32(0x50006300 + 48 * 4) = 0x50007000; memcpy((void *)ADDR(0x50007000), (uint32_t[]){0, 3 << 16, 51005, 25, 1, 25812, 25812, 0}, 32); memcpy((void *)ADDR(0x50002054), (float[]){10, 20, 30}, 12); + + /* Mission statels retain distinct typed identities with the same numeric ID. */ + MEM32(0x50000304) = 0x50000600; + memcpy((void *)ADDR(0x50000600), (uint32_t[]){0x50000500, 0, 0x50000700, 56001, 99, 0x50009000}, 24); + memcpy((void *)ADDR(0x50000700), (uint32_t[]){0x50000400, 0, 0x50000400, 56006, 99, 0x5000a000}, 24); + MEM32(0x50009060) = 0x5000b000; + MEM32(0x5000a060) = 0x5000c000; + memcpy((void *)ADDR(0x5000b054), (float[]){100, 115, 148}, 12); + memcpy((void *)ADDR(0x5000c054), (float[]){89, 115, 151}, 12); g_eax = 123; g_esp = 456; @@ -63,6 +72,8 @@ static void snapshot_copies_native_state_without_changing_guest_registers(void) assert(strstr(snapshot, "\"frame\":2")); assert(strstr(snapshot, "\"localId\":7")); assert(strstr(snapshot, "\"position\":[10,20,30]")); + assert(strstr(snapshot, "\"type\":56001,\"id\":99,\"position\":[100,115,148],\"screenPosition\":[100,115,148]")); + assert(strstr(snapshot, "\"type\":56006,\"id\":99,\"position\":[89,115,151],\"screenPosition\":[89,115,151]")); assert(strstr(snapshot, "\"hover\":[51050,99]")); assert(strstr(snapshot, "\"selected\":[50000,9]")); assert(strstr(snapshot, "\"slot\":48,\"type\":51005,\"id\":25,\"quality\":1,\"templates\":[25812,25812],\"count\":3")); diff --git a/docs/mission-terminals.md b/docs/mission-terminals.md @@ -38,6 +38,34 @@ The nearby starter objects in backyard3000 are: The numeric ID is shared across two different object types. An entrance is not a terminal, and nearby type51016/template118262 doors are apartments. +## Native test snapshots + +The frame snapshot includes mission booths (56001) and entrances (56006) in the same +native directory as characters, floor items and shop machines. Filtering these +types out made `GameTest.pick` report a missing entity while the visible booth +still produced native hover56001/3221228472. The type51005 object with that +numeric ID is a separate scene door at102.95067,115,130.01703; substituting it +would select the wrong object. + +The original constructors establish the shared layout. In +`client/game/kkr.dll/lifted-0009.c`, factory `sub_36017510` constructs the booth +and returns its n3Dynel base at object+0x8c. Entrance factory `sub_36017090` +returns the same base through constructors `sub_3608C9B0`, `sub_36097290` and +`sub_3609C3C0`. +The shared visual constructor calls n3VisualDynel_t at that base. In +`client/game/llr.dll/lifted-0008.c`, constructor `sub_38017660` registers that +pointer through PutInDir (`sub_38017900`); GetGlobalPos (`sub_38017F50`) reads its +Vehicle at+0x60. +The directory already holds the adjusted pointer, so snapshotting must not add +another0x8c. Native N3Msg_GetPos (`sub_36022A00`) uses this same typed lookup and position +bridge. These are layout/lookup facts, not a guarantee that every statel is +currently loaded. + +The focused WASM fixture gives the booth and entrance equal numeric IDs but +different positions and verifies both records without changing guest registers. +It fails with the old filter. The ordinary browser regression reaches Backyard1 +on foot and checks the three distinct typed objects before using the booth. + ## Native interaction The original `kkr.dll` at diff --git a/docs/starter-progression.md b/docs/starter-progression.md @@ -599,3 +599,50 @@ This connects the chosen Enforcer's earned armor purchase and health replenishme The fixed contract, stock subset and NPC balance are reconstruction policy; broader progression, useful creature equipment drops, other starting professions and historical mission/population/reward generation remain open. + +## Two-client native harness progression + +A fresh Omni Atrox Enforcer and an ordinary observer now exercise the production +simulation through `GameTest`, without grants, edited positions/stats/funds, +fixture combat rolls or protocol injection. The same saved character follows two +full-health outdoor Leet kills into a funded starter contract, defeats all five +full-health private encounters and returns its exact Blue Book instance 17. +Seven kills produce 700 XP under the current provisional kill table. The fixed +completion consumes key 16/book 17, awards 20 credits and creates QL1 Worn +Metaplast Body Armor instance 22. Conditional completion XP/token rules remain +unimplemented; completion does not add another 100 XP in this run. + +The wallet accounts for all 33 credits: four outdoor corpse credits, five from +selling earned Monster Parts instance 15, minus one request fee, plus five +collected mission corpse credits and the 20-credit reward. The first two mission +corpses expired unclaimed, including generated part 18; none of that loot became +owned. Parts 19, 20 and 21 were collected and remain distinct owned instances. + +Native wear rejects armor 22 at Agility 6, retaining it. Ordinary training raises +Agility 6->8 for 26 IP, leaving 1,087. Removing issued shirt 7 preserves it in main +slot 68; armor 22 then equips in body slot 21. The native Stats window shows melee, +projectile and energy AC 5/5/5. Removal restores 0/0/0 while the shirt stays in +inventory; re-wear restores 5/5/5 and the rendered armor. This trades the shirt's +projectile-only AC 10 for broader protection. No received-damage improvement is +inferred from these low AC values. Page reconnect restores the actual armor +identity 22; its initial live AddTemplate placeholder has no instance identity. +The snapshot's raw stat dictionary excludes modifiers, so its zero raw AC fields +are not evidence that the native equipment effect failed. + +The final checkpoint contains 17 physical items: ten owned by the fighter and all +seven unchanged observer items. The fighter retains issued bat 4, shirt 7, map 3, +board 6, laboratory 1 with 21 charges and stims 2 with 3 charges, plus reward 22 and +the three parts. Issued crystal 5 was consumed by normal upload; its learned +Thug's Delight 43371 remains, while the cast buff expired naturally. The observer +retains zero XP/credits and its full 25 laboratory/3 stim charges. SQL integrity, +foreign keys, exact item locations, wallet, skills and completed mission 16 pass +against the stopped checkpoint. Native captures, read-only audits and the +immutable checkpoint are retained in `local/todo-progression-play/`. + +This advances the connected fresh-character gate. Its earned level, new level IP, +funded purchase/use, next enemy level, death/reclaim and full-inventory cases +remain open. Both ordinary clients have cold-recovered the final earned +checkpoint with the same 17 item identities, locations and counts, progress and +supplies. The fighter's rendered armor and native AC 5/5/5 remain; the observer +still has no XP or credits. Both retained error lists are empty. Evidence: +`local/todo-progression-play/cold-native-verified.json` and `runtime-cold-final/`. diff --git a/server/browser_game_test.go b/server/browser_game_test.go @@ -148,3 +148,69 @@ func TestBrowserStarterEquipment(t *testing.T) { t.Fatalf("created %d ordinary characters, want 2", players) } } + +func TestBrowserStarterMissionTargets(t *testing.T) { + if os.Getenv("AO_GAME_TEST") != "1" { + t.Skip("set AO_GAME_TEST=1 to run the real WASM client in Chromium") + } + + _, source, _, _ := runtime.Caller(0) + root := filepath.Dir(filepath.Dir(source)) + output := filepath.Join(root, "local", "game-tests", "mission-targets-"+time.Now().Format("20060102-150405")) + world := newTestServer(t) + mux := http.NewServeMux() + mux.Handle("/", world.httpHandler()) + mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) { + world.mutex.Lock() + defer world.mutex.Unlock() + player := world.browserCharacter_locked(r) + json.NewEncoder(w).Encode(map[string]any{"playfield": player.playfield, "inventory": player.inventory}) + }) + host := httptest.NewServer(mux) + t.Cleanup(host.Close) + closeTestBrowserStreams(t, world) + + // Advance the ordinary travel route without teleporting the character. + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + stopped := make(chan struct{}) + go func() { + defer close(stopped) + movement := time.NewTicker(time.Second / 60) + zoning := time.NewTicker(100 * time.Millisecond) + defer movement.Stop() + defer zoning.Stop() + for { + select { + case now := <-movement.C: + world.advancePlayerMovement(now) + case now := <-zoning.C: + world.advanceZoneCrossings(now) + case <-ctx.Done(): + return + } + } + }() + defer func() { cancel(); <-stopped }() + + command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_starter_mission_targets.mjs"), host.URL, output) + command.Dir = root + command.Stdout, command.Stderr = os.Stdout, os.Stderr + if err := command.Run(); err != nil { + t.Fatal(err) + } + t.Logf("Browser artifacts: %s", output) + + world.mutex.Lock() + defer world.mutex.Unlock() + for _, player := range world.characters { + if player.name == "Missionpick" { + if player.playfield != 3000 || len(player.inventory.Items) != 7 || player.inventory.Credits != 0 || + player.level != 1 || player.experience != 0 || len(player.missions) != 0 { + t.Fatalf("native terminal inspection changed starter progress: %+v", player.userData()) + } + return + } + } + t.Fatal("normally created character is missing") +} diff --git a/tools/client/test_starter_mission_targets.mjs b/tools/client/test_starter_mission_targets.mjs @@ -0,0 +1,113 @@ +import assert from 'node:assert/strict'; +import {createRequire} from 'node:module'; +import {GameTest} from './game_test.mjs'; + +const {chromium} = createRequire(import.meta.url)('playwright'); +const [url, output] = process.argv.slice(2); +assert(url && output, 'Run through TestBrowserStarterMissionTargets'); +const browser = await chromium.launch({executablePath: '/usr/bin/chromium', + args: ['--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage']}); +let game; + +// Follow ordinary movement feedback, stopping when a route no longer approaches its goal. +function difference(a, b) { return Math.atan2(Math.sin(a - b), Math.cos(a - b)); } +async function walk(x, z) { + const field = game.local().playfield; + let best = Infinity, progressAt = Date.now(); + for (;;) { + await game.snapshot(); + const actor = game.local(); + if (!actor || actor.playfield !== field) return; + const distance = Math.hypot(x - actor.position[0], z - actor.position[2]); + if (distance < 1.2) return; + if (distance < best - 0.2) { best = distance; progressAt = Date.now(); } + assert(Date.now() - progressAt < 8000, 'Route is not approaching its destination'); + const yaw = Math.atan2(x - actor.position[0], z - actor.position[2]); + const angle = difference(yaw, 2 * Math.atan2(actor.rotation[1], actor.rotation[3])); + if (Math.abs(angle) > 0.05) { + await game.hold(angle > 0 ? 'KeyD' : 'KeyA', 'face route', state => { + const actor = game.local(state); + if (!actor || actor.playfield !== field) return true; + const remaining = difference(yaw, 2 * Math.atan2(actor.rotation[1], actor.rotation[3])); + return Math.abs(remaining) < 0.05 || Math.sign(remaining) !== Math.sign(angle); + }); + } + const start = game.local().position; + await game.hold('KeyW', 'walk toward ' + x + ',' + z, state => { + const actor = game.local(state); + return !actor || actor.playfield !== field || + Math.hypot(actor.position[0] - start[0], actor.position[2] - start[2]) >= Math.min(3, distance - 1) || + Math.hypot(x - actor.position[0], z - actor.position[2]) < 1.2; + }, 5000); + } +} + +try { + const context = await browser.newContext({viewport: {width: 1024, height: 768}}); + const page = await context.newPage(); + game = await GameTest.attach(page); + + // Create the normal starter, then reach its backyard through the training exit. + await page.goto(url); + await game.ready(); + await page.keyboard.press('Control+Alt+M'); + await page.locator('#create-button').click(); + await page.locator('#creation-breed').selectOption('4'); + await page.locator('#creation-profession').selectOption('9'); + await page.locator('#creation-side').selectOption('2'); + await page.locator('#account-name').fill('Missionpick'); + await page.locator('#account-password').fill('mission target regression password'); + await Promise.all([page.waitForEvent('load'), page.locator('#account-submit').click()]); + await game.ready(); + assert.equal(game.local().playfield, 950); + const issued = game.local().inventory; + await game.save(output + '/created'); + await game.hold('KeyS', 'leave the training entrance', state => + game.local(state)?.playfield === 3000, 60000); + await game.wait('backyard and its original mission statels', state => + game.local(state)?.playfield === 3000 && + state.actors.some(actor => actor.type === 56001 && actor.id === 3221228472) && + state.actors.some(actor => actor.type === 56006 && actor.id === 3221228472), 60000); + await game.ready(); + const backyard = await (await page.request.get(url + '/test-state')).json(); + assert.equal(backyard.playfield, 3000); + + // Equal numeric IDs belong to separate native objects, including a third scene door. + const booth = game.state.actors.find(actor => actor.type === 56001 && actor.id === 3221228472); + const entrance = game.state.actors.find(actor => actor.type === 56006 && actor.id === 3221228472); + const door = game.state.actors.find(actor => actor.type === 51005 && actor.id === 3221228472); + assert(Math.hypot(booth.position[0] - 100.03333, booth.position[2] - 148.27986) < 0.01); + assert(Math.hypot(entrance.position[0] - 89.30216, entrance.position[2] - 151.16087) < 0.01); + assert(Math.hypot(door.position[0] - 102.95067, door.position[2] - 130.01703) < 0.01); + await game.save(output + '/backyard'); + + for (const [x, z] of [[102.5, 102], [102.5, 143], [104, 150], [102, 149.5]]) + await walk(x, z); + assert.equal(game.local().playfield, 3000); + if (!game.state.camera.firstPerson) await game.key('F8'); + await game.save(output + '/booth-approach'); + const [x, y] = await game.pick(56001, 3221228472); + await game.click(x, y, 'right'); + // The targeted callback puts its success word after the actor and target flag. + await game.wait('successful native mission-booth callback', () => game.events.some(event => + event.kind === 'packet' && event.direction === 'framereceived' && event.opcode === '52526858' && + Buffer.from(event.hex, 'hex').readUInt32BE(29) === 1)); + await game.wait('visible mission difficulty window', state => state.regions.some( + ([left, top, right, bottom]) => left === 150 && top === 180 && right === 220 && bottom === 200)); + await game.save(output + '/booth-open'); + await game.click(183, 190); + await game.wait('mission difficulty window closed', state => !state.regions.some( + ([left, top, right, bottom]) => left === 150 && top === 180 && right === 220 && bottom === 200)); + + // Inspection and cancellation preserve the complete issued loadout and all progress. + await game.snapshot(); + assert.deepEqual(game.local().inventory, issued); + const final = await (await page.request.get(url + '/test-state')).json(); + assert.deepEqual(final.inventory, backyard.inventory); + assert.deepEqual(game.errors, []); + assert.equal(game.dropped, 0); + console.log('PASS: ordinary backyard travel, distinct typed mission statels and native booth Use'); +} finally { + try { if (game) await game.save(output + '/final'); } + finally { await browser.close(); } +}