aorecomp

Anarchy Online classic in the browser

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


commit 44b20dcaf931a1426d56ccb332ebd07b7e423a1b
parent 679ef6cb15af0c45a8786f5324787d7552295863
Author: anon <anon@example.com>
Date:   Sat, 17 Oct 2026 01:54:44 +0000

Serve the complete asset root in browser sweep fixtures

Diffstat:
Mtools/client/sweep_browser.html | 12+++++++++++-
Mtools/client/sweep_browser.py | 16++++++----------
2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/tools/client/sweep_browser.html b/tools/client/sweep_browser.html @@ -11,6 +11,7 @@ pre { white-space: pre-wrap; } <pre id="status">Ready</pre> <iframe id="game" title="AO WASM client"></iframe> <pre id="result"></pre> +<pre id="log"></pre> <script> const status = document.querySelector('#status'); const frame = document.querySelector('#game'); @@ -21,7 +22,10 @@ window.addEventListener('message', event => { const message = event.data; if (message.instance !== instance) return; if (message.kind === 'frame') { frames = message.frames; frameTime = message.time; } - if (message.kind === 'log') log += message.text + '\n'; + if (message.kind === 'log') { + log += message.text + '\n'; + document.querySelector('#log').textContent = log.slice(-8000); + } if (message.kind === 'error') error = message.text; if (message.kind === 'input') input = message.events; if (message.kind === 'capture') screenshot = message.png; @@ -35,6 +39,10 @@ async function request(path, body) { } document.querySelector('#start').onclick = async event => { event.target.disabled = true; + if (!crossOriginIsolated || !WebAssembly.Suspending || !HTMLCanvasElement.prototype.transferControlToOffscreen) { + status.textContent = 'This browser needs shared memory, WebAssembly JSPI and OffscreenCanvas support'; + return; + } window.sweepAudio = new AudioContext(); await window.sweepAudio.resume(); try { @@ -50,6 +58,7 @@ document.querySelector('#start').onclick = async event => { if (command.action === 'launch') { instance = command.instance; frames = 0; frameTime = 0; input = null; error = ''; log = ''; + document.querySelector('#log').textContent = ''; inputRequested = captureRequested = false; screenshot = null; frame.src = 'sweep-client.html?instance=' + instance; } @@ -65,6 +74,7 @@ document.querySelector('#start').onclick = async event => { const result = await request('/finish', {instance, log, screenshot, input}); document.querySelector('#result').textContent = JSON.stringify(result, null, 2); input = null; inputRequested = captureRequested = false; screenshot = null; log = ''; + document.querySelector('#log').textContent = ''; } await new Promise(resolve => setTimeout(resolve, 250)); } diff --git a/tools/client/sweep_browser.py b/tools/client/sweep_browser.py @@ -29,20 +29,12 @@ for port in [7520, 7521, 8082, 8083]: assert connection.connect_ex(('127.0.0.1', port)) != 0, port subprocess.run(['go', 'build', '-o', str(work / 'server'), './server'], cwd=root, check=True) -# Isolate the character and writable settings; keep immutable game assets shared. +# The browser copies preferences into private WASM memory; HTTP assets are read-only. fixture = output / 'server' if not resuming: (fixture / 'data').mkdir(parents=True) (fixture / 'client').mkdir() - assets = fixture / 'anarchy-assets-14.9.1' - assets.mkdir() - for source in (root / 'anarchy-assets-14.9.1').iterdir(): - if source.name in ['cd_image', 'fonts']: - (assets / source.name).symlink_to(source) - elif source.is_dir(): - shutil.copytree(source, assets / source.name) - else: - shutil.copy2(source, assets / source.name) + (fixture / 'anarchy-assets-14.9.1').symlink_to(root / 'anarchy-assets-14.9.1') for name in ['terrain.bin', 'zone_links.yaml', 'npc_spawns.yaml', 'maps']: (fixture / 'data' / name).symlink_to(root / 'data' / name) (fixture / 'runtime').symlink_to(root / 'runtime') @@ -245,6 +237,10 @@ with (output / 'server.log').open('a') as server_log: if connection.connect_ex(('127.0.0.1', 8082)) == 0: break time.sleep(1) + manifest = request('/browser-manifest').decode().splitlines() + assert all(name in manifest for name in ['cd_image/', 'fonts/', 'version.id']), 'incomplete browser asset fixture' + for name in ['cd_image', 'fonts', 'version.id']: + request('/browser-assets/' + name) print(output, '\nOpen http://127.0.0.1:8082/wasm/sweep.html', flush=True) with http.server.HTTPServer(('127.0.0.1', 8083), Controller) as controller: controller.timeout = 1