commit 885149a47c5b750c954aae1ba6c2a8dbf5dffd2a
parent 98deeffa0a7474c1933fb39f8be349c2e79c6640
Author: anon <anon@example.com>
Date: Fri, 6 Nov 2026 22:46:19 +0000
Collect character credentials in the native naming step
Diffstat:
19 files changed, 694 insertions(+), 282 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -35,15 +35,18 @@ research separately. More screenshots and test cases do not count as new gamepla
## P0: first experience
-- [x] **Use the original native character creation flow.** Phone regressions now
- preserve the creator's 4:3 proportions across orientations, edit a name through
- a real HTML input, and restore adaptive world rendering. Native browser walking
+- [x] **Use the original native character creation flow.** Login credentials are
+ collected in a modal at native naming, with native controls blocked until OK
+ advances the sequence. Phone and desktop browser regressions pass: password
+ login after creation/restart, cancellation and refresh without duplicate
+ creation, 4:3 proportions through the outro, and adaptive world rendering.
+ Native browser walking
passes through all three faction corridors into their training grounds with
the correct starter grants; protocol checks cover atomicity and restart.
Physical phone keyboard display remains a device retest. Options now launches
the original breed, appearance, profession and naming scenes, using the shared
atomic creation backend. Real WASM input covers cancellation, short/duplicate
- names, completion, walking through Arrival Hall, faction departure, saving,
+ names, completion, walking through Arrival Hall, faction departure, password login,
inventory preferences, reconnect and cold recovery of both old and new saved
characters. Protocol tests cover duplicate submissions and competing sockets
without duplicate characters/items. Hall dialogue, outfits and departure
diff --git a/client/browser/index.html b/client/browser/index.html
@@ -11,8 +11,6 @@
#game-surface { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#game-surface[data-creation] canvas { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
- #creation-name { position: absolute; box-sizing: border-box; padding: 0 4px; border: 0; border-radius: 0; background: #111; color: white; font: 16px GameVerdana, Verdana, sans-serif; }
- #creation-name[hidden] { display: none; }
button, select, input { font: inherit; }
button { min-height: 44px; }
#game-toolbar { position: absolute; top: max(24px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); display: flex; gap: 8px; }
@@ -53,18 +51,18 @@
#menu-error { color: #ffb0a0; }
#menu-error:empty { display: none; }
#account-panel { margin-top: 20px; border-top: 1px solid #777; }
- #account-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
+ #account-panel fieldset, #creation-credentials fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
#account-choices button { display: block; width: 100%; margin: 8px 0; }
#account-choices button[hidden] { display: none; }
- #account-form input { box-sizing: border-box; display: block; width: 100%; margin-top: 6px; padding: 8px; }
+ #account-form input, #creation-credentials input { box-sizing: border-box; display: block; width: 100%; margin-top: 6px; padding: 8px; }
+ #creation-credentials input { font-size: 16px; }
#account-form label[hidden] { display: none; }
- #account-error { color: #ffb0a0; }
+ #account-error, #creation-error { color: #ffb0a0; }
#account-error.success { color: #b9d8b0; }
- #account-error:empty { display: none; }
+ #account-error:empty, #creation-error:empty { display: none; }
</style>
<div id="game-surface">
<canvas id="canvas" width="1024" height="768" tabindex="0"></canvas>
-<input id="creation-name" aria-label="Player name" maxlength="12" autocomplete="off" autocapitalize="none" spellcheck="false" enterkeyhint="done" hidden>
<div id="loading" role="status">Downloading Anarchy Online client...</div>
<div id="download-progress" role="progressbar" aria-label="Client download" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" hidden><div id="download-fill"></div></div>
<button id="reconnect" hidden>Reconnect</button>
@@ -128,6 +126,19 @@
<p id="account-error" role="status"></p>
</section>
</dialog>
+<dialog id="creation-credentials" aria-labelledby="creation-title">
+ <h1 id="creation-title">Name your character</h1>
+ <p>Use this name and password to log in to this character.</p>
+ <form id="creation-form">
+ <fieldset id="creation-fields">
+ <label>Player name <input id="creation-player-name" name="username" autocomplete="username" autocapitalize="none" spellcheck="false" maxlength="12" required></label>
+ <label>Password <input id="creation-password" name="password" type="password" autocomplete="new-password" maxlength="1024"></label>
+ <button id="creation-submit" type="submit">OK</button>
+ </fieldset>
+ <p id="creation-error" role="status"></p>
+ <button id="creation-cancel" type="button">Cancel creation</button>
+ </form>
+</dialog>
<script>
const status = document.querySelector('#loading');
const downloadProgress = document.querySelector('#download-progress');
@@ -256,7 +267,6 @@
Module._browser_chat_viewport(isMobileBrowser && !chatForm.hidden ? Math.round(height * scale) : 0);
}
positionChat();
- positionCreationName();
}
// Restore the existing session after a background tab or suspended page returns.
@@ -371,6 +381,12 @@ show();
};
async function startGame() {
if (!crossOriginIsolated) { status.textContent = 'Shared memory is unavailable'; return; }
+ // Consume the one-time launch intent before any asynchronous loading begins.
+ const launchURL = new URL(location.href);
+ const creating = launchURL.searchParams.get('create') === '1';
+ setCreatorActive(creating);
+ launchURL.searchParams.delete('create');
+ history.replaceState(null, '', launchURL);
// Some browsers expose OffscreenCanvas without supporting WebGL in workers.
let workerGraphics = false;
if (canvas.transferControlToOffscreen) {
@@ -403,11 +419,6 @@ show();
document.addEventListener(type, resumeAudio, true);
}
status.textContent = 'Downloading Anarchy Online client...';
- const launchURL = new URL(location.href);
- const creating = launchURL.searchParams.get('create') === '1';
- setCreatorActive(creating);
- launchURL.searchParams.delete('create');
- history.replaceState(null, '', launchURL);
const response = await fetch('browser-launch' + (creating ? '?create=1' : ''), {method: 'POST'});
if (!response.ok) { status.textContent = await response.text(); return; }
Module.arguments = (await response.text()).trim().split(' ').slice(1);
@@ -429,65 +440,50 @@ show();
const chatForm = document.querySelector('#chat-compose');
const chatText = document.querySelector('#chat-text');
const chatActions = document.querySelector('#chat-actions');
- const creationName = document.querySelector('#creation-name');
- let creationNameBounds = null, creationNameValue = '', creationNameComposing = false;
- let creationFullscreen = null;
+ const creationDialog = document.querySelector('#creation-credentials');
+ const creationFields = document.querySelector('#creation-fields');
+ const creationError = document.querySelector('#creation-error');
+ let creationSubmitted = false;
Module.onCreationState = state => {
creatorSeen ||= state.active;
if (creatorSeen) setCreatorActive(state.active);
- creationNameBounds = state.name;
- creationName.hidden = !isMobileBrowser || !state.name;
- if (creationName.hidden && document.activeElement === creationName) creationName.blur();
- if (state.name && document.activeElement !== creationName) {
- creationName.value = creationNameValue = state.name.value;
+ if (creationSubmitted && (!state.name || !state.active) && creationDialog.open) {
+ creationDialog.close();
+ canvas.focus();
}
- positionCreationName();
- };
-
- // A real HTML field opens the phone IME over the original native name editor.
- function positionCreationName() {
- if (!creationNameBounds || creationName.hidden) return;
- const canvasBounds = canvas.getBoundingClientRect();
- const surfaceBounds = gameSurface.getBoundingClientRect();
- const scale = canvasBounds.width / 1024;
- const width = Math.max(160, creationNameBounds.width * scale);
- creationName.style.left = `${canvasBounds.left - surfaceBounds.left + (creationNameBounds.x + creationNameBounds.width / 2) * scale - width / 2}px`;
- creationName.style.top = `${canvasBounds.top - surfaceBounds.top + creationNameBounds.y * scale}px`;
- creationName.style.width = `${width}px`;
- creationName.style.height = `${Math.max(28, creationNameBounds.height * scale)}px`;
- }
- function typeCreationName() {
- if (creationNameComposing || creationName.value === creationNameValue) return;
- Module.setCreationName(creationName.value);
- creationNameValue = creationName.value;
- }
- creationName.onfocus = () => {
- releaseControls();
- // Android Firefox needs to leave fullscreen before showing a usable IME.
- if (document.fullscreenElement && /Android.*Firefox\//.test(navigator.userAgent)) {
- const fullscreen = document.fullscreenElement;
- document.exitFullscreen().then(() => {
- creationFullscreen = fullscreen;
- updateResolution();
- positionCreationName();
- if (!creationName.hidden) creationName.focus({preventScroll: true});
- }).catch(error => {
- document.querySelector('#menu-error').textContent = 'Fullscreen is unavailable: ' + error.message;
- });
+ if (state.name && !creationSubmitted && !creationDialog.open) {
+ releaseControls();
+ creationDialog.showModal();
+ // Firefox Android needs to leave fullscreen before opening its keyboard.
+ if (document.fullscreenElement && /Android.*Firefox\//.test(navigator.userAgent)) {
+ document.exitFullscreen().then(() => document.querySelector('#creation-player-name').focus()).catch(error => {
+ creationError.textContent = 'Fullscreen is unavailable: ' + error.message;
+ });
+ }
}
};
- creationName.oninput = typeCreationName;
- creationName.addEventListener('compositionstart', () => { creationNameComposing = true; });
- creationName.addEventListener('compositionend', () => { creationNameComposing = false; typeCreationName(); });
- creationName.onblur = () => {
- creationNameComposing = false;
- typeCreationName();
- if (creationFullscreen) {
- creationFullscreen.requestFullscreen().catch(error => {
- document.querySelector('#menu-error').textContent = 'Fullscreen is unavailable: ' + error.message;
- });
- creationFullscreen = null;
+ document.querySelector('#creation-cancel').onclick = () => location.reload();
+ creationDialog.addEventListener('cancel', event => { event.preventDefault(); location.reload(); });
+ document.querySelector('#creation-form').onsubmit = async event => {
+ event.preventDefault();
+ if (creationFields.disabled || creationSubmitted) return;
+ creationFields.disabled = true;
+ creationError.textContent = '';
+ const values = new URLSearchParams({name: document.querySelector('#creation-player-name').value,
+ password: document.querySelector('#creation-password').value});
+ try {
+ const response = await fetch('browser-create', {method: 'POST', body: values});
+ if (response.ok) {
+ creationSubmitted = true;
+ document.querySelector('#creation-password').value = '';
+ Module.finishCreation(response.headers.get('X-AO-Creation-Name'));
+ return;
+ }
+ creationError.textContent = await response.text();
+ } catch (error) {
+ creationError.textContent = 'Could not contact the server. Please try again.';
}
+ creationFields.disabled = false;
};
const movePad = document.querySelector('#move-pad');
const autorunButton = document.querySelector('#autorun-button');
@@ -977,19 +973,14 @@ show();
};
for (const type of ['keydown', 'keyup', 'keypress']) {
window.addEventListener(type, event => {
- if (type === 'keydown' && event.ctrlKey && event.altKey && event.code === 'KeyM') {
+ if (creationDialog.open) {
+ event.stopImmediatePropagation();
+ } else if (type === 'keydown' && event.ctrlKey && event.altKey && event.code === 'KeyM') {
event.preventDefault();
event.stopImmediatePropagation();
if (event.repeat) return;
if (playerMenu.open) playerMenu.close();
else openMenu();
- } else if (document.activeElement === creationName) {
- event.stopImmediatePropagation();
- if (type === 'keydown' && (event.key === 'Enter' || event.key === 'Escape') && !creationNameComposing && !event.isComposing && event.keyCode !== 229) {
- event.preventDefault();
- creationName.blur();
- canvas.focus();
- }
} else if (playerMenu.open || !chatForm.hidden) {
event.stopImmediatePropagation();
if (type === 'keydown' && event.key === 'Escape' && !chatForm.hidden && !chatComposing && !event.isComposing && event.keyCode !== 229) {
diff --git a/client/runtime/browser_host.js b/client/runtime/browser_host.js
@@ -135,11 +135,11 @@ addToLibrary({
Module.onTouchRegions?.({regions, screenWidth, screenHeight});
},
ao_creation_state__proxy: 'sync',
- ao_creation_state__deps: ['$UTF8ToString', '$stringToNewUTF8', 'free', 'browser_creation_name'],
+ ao_creation_state__deps: ['$UTF8ToString', '$stringToNewUTF8', 'free', 'browser_creation_finish'],
ao_creation_state: (bounds, name) => {
- Module.setCreationName ||= value => {
+ Module.finishCreation ||= value => {
const text = stringToNewUTF8(value);
- _browser_creation_name(text);
+ _browser_creation_finish(text);
_free(text);
};
const offset = bounds >> 2;
diff --git a/client/runtime/browser_resolution.c b/client/runtime/browser_resolution.c
@@ -36,7 +36,10 @@ void ao_creation_state(const int *bounds, const char *name);
static void publish_creation_state(void)
{
uint32_t scene = MEM32(0x2b0ee7d0);
- int bounds[] = {scene != 0, 0, 0, 0, 0, MEM32(0x27048be8), MEM32(0x27048bec)};
+ /* CharCreateModule_t::FrameProcess clears the scene for the outro, while
+ * its renderer remains alive until ShutdownMessage (sub_2B02DE30). */
+ int bounds[] = {scene || MEM32(0x2b0ee7e4), 0, 0, 0, 0,
+ MEM32(0x27048be8), MEM32(0x27048bec)};
const char *name = "";
/* NameScene_t::sub_2B0338B0 reads the InputWindow_t and its native string. */
if (scene && scene == MEM32(0x2b0ee7e0)) {
@@ -124,7 +127,7 @@ EMSCRIPTEN_KEEPALIVE void browser_request_resize(unsigned width, unsigned height
atomic_store(&requested_size, width | (height << 16));
}
-EMSCRIPTEN_KEEPALIVE void browser_creation_name(const char *name)
+EMSCRIPTEN_KEEPALIVE void browser_creation_finish(const char *name)
{
char *copy = strdup(name);
if (!copy) abort();
@@ -193,23 +196,27 @@ static void call_method(uint32_t address, uint32_t object, unsigned count,
assert(g_esp == stack);
}
-static void update_creation_name(void)
+static void finish_creation(void)
{
- char *name = atomic_exchange(&requested_creation_name, NULL);
- if (!name) return;
- uint32_t scene = MEM32(0x2b0ee7d0);
- if (scene && scene == MEM32(0x2b0ee7e0)) {
- uint32_t input = MEM32(scene + 0x88);
- if (input && MEM8(MEM32(input + 4) + 8)) {
- /* The original random-name reply uses TextInput_t::SetString, which
- * retains its length limit, string callbacks and cursor redraw. */
- unsigned size = (strlen(name) + 4) & ~3u;
- g_esp -= size;
- strcpy((char *)ADDR(g_esp), name);
- call_method(0x2701f310, MEM32(input + 8), 1, (uint32_t[]){g_esp});
- g_esp += size;
- }
+ if (!atomic_load(&requested_creation_name)) return;
+ if (!MEM32(0x2b0ee7e0)) {
+ free(atomic_exchange(&requested_creation_name, NULL));
+ return;
}
+ uint32_t scene = MEM32(0x2b0ee7d0);
+ if (scene != MEM32(0x2b0ee7e0) || MEM32(0x2b0e42a8) || MEM32(scene + 0xa4)) return;
+ uint32_t input = MEM32(scene + 0x88);
+ if (!input || !MEM8(MEM32(input + 4) + 8)) return;
+
+ /* Consume once before the original Finish path, including validation errors.
+ * SetString keeps the same editor limits and callbacks as random-name replies. */
+ char *name = atomic_exchange(&requested_creation_name, NULL);
+ unsigned size = (strlen(name) + 4) & ~3u;
+ g_esp -= size;
+ strcpy((char *)ADDR(g_esp), name);
+ call_method(0x2701f310, MEM32(input + 8), 1, (uint32_t[]){g_esp});
+ g_esp += size;
+ call_method(0x2b033cb0, scene, 0, NULL);
free(name);
}
@@ -713,7 +720,7 @@ void browser_resize_frame(void)
uint16_t control = g_fpu_cw;
resize_frame();
- update_creation_name();
+ finish_creation();
orbit_frame();
position_mobile_chat();
position_mobile_hud();
diff --git a/client/tests/browser_controls.mjs b/client/tests/browser_controls.mjs
@@ -11,7 +11,8 @@ function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149.
const modifiers = [];
const timers = new Map();
const storage = new Map(saved === null ? [] : [['ao-touch-controls', saved]]);
- const reloads = [];
+ const reloads = [], requests = [];
+ let response = new Response(null, {status: 204, headers: {'X-AO-Creation-Name': 'Phonehero'}});
const document = new EventTarget();
class Element extends EventTarget {
hidden = false;
@@ -47,7 +48,6 @@ function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149.
});
document.querySelectorAll = () => actions;
document.querySelector('#chat-compose').hidden = true;
- document.querySelector('#creation-name').hidden = true;
document.querySelector('#touch-controls').hidden = true;
document.querySelector('#reconnect').hidden = true;
const canvas = document.querySelector('#canvas');
@@ -59,7 +59,8 @@ function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149.
window.visualViewport.offsetLeft = 0;
window.visualViewport.offsetTop = 0;
const context = vm.createContext({
- document, window, navigator, Event, TextDecoder, Uint8Array,
+ document, window, navigator, Event, TextDecoder, Uint8Array, URLSearchParams,
+ fetch: async (url, options) => { requests.push({url, ...options}); return response; },
location: {reload: () => reloads.push(true)},
console: {log() {}, error: console.error},
localStorage: {getItem: key => storage.get(key) ?? null, setItem: (key, value) => storage.set(key, String(value))},
@@ -79,7 +80,7 @@ function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149.
keys.push([key, down]); repeats.push(!!repeat); modifiers.push(mods || 0);
};
context.Module._browser_input_character = character => characters.push(character);
- context.Module.setCreationName = name => creationNames.push(name);
+ context.Module.finishCreation = name => creationNames.push(name);
context.Module._browser_input_motion = (x, y) => mouse.push(['mousemove', x, y, 0]);
context.Module._browser_input_button = (button, down, x, y) => mouse.push([down ? 'mousedown' : 'mouseup', x, y, button === 3 ? 2 : 0]);
context.Module._browser_input_wheel = (x, y, vertical) => wheels.push([x, y, vertical]);
@@ -115,6 +116,7 @@ function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149.
graphics: lost => context.Module.onGraphicsStatus(lost),
chatBounds: bounds => context.Module.onChatBounds(bounds),
touchRegions: bounds => context.Module.onTouchRegions(bounds),
+ requests, respond: value => { response = value; },
creationNames, creationState: state => context.Module.onCreationState(state),
element: selector => document.querySelector(selector),
hold: () => { for (const callback of timers.values()) callback(); timers.clear(); }};
@@ -140,61 +142,75 @@ test('creator keeps its original render dimensions while the phone rotates', ()
assert.deepEqual(game.sizes.at(-1), [844, 390]);
});
-test('mobile name field sends complete composed edits once', () => {
+test('naming credentials block game keys until native Finish advances', async () => {
const game = page();
- const name = game.element('#creation-name');
- game.creationState({active: true, name: {x: 300, y: 110, width: 400, height: 40, value: 'Random'}});
- assert.equal(name.hidden, false);
- assert.equal(name.value, 'Random');
- name.focus();
- assert.equal(game.document.activeElement, name);
-
- game.fire('#creation-name', 'compositionstart');
- name.value = 'Phonehero';
- game.fire('#creation-name', 'input');
- assert.deepEqual(game.creationNames, []);
- game.fire('#creation-name', 'compositionend');
- game.fire('#creation-name', 'input');
+ game.creationState({active: true, name: null});
+ assert.equal(game.element('#creation-credentials').open, false);
+ game.creationState({active: true, name: {value: ''}});
+ game.element('#creation-player-name').value = 'phonehero';
+ game.element('#creation-password').value = 'phone password';
+ const nativeKeys = [];
+ game.window.addEventListener('keydown', event => nativeKeys.push(event.key));
+
+ const key = new Event('keydown', {cancelable: true});
+ Object.assign(key, {key: 'a', code: 'KeyA'});
+ game.window.dispatchEvent(key);
+ await game.element('#creation-form').onsubmit({preventDefault() {}});
+ await game.element('#creation-form').onsubmit({preventDefault() {}});
+ game.creationState({active: true, name: {value: ''}});
+
+ assert.equal(key.defaultPrevented, false);
+ assert.deepEqual(nativeKeys, []);
+ assert.equal(game.requests.length, 1);
+ assert.equal(game.requests[0].url, 'browser-create');
+ assert.equal(game.requests[0].method, 'POST');
+ assert.equal(game.requests[0].body.toString(), 'name=phonehero&password=phone+password');
assert.deepEqual(game.creationNames, ['Phonehero']);
- assert.deepEqual(game.characters, []);
- assert.deepEqual(game.keys, []);
- game.creationState({active: true, name: {x: 300, y: 110, width: 400, height: 40, value: 'Phone'}});
- assert.equal(name.value, 'Phonehero');
+ assert.equal(game.element('#creation-password').value, '');
+ assert.equal(game.element('#creation-credentials').open, true);
+ assert.equal(game.element('#creation-fields').disabled, true);
- const enter = new Event('keydown', {cancelable: true});
- Object.assign(enter, {key: 'Enter'});
- game.window.dispatchEvent(enter);
- assert.equal(enter.defaultPrevented, true);
+ game.creationState({active: true, name: null});
+ assert.equal(game.element('#creation-credentials').open, false);
assert.equal(game.document.activeElement, game.canvas);
- game.creationState({active: true, name: {x: 300, y: 110, width: 400, height: 40, value: 'Newrandom'}});
- assert.equal(name.value, 'Newrandom');
- game.creationState({active: false, name: null});
- assert.equal(name.hidden, true);
+ assert.deepEqual(game.sizes.at(-1), [1024, 768]);
});
-test('desktop naming uses the original field without the mobile input', () => {
- const game = page({navigator: {userAgent: 'Desktop'}});
- game.creationState({active: true, name: {x: 300, y: 110, width: 400, height: 40, value: ''}});
- assert.equal(game.element('#creation-name').hidden, true);
+test('rejected naming credentials leave the modal editable without advancing', async () => {
+ const game = page();
+ game.respond(new Response('Name already taken', {status: 409}));
+ game.creationState({active: true, name: {value: ''}});
+ game.element('#creation-player-name').value = 'Taken';
+
+ await game.element('#creation-form').onsubmit({preventDefault() {}});
+
+ assert.equal(game.element('#creation-credentials').open, true);
+ assert.equal(game.element('#creation-fields').disabled, false);
+ assert.equal(game.element('#creation-error').textContent, 'Name already taken');
+ assert.deepEqual(game.creationNames, []);
});
-test('Android Firefox name entry exits fullscreen before refocusing the keyboard', async () => {
- const game = page({navigator: {userAgent: 'Mozilla/5.0 (Android 13; Mobile) Firefox/130.0'}});
- const name = game.element('#creation-name');
- let restored = 0;
- const fullscreen = {requestFullscreen: async () => { ++restored; }};
- game.document.fullscreenElement = fullscreen;
- game.document.exitFullscreen = async () => {
- name.blur();
- game.document.fullscreenElement = null;
- };
- game.creationState({active: true, name: {x: 300, y: 110, width: 400, height: 40, value: ''}});
- name.focus();
+test('cancelling the naming modal reloads instead of exposing native controls', () => {
+ const game = page();
+ game.creationState({active: true, name: {value: ''}});
+
+ const cancel = game.fire('#creation-credentials', 'cancel');
+
+ assert.equal(cancel.defaultPrevented, true);
+ assert.equal(game.element('#creation-credentials').open, true);
+ assert.deepEqual(game.reloads, [true]);
+});
+
+test('Firefox Android leaves fullscreen for the naming keyboard', async () => {
+ const game = page();
+ game.document.fullscreenElement = game.canvas;
+ game.document.exitFullscreen = async () => { game.document.fullscreenElement = null; };
+
+ game.creationState({active: true, name: {value: ''}});
await Promise.resolve();
- assert.equal(restored, 0);
- assert.equal(game.document.activeElement, name);
- name.blur();
- assert.equal(restored, 1);
+
+ assert.equal(game.document.fullscreenElement, null);
+ assert.equal(game.document.activeElement, game.element('#creation-player-name'));
});
test('wheel over native UI bypasses the camera gesture and preserves wheel units', () => {
diff --git a/client/tests/browser_loading.mjs b/client/tests/browser_loading.mjs
@@ -96,16 +96,20 @@ async function reportsMissingWebGL() {
async function reportsUnavailableWebGLOnBothThreadsBeforeDownloading() {
const test = fixture();
+ test.context.location.href = 'http://localhost/?create=1';
+ let restoredURL;
+ test.context.history.replaceState = (state, title, url) => { restoredURL = String(url); };
test.context.document.querySelector('#canvas').transferControlToOffscreen = () => {};
let terminated = false, revoked = null;
test.context.Blob = Blob;
- test.context.URL = {
- createObjectURL() { return 'blob:graphics-probe'; },
- revokeObjectURL(url) { revoked = url; }
+ test.context.URL = class extends URL {
+ static createObjectURL() { return 'blob:graphics-probe'; }
+ static revokeObjectURL(url) { revoked = url; }
};
test.context.Worker = class {
constructor(url) {
assert.equal(url, 'blob:graphics-probe');
+ assert.equal(restoredURL, 'http://localhost/');
queueMicrotask(() => this.onmessage({data: false}));
}
terminate() { terminated = true; }
diff --git a/client/tests/browser_resolution.c b/client/tests/browser_resolution.c
@@ -2,7 +2,7 @@
#include <assert.h>
void browser_request_resize(unsigned width, unsigned height);
-void browser_creation_name(const char *name);
+void browser_creation_finish(const char *name);
void browser_chat_viewport(unsigned bottom);
void browser_orbit(int x, int y, int active);
void browser_camera_wheel(int x, int y);
@@ -31,6 +31,7 @@ static int creation_bounds[7];
static char creation_name[256];
static unsigned creation_updates;
static unsigned creation_edits;
+static unsigned creation_finishes;
static unsigned orbit_updates, orbit_stops;
static float orbit_x, orbit_y;
static unsigned camera_repositions, camera_syncs;
@@ -142,6 +143,14 @@ static void set_creation_name(void)
g_esp += 8;
}
+static void start_server_creation(void)
+{
+ assert(g_ecx == 0x50005500 && creation_edits == 1);
+ assert(!strcmp((const char *)ADDR(0x50005b00), "Phonehero"));
+ ++creation_finishes;
+ g_esp += 4;
+}
+
static void creator_name_tracks_native_field_and_random_replies(void)
{
MEM32(0x27048be8) = 1024;
@@ -172,24 +181,49 @@ static void creator_name_tracks_native_field_and_random_replies(void)
char replacement[] = "Phonehero";
uint32_t stack = g_esp;
- browser_creation_name("Phonebad");
- browser_creation_name(replacement);
+ browser_creation_finish("Phonebad");
+ browser_creation_finish(replacement);
replacement[0] = 'X';
+ MEM32(0x2b0e42a8) = 1004;
+
+ browser_resize_frame();
+
+ assert(creation_edits == 0 && creation_finishes == 0);
+ MEM32(0x2b0e42a8) = 0;
+ MEM32(0x500055a4) = 0x1008;
browser_resize_frame();
- assert(!strcmp(creation_name, "Phonehero") && creation_edits == 1);
+ assert(creation_edits == 0 && creation_finishes == 0);
+ MEM32(0x500055a4) = 0;
+ MEM8(0x50005808) = 0;
+
+ browser_resize_frame();
+
+ assert(creation_edits == 0 && creation_finishes == 0);
+ MEM8(0x50005808) = 1;
+
+ browser_resize_frame();
+ browser_resize_frame();
+
+ assert(!strcmp(creation_name, "Phonehero") && creation_edits == 1 && creation_finishes == 1);
assert(g_esp == stack && g_eax == 101 && g_st[0] == 123.5 && g_flag_cf == 112);
MEM8(0x50005808) = 0;
- browser_creation_name("Hidden");
+ browser_creation_finish("Hidden");
browser_resize_frame();
assert(creation_bounds[0] == 1 && creation_bounds[3] == 0 && !creation_name[0]);
assert(creation_edits == 1);
- MEM32(0x2b0ee7d0) = MEM32(0x2b0ee7e0) = 0;
- browser_creation_name("Departed");
+ MEM32(0x2b0ee7d0) = 0;
+ MEM32(0x2b0ee7e4) = 0x50005c00;
+ browser_resize_frame();
+
+ assert(creation_bounds[0] == 1 && creation_bounds[3] == 0);
+ assert(creation_finishes == 1);
+
+ MEM32(0x2b0ee7e0) = MEM32(0x2b0ee7e4) = 0;
browser_resize_frame();
assert(creation_bounds[0] == 0 && creation_bounds[3] == 0 && !creation_name[0]);
@@ -418,6 +452,7 @@ recomp_func_t recomp_lookup(uint32_t address)
case 8: return set_camera_position;
case 0x38004290: return synchronize_camera;
case 0x2701f310: return set_creation_name;
+ case 0x2b033cb0: return start_server_creation;
default: abort();
}
}
diff --git a/docs/character-creation.md b/docs/character-creation.md
@@ -2,10 +2,15 @@
## Native browser flow
-Options' "Create character from scratch" starts the original translated
-`ddr.dll` creator with character ID zero. Its breed, appearance, profession and
-naming scenes use the original models, controls and camera paths. The packaged
-`CharCreateCamera.dat` is exposed in the browser's game directory alongside
+Options' "Create character from scratch" starts an unnamed creation attempt and
+launches the original translated `ddr.dll` creator with character ID zero. Its
+breed, appearance, profession and naming scenes use the original models,
+controls and camera paths. At the native naming step, an HTML modal collects
+the character's login name and password. The modal makes the game controls inert,
+including Randomize, and captures keyboard events before they reach the game.
+`POST /browser-create` validates the name and attaches a salted password hash
+to that same creation attempt in memory.
+The packaged `CharCreateCamera.dat` is exposed in the browser's game directory alongside
the other root assets. The guest CRT implements `ungetc` for the native C++
camera-file parser, including buffered pushback, EOF reset and text positions.
The guest CRT also supplies the ASCII case conversion and classification used
@@ -15,20 +20,26 @@ The creator retains a 1024x768 backing surface and fits that 4:3 image inside
the browser viewport. Its original `ddr.dll::sub_2B037910` constructor caches
screen dimensions in each scene, and `sub_2B032DA0` scales creator sprites
against 1024x768. Resizing only the shared framebuffer leaves those cached
-scene layouts stale. Normal responsive world rendering resumes after creation.
-On phones, the browser keyboard input overlays the original naming field.
-`browser_resolution.c` publishes the field's actual native bounds and value:
-`ddr.dll::sub_2B0338B0` reads the name scene's `InputWindow_t` at offset 0x88,
-and `sub_2B034C40` updates that same field for random-name replies. Browser
-Whole browser edits use the original `TextInput_t::SetString` at a frame boundary,
-as native suggested-name replies do, and Finish retains the original validation.
+scene layouts stale. The creator renderer remains alive after
+`ddr.dll::sub_2B02DF70` clears its current scene for the ending animation.
+The 4:3 lifetime therefore follows the renderer through `sub_2B02DE30` shutdown;
+normal responsive world rendering resumes afterward.
+
+The canonical name comes back in the credentials response. On OK,
+`browser_resolution.c` sets the original `TextInput_t` and invokes
+`NameScene::StartServerCreation` (`sub_2B033CB0`), the same path as Finish button
+101 in `sub_2B0338B0`. The modal stays open until the native naming controls are
+disabled, preserving the input block during that handoff. Native validation and
+the ending animation remain intact. The server rejects a different final name
+and returns the prepared name for any native random-name request.
`tests/e2e/mobile-creation.test.mjs` exercises touch selection in a phone-sized
-Chromium context, rotates between portrait and landscape, replaces a name through
-the HTML editor, and checks the created name and starter inventory on the server.
-It also checks that world rendering returns to the full phone resolution after
-creation. Browser emulation verifies focus and text delivery; the physical
-phone keyboard still needs device testing.
+Chromium context, enters credentials at the naming step, checks that native
+clicks and keys are blocked, rotates between portrait and landscape, and checks
+the created name and starter inventory on the server.
+It also checks refresh before/after creation and that world rendering returns
+to the full phone resolution. Browser emulation verifies focus and text delivery;
+the physical phone keyboard still needs device testing.
The browser routes the creator's login connection to `browser-create`, using
the existing browser cookie for authorization. `server/native_creation.go`
@@ -42,14 +53,18 @@ The decoder accepts the native variable-length area and ban-reason strings
before the head/height/build fields; a captured creator packet is retained as
a protocol regression.
-One transaction saves the new character, starter items, identity counters and
-browser ownership transfer. Only a successful commit publishes the new player
-and acknowledges creation. Repeated submission on that connection returns the
+One transaction saves the new character, password credentials, starter items,
+identity counters and browser ownership transfer. Only a successful commit
+publishes the new player and acknowledges creation. Repeated submission on that connection returns the
same identity; a competing connection cannot reuse the previous credential to
create another character. Refused names and failed commits preserve the
-previous session. Exiting before successful creation returns to the previous
-character; save an unsaved visitor first to make it accessible after creating
-another character.
+previous session. A normal page launch cancels unfinished preparation under the
+same server lock used for finalization. Refresh before commit returns to the
+previous character and rejects an old creator socket; refresh after commit opens
+the new character. The one-time `?create=1` flag is removed before asynchronous
+client loading, so refresh never repeats the creation launch. Unfinished
+preparation is discarded on server restart. Save an unsaved visitor first to
+make it accessible after creating another character.
Successful creation places a neutral character in Arrival Hall 4604. The
original creator's final world handoff remains in the same client instance.
@@ -61,11 +76,10 @@ the same directory layout uses the existing temporary storage fallback.
Faction selection, deferred maps/gifts and the training-ground departure are
described in [Arrival Hall](arrival-hall.md).
-The chosen name and progress are already durable, but native creation does
-not choose a password or enable name-and-password login. Use Options' **Save
-this character** to set login credentials; it prefills the current name.
-Until then, access uses the browser cookie. Cancellation does not delete an
-existing saved character or change its password.
+The chosen name and password enable login as soon as native creation commits;
+there is no separate Save step. Passwords are not kept in browser storage or
+URLs. Cancellation does not delete an existing saved character or change its
+password.
## Starting attributes and appearance
diff --git a/server/browser_launch.go b/server/browser_launch.go
@@ -29,6 +29,19 @@ func (server *server) browserLaunch(w http.ResponseWriter, r *http.Request) {
// A browser owns one persistent character, independent of other online players.
character := server.browserCharacter_locked(r)
+ if r.URL.Query().Get("create") == "1" {
+ if character == nil {
+ http.Error(w, "Your browser session has ended. Reconnect to continue.", http.StatusUnauthorized)
+ return
+ }
+ if server.browserCreations == nil {
+ server.browserCreations = make(map[string]*browserCreationCredentials)
+ }
+ server.browserCreations[character.browserTokenHash] = &browserCreationCredentials{}
+ } else if character != nil {
+ // Returning to the game cancels any unfinished creator using this credential.
+ delete(server.browserCreations, character.browserTokenHash)
+ }
if character == nil {
token := rand.Text()
character = server.newCharacter_locked()
diff --git a/server/http.go b/server/http.go
@@ -26,6 +26,7 @@ func (server *server) httpHandler() http.Handler {
mux.HandleFunc("GET /browser-world", server.browserWorld)
mux.HandleFunc("GET /browser-chat", server.browserChat)
mux.HandleFunc("GET /browser-create", server.browserCreate)
+ mux.Handle("POST /browser-create", http.NewCrossOriginProtection().Handler(http.HandlerFunc(server.prepareBrowserCreation)))
mux.HandleFunc("GET /browser-manifest", browserManifest)
mux.HandleFunc("GET /browser-resource-index", browserResourceIndex)
mux.HandleFunc("GET /wasm/", server.browserClient)
diff --git a/server/native_creation.go b/server/native_creation.go
@@ -17,6 +17,65 @@ import (
"github.com/coder/websocket"
)
+type browserCreationCredentials struct {
+ name string
+ salt, hash []byte
+}
+
+func (server *server) prepareBrowserCreation(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "no-store")
+ r.Body = http.MaxBytesReader(w, r.Body, 4096)
+ if err := r.ParseForm(); err != nil {
+ http.Error(w, "Invalid account form.", http.StatusBadRequest)
+ return
+ }
+ name, valid := browserPlayerName(r.PostForm.Get("name"))
+ password := r.PostForm.Get("password")
+ if !valid || len(password) > 1024 {
+ http.Error(w, "Use a name of 4-12 letters or digits, with at least four initial letters and digits only at the end, and a password up to 1024 bytes.", http.StatusBadRequest)
+ return
+ }
+ server.mutex.Lock()
+ current := server.browserCharacter_locked(r)
+ if current == nil {
+ server.mutex.Unlock()
+ http.Error(w, "Your browser session has ended. Reconnect to continue.", http.StatusUnauthorized)
+ return
+ }
+ currentID, credential := current.id, current.browserTokenHash
+ pending := server.browserCreations[credential]
+ server.mutex.Unlock()
+ if pending == nil {
+ http.Error(w, "Start character creation first.", http.StatusConflict)
+ return
+ }
+
+ // Keep only salted credentials while the original creator runs.
+ salt := make([]byte, 16)
+ rand.Read(salt)
+ hash := server.browserPassword(password, salt)
+ server.mutex.Lock()
+ defer server.mutex.Unlock()
+ current = server.browserCharacter_locked(r)
+ if current == nil || current.id != currentID || current.browserTokenHash != credential {
+ http.Error(w, "Your browser session changed. Reconnect to continue.", http.StatusUnauthorized)
+ return
+ }
+ if server.browserCreations[credential] != pending {
+ http.Error(w, "Character creation has ended. Start again to continue.", http.StatusConflict)
+ return
+ }
+ for _, other := range server.characters {
+ if !other.npc && strings.EqualFold(other.name, name) {
+ http.Error(w, "That player name is already in use.", http.StatusConflict)
+ return
+ }
+ }
+ pending.name, pending.salt, pending.hash = name, salt, hash
+ w.Header().Set("X-AO-Creation-Name", name)
+ w.WriteHeader(http.StatusNoContent)
+}
+
func (server *server) browserCreate(w http.ResponseWriter, r *http.Request) {
server.mutex.Lock()
current := server.browserCharacter_locked(r)
@@ -25,23 +84,28 @@ func (server *server) browserCreate(w http.ResponseWriter, r *http.Request) {
if current != nil {
id, credential = current.id, current.browserTokenHash
}
+ pending := server.browserCreations[credential]
server.mutex.Unlock()
if id == 0 {
http.Error(w, "Open the game page to start a visitor session.", http.StatusUnauthorized)
return
}
+ if pending == nil {
+ http.Error(w, "Start character creation first.", http.StatusConflict)
+ return
+ }
socket, err := websocket.Accept(w, r, nil)
if err != nil {
return
}
defer socket.CloseNow()
connection := websocket.NetConn(context.Background(), socket, websocket.MessageBinary)
- if err := server.serveNativeCreation(connection, id, credential); err != nil {
+ if err := server.serveNativeCreation(connection, id, credential, pending); err != nil {
log.Printf("Browser creation connection: %v", err)
}
}
-func (server *server) serveNativeCreation(conn net.Conn, currentID uint32, credential string) error {
+func (server *server) serveNativeCreation(conn net.Conn, currentID uint32, credential string, pending *browserCreationCredentials) error {
var createdID uint32
for {
packet, err := readPacket(conn)
@@ -61,12 +125,17 @@ func (server *server) serveNativeCreation(conn net.Conn, currentID uint32, crede
// The browser cookie authenticates this connection, independently of launcher credentials.
response = systemPacket(0x0e, binary.BigEndian.AppendUint32(nil, 0))
case 0x55:
- name := randomVisitorName()
+ server.mutex.Lock()
+ name := pending.name
+ server.mutex.Unlock()
+ if name == "" {
+ name = randomVisitorName()
+ }
response = systemPacket(0x56, append(binary.BigEndian.AppendUint16(nil, uint16(len(name))), name...))
case 0x0f:
var reason uint32
if createdID == 0 {
- createdID, reason, err = server.createNativeCharacter(currentID, credential, packet[20:])
+ createdID, reason, err = server.createNativeCharacter(currentID, credential, pending, packet[20:])
if err != nil {
log.Printf("Creating browser character: %v", err)
reason = 9
@@ -95,7 +164,7 @@ func (server *server) serveNativeCreation(conn net.Conn, currentID uint32, crede
}
}
-func (server *server) createNativeCharacter(currentID uint32, credential string, body []byte) (uint32, uint32, error) {
+func (server *server) createNativeCharacter(currentID uint32, credential string, pending *browserCreationCredentials, body []byte) (uint32, uint32, error) {
// nr.dll!CharacterData_t::WriteDataStream and CharacterInfo_c::WriteStream use version 4.
if len(body) < 89 || binary.BigEndian.Uint32(body) != 4 || body[8] != 'a' || binary.BigEndian.Uint32(body[37:]) != 4 {
return 0, 9, nil
@@ -106,7 +175,7 @@ func (server *server) createNativeCharacter(currentID uint32, credential string,
}
name, valid := browserPlayerName(string(body[49 : 49+length]))
if !valid {
- return 0, 9, nil
+ return 0, 0x1f, nil
}
fields := body[49+length:]
breed, sex := binary.BigEndian.Uint32(fields), binary.BigEndian.Uint32(fields[4:])
@@ -155,9 +224,12 @@ func (server *server) createNativeCharacter(currentID uint32, credential string,
server.mutex.Lock()
defer server.mutex.Unlock()
current := server.characters[currentID]
- if current == nil || current.browserTokenHash != credential {
+ if current == nil || current.browserTokenHash != credential || server.browserCreations[credential] != pending || len(pending.hash) == 0 {
return 0, 2, nil
}
+ if name != pending.name {
+ return 0, 0x1f, nil
+ }
for _, other := range server.characters {
if !other.npc && strings.EqualFold(other.name, name) {
return 0, 0x1e, nil
@@ -185,7 +257,7 @@ func (server *server) createNativeCharacter(currentID uint32, credential string,
}
defer tx.Rollback()
abandoned := fmt.Sprintf("%x", sha256.Sum256([]byte(rand.Text())))
- if err := server.insertBrowserPlayer_locked(tx, player, []byte{}, []byte{}); err != nil {
+ if err := server.insertBrowserPlayer_locked(tx, player, pending.salt, pending.hash); err != nil {
return 0, 0, err
}
if err := updateRecord(tx, "characters", currentID, "browser_token_hash", []any{abandoned}); err != nil {
@@ -195,6 +267,7 @@ func (server *server) createNativeCharacter(currentID uint32, credential string,
return 0, 0, err
}
server.publishBrowserPlayer_locked(player)
+ delete(server.browserCreations, credential)
current.browserTokenHash, current.savedProfile.BrowserTokenHash = abandoned, abandoned
if client := server.clients[currentID]; client != nil {
server.cancelPlayerTrade_locked(client)
diff --git a/server/native_creation_test.go b/server/native_creation_test.go
@@ -7,13 +7,44 @@ import (
"net"
"net/http"
"net/http/httptest"
+ "net/url"
"reflect"
+ "strings"
"testing"
"time"
"github.com/coder/websocket"
)
+func nativePreparationRequest(world *server, cookie *http.Cookie, name, password string) *httptest.ResponseRecorder {
+ request := httptest.NewRequest("POST", world.baseURL+"browser-create", strings.NewReader(url.Values{"name": {name}, "password": {password}}.Encode()))
+ request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ if cookie != nil {
+ request.AddCookie(cookie)
+ }
+ response := httptest.NewRecorder()
+ world.httpHandler().ServeHTTP(response, request)
+ return response
+}
+
+func prepareNativeCreation(t *testing.T, world *server, cookie *http.Cookie, name, password string) {
+ t.Helper()
+ if response := nativePreparationRequest(world, cookie, name, password); response.Code != http.StatusNoContent || response.Header().Get("X-AO-Creation-Name") == "" {
+ t.Fatal("could not prepare native creation", response.Code, response.Body.String())
+ }
+}
+
+func startNativeCreation(t *testing.T, world *server, cookie *http.Cookie) {
+ t.Helper()
+ request := httptest.NewRequest("POST", world.baseURL+"browser-launch?create=1", nil)
+ request.AddCookie(cookie)
+ response := httptest.NewRecorder()
+ world.httpHandler().ServeHTTP(response, request)
+ if response.Code != http.StatusOK {
+ t.Fatal("could not start native creation", response.Code, response.Body.String())
+ }
+}
+
func nativeCreationConnection(t *testing.T, world *server, cookie *http.Cookie) net.Conn {
t.Helper()
host := httptest.NewServer(world.httpHandler())
@@ -60,7 +91,9 @@ func TestNativeCreationCapturedClientRequest(t *testing.T) {
t.Run(scenario, func(t *testing.T) {
world := newTestServer(t)
cookie := accountVisitor(t, world)
+ startNativeCreation(t, world, cookie)
connection := nativeCreationConnection(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Nativehero", "secret")
// Actual creator: Atrox Enforcer, head 29, tall, heavy, area "area unknown".
packet, err := hex.DecodeString("dfdf00010001008300000000000000010000000f0000000400000000610000000000000000000000000000000000000000000000000000000000000004000000000000000a4e61746976656865726f000000040000000100000009000000000000000c6172656120756e6b6e6f776e00000000000000000000001d0000006e0000000215")
if err != nil {
@@ -102,16 +135,23 @@ func TestNativeCreationPersistsAndRedirects(t *testing.T) {
}
cookie = claimed.Result().Cookies()[0]
before := world.characters[1].profile()
+ startNativeCreation(t, world, cookie)
connection := nativeCreationConnection(t, world, cookie)
+ prepared := nativePreparationRequest(world, cookie, "ALICE", "new secret")
+ if prepared.Code != http.StatusNoContent || prepared.Header().Get("X-AO-Creation-Name") != "Alice" {
+ t.Fatal("naming did not return its canonical name", prepared.Code, prepared.Header())
+ }
challenge := nativeCreationExchange(t, connection, systemPacket(0x22, nil))
authenticated := nativeCreationExchange(t, connection, systemPacket(0x25, nil))
+ suggested := nativeCreationExchange(t, connection, systemPacket(0x55, nil))
created := nativeCreationExchange(t, connection, nativeCreationAlice(t))
repeated := nativeCreationExchange(t, connection, nativeCreationAlice(t))
redirect := nativeCreationExchange(t, connection, systemPacket(0x16, []byte{0, 0, 0, 2}))
restored := newTestInventoryServer(t)
if binary.BigEndian.Uint32(challenge) != 0x24 || hex.EncodeToString(authenticated) != "0000000e00000000" ||
+ hex.EncodeToString(suggested) != "000000560005416c696365" || len(world.browserCreations) != 0 ||
hex.EncodeToString(created) != "0000001100000002" || !reflect.DeepEqual(created, repeated) ||
hex.EncodeToString(redirect) != "00000017000000027f0000011dc40000000000000000" {
t.Fatalf("native creation replies: challenge=%x auth=%x created=%x repeat=%x redirect=%x", challenge, authenticated, created, repeated, redirect)
@@ -142,14 +182,11 @@ func TestNativeCreationPersistsAndRedirects(t *testing.T) {
}
func TestNativeCreationRefusalAndFailedCommitRetainSession(t *testing.T) {
- for _, scenario := range []string{"name taken", "invalid head", "truncated", "insert failure", "ownership failure", "commit failure", "cancel"} {
+ for _, scenario := range []string{"invalid head", "truncated", "insert failure", "ownership failure", "commit failure", "cancel"} {
t.Run(scenario, func(t *testing.T) {
world := newTestServer(t)
cookie := accountVisitor(t, world)
- if scenario == "name taken" {
- response := accountRequest(world, cookie, "claim", "Alice", "secret")
- cookie = response.Result().Cookies()[0]
- }
+ startNativeCreation(t, world, cookie)
before := world.characters[1].profile()
lastItem := world.nextItem
packet := nativeCreationAlice(t)
@@ -171,6 +208,7 @@ func TestNativeCreationRefusalAndFailedCommitRetainSession(t *testing.T) {
}
}
connection := nativeCreationConnection(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Alice", "secret")
nativeCreationExchange(t, connection, systemPacket(0x25, nil))
var response []byte
@@ -182,9 +220,6 @@ func TestNativeCreationRefusalAndFailedCommitRetainSession(t *testing.T) {
if scenario != "cancel" {
want := "0000001000000009"
- if scenario == "name taken" {
- want = "000000100000001e"
- }
if hex.EncodeToString(response) != want {
t.Fatalf("refusal %x, want %s", response, want)
}
@@ -212,8 +247,10 @@ func TestNativeCreationRefusalAndFailedCommitRetainSession(t *testing.T) {
func TestNativeCreationCompetingConnectionCannotCreateTwice(t *testing.T) {
world := newTestServer(t)
cookie := accountVisitor(t, world)
+ startNativeCreation(t, world, cookie)
first := nativeCreationConnection(t, world, cookie)
second := nativeCreationConnection(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Alice", "secret")
responses := make(chan []byte, 2)
packet := nativeCreationAlice(t)
@@ -237,22 +274,23 @@ func TestNativeCreationCompetingConnectionCannotCreateTwice(t *testing.T) {
}
}
-func TestNativeCreationLoginRequiresExplicitSave(t *testing.T) {
+func TestNativeCreationPreparedPasswordSurvivesRestart(t *testing.T) {
for _, password := range []string{"", "chosen password"} {
t.Run(password, func(t *testing.T) {
world := newTestServer(t)
cookie := accountVisitor(t, world)
- nativeCreationExchange(t, nativeCreationConnection(t, world, cookie), nativeCreationAlice(t))
+ startNativeCreation(t, world, cookie)
+ connection := nativeCreationConnection(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Alice", password)
+ nativeCreationExchange(t, connection, nativeCreationAlice(t))
+ restored := newTestInventoryServer(t)
+ restored.baseURL = "/"
- beforeSave := accountRequest(world, cookie, "login", "Alice", "")
- saved := accountRequest(world, cookie, "claim", "Alice", password)
- if saved.Code != http.StatusNoContent {
- t.Fatal("could not explicitly save native character", saved.Body.String())
- }
- loggedIn := accountRequest(world, saved.Result().Cookies()[0], "login", "Alice", password)
+ wrong := accountRequest(restored, cookie, "login", "Alice", "wrong password")
+ loggedIn := accountRequest(restored, cookie, "login", "Alice", password)
- if beforeSave.Code != http.StatusUnauthorized || loggedIn.Code != http.StatusNoContent || world.nextCharacter != 2 {
- t.Fatal("native creation enabled login without an explicit password choice or could not save", beforeSave.Code, loggedIn.Code)
+ if wrong.Code != http.StatusUnauthorized || loggedIn.Code != http.StatusNoContent || restored.nextCharacter != 2 {
+ t.Fatal("prepared credentials did not survive creation and restart", wrong.Code, loggedIn.Code)
}
})
}
@@ -268,3 +306,180 @@ func TestNativeCreationRequiresBrowserCredential(t *testing.T) {
t.Fatal("unauthenticated browser entered character creation", response.Code)
}
}
+
+func TestNativeCreationPreparationRejectsInvalidCredentials(t *testing.T) {
+ for _, scenario := range []string{"invalid name", "long password", "duplicate name", "no session"} {
+ t.Run(scenario, func(t *testing.T) {
+ world := newTestServer(t)
+ cookie := accountVisitor(t, world)
+ startNativeCreation(t, world, cookie)
+ connection := nativeCreationConnection(t, world, cookie)
+ before := world.characters[1].profile()
+ name, password, want := "Alice", "secret", http.StatusBadRequest
+ switch scenario {
+ case "invalid name":
+ name = "A1"
+ case "long password":
+ password = strings.Repeat("x", 1025)
+ case "duplicate name":
+ name, want = strings.ToLower(before.Name), http.StatusConflict
+ case "no session":
+ cookie, want = nil, http.StatusUnauthorized
+ }
+
+ response := nativePreparationRequest(world, cookie, name, password)
+ refused := nativeCreationExchange(t, connection, nativeCreationAlice(t))
+
+ if response.Code != want || hex.EncodeToString(refused) != "0000001000000002" || world.characters[1].profile() != before || world.nextCharacter != 1 {
+ t.Fatal("invalid preparation changed the current character", response.Code, response.Body.String())
+ }
+ })
+ }
+}
+
+func TestNativeCreationRequiresAttemptAndCredentials(t *testing.T) {
+ world := newTestServer(t)
+ cookie := accountVisitor(t, world)
+ before := world.characters[1].profile()
+ prepared := nativePreparationRequest(world, cookie, "Alice", "secret")
+ request := httptest.NewRequest("GET", "/browser-create", nil)
+ request.AddCookie(cookie)
+ response := httptest.NewRecorder()
+ world.httpHandler().ServeHTTP(response, request)
+ if prepared.Code != http.StatusConflict || response.Code != http.StatusConflict {
+ t.Fatal("creation without an attempt was accepted", prepared.Code, response.Code)
+ }
+
+ startNativeCreation(t, world, cookie)
+ connection := nativeCreationConnection(t, world, cookie)
+ refused := nativeCreationExchange(t, connection, nativeCreationAlice(t))
+
+ if hex.EncodeToString(refused) != "0000001000000002" || world.characters[1].profile() != before || world.nextCharacter != 1 {
+ t.Fatalf("attempt without credentials created a character: %x", refused)
+ }
+}
+
+func TestNativeCreationCannotChangePreparedIdentity(t *testing.T) {
+ for _, scenario := range []string{"forged name", "replaced attempt"} {
+ t.Run(scenario, func(t *testing.T) {
+ world := newTestServer(t)
+ cookie := accountVisitor(t, world)
+ before := world.characters[1].profile()
+ startNativeCreation(t, world, cookie)
+ connection := nativeCreationConnection(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Alice", "first secret")
+ packet, want := nativeCreationAlice(t), "000000100000001f"
+ if scenario == "forged name" {
+ copy(packet[69:74], "Bobby")
+ } else {
+ startNativeCreation(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Alice", "second secret")
+ want = "0000001000000002"
+ }
+
+ response := nativeCreationExchange(t, connection, packet)
+
+ if hex.EncodeToString(response) != want || world.nextCharacter != 1 || world.characters[1].profile() != before {
+ t.Fatalf("native request changed prepared credentials: %x", response)
+ }
+ })
+ }
+}
+
+func TestNativeCreationRechecksNameAtFinalization(t *testing.T) {
+ world := newTestServer(t)
+ first, second := accountVisitor(t, world), accountVisitor(t, world)
+ startNativeCreation(t, world, first)
+ startNativeCreation(t, world, second)
+ one := nativeCreationConnection(t, world, first)
+ two := nativeCreationConnection(t, world, second)
+ prepareNativeCreation(t, world, first, "Alice", "first secret")
+ prepareNativeCreation(t, world, second, "Alice", "second secret")
+
+ created := nativeCreationExchange(t, one, nativeCreationAlice(t))
+ refused := nativeCreationExchange(t, two, nativeCreationAlice(t))
+
+ if hex.EncodeToString(created) != "0000001100000003" || hex.EncodeToString(refused) != "000000100000001e" || world.nextCharacter != 3 {
+ t.Fatalf("competing prepared names created duplicate characters: %x %x", created, refused)
+ }
+ if response := accountRequest(world, second, "login", "Alice", "first secret"); response.Code != http.StatusNoContent {
+ t.Fatal("competing preparation replaced the committed password", response.Code)
+ }
+}
+
+func TestNativeCreationNormalLaunchCancelsUnfinishedCreation(t *testing.T) {
+ world := newTestServer(t)
+ cookie := accountVisitor(t, world)
+ startNativeCreation(t, world, cookie)
+ connection := nativeCreationConnection(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Alice", "secret")
+ before, lastItem := world.characters[1].profile(), world.nextItem
+ request := httptest.NewRequest("POST", "/browser-launch", nil)
+ request.AddCookie(cookie)
+ launched := httptest.NewRecorder()
+
+ world.httpHandler().ServeHTTP(launched, request)
+ refused := nativeCreationExchange(t, connection, nativeCreationAlice(t))
+ creator := httptest.NewRequest("GET", "/browser-create", nil)
+ creator.AddCookie(cookie)
+ unprepared := httptest.NewRecorder()
+ world.httpHandler().ServeHTTP(unprepared, creator)
+
+ if launched.Code != http.StatusOK || !strings.Contains(launched.Body.String(), "localtest localtest 1 ") ||
+ hex.EncodeToString(refused) != "0000001000000002" || unprepared.Code != http.StatusConflict ||
+ world.characters[1].profile() != before || world.nextCharacter != 1 || world.nextItem != lastItem {
+ t.Fatalf("normal launch did not cancel creation without changing the current character: %d %x %d", launched.Code, refused, unprepared.Code)
+ }
+}
+
+func TestNativeCreationNormalLaunchKeepsCommittedCharacter(t *testing.T) {
+ world := newTestServer(t)
+ cookie := accountVisitor(t, world)
+ startNativeCreation(t, world, cookie)
+ connection := nativeCreationConnection(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Alice", "secret")
+ nativeCreationExchange(t, connection, nativeCreationAlice(t))
+ before, lastItem := world.characters[2].profile(), world.nextItem
+
+ for range 2 {
+ request := httptest.NewRequest("POST", "/browser-launch", nil)
+ request.AddCookie(cookie)
+ response := httptest.NewRecorder()
+ world.httpHandler().ServeHTTP(response, request)
+ if response.Code != http.StatusOK || !strings.Contains(response.Body.String(), "localtest localtest 2 ") ||
+ world.characters[2].profile() != before || world.nextCharacter != 2 || world.nextItem != lastItem {
+ t.Fatal("refresh after creation changed or duplicated the committed character", response.Code, response.Body.String())
+ }
+ }
+ request := httptest.NewRequest("GET", "/browser-create", nil)
+ request.AddCookie(cookie)
+ response := httptest.NewRecorder()
+ world.httpHandler().ServeHTTP(response, request)
+ if response.Code != http.StatusConflict {
+ t.Fatal("completed creation could relaunch without fresh preparation", response.Code)
+ }
+}
+
+func TestNativeCreationRestartCancelsUnfinishedPreparation(t *testing.T) {
+ world := newTestServer(t)
+ cookie := accountVisitor(t, world)
+ claimed := accountRequest(world, cookie, "claim", "Previous", "secret")
+ if claimed.Code != http.StatusNoContent {
+ t.Fatal(claimed.Body.String())
+ }
+ cookie = claimed.Result().Cookies()[0]
+ startNativeCreation(t, world, cookie)
+ prepareNativeCreation(t, world, cookie, "Alice", "new secret")
+ restored := newTestInventoryServer(t)
+ restored.baseURL = "/"
+ request := httptest.NewRequest("GET", "/browser-create", nil)
+ request.AddCookie(cookie)
+ response := httptest.NewRecorder()
+
+ restored.httpHandler().ServeHTTP(response, request)
+ loggedIn := accountRequest(restored, cookie, "login", "Previous", "secret")
+
+ if response.Code != http.StatusConflict || loggedIn.Code != http.StatusNoContent || restored.nextCharacter != 1 {
+ t.Fatal("restart retained unfinished creation or lost the previous character", response.Code, loggedIn.Code)
+ }
+}
diff --git a/server/state.go b/server/state.go
@@ -154,6 +154,7 @@ type server struct {
chats map[uint32]*chatClient
chatLogMutex sync.Mutex
browserStreams map[string]*browserStream
+ browserCreations map[string]*browserCreationCredentials
weather int
weatherUntil time.Time
nextWeather time.Time
diff --git a/tests/e2e/arrival-hall.test.mjs b/tests/e2e/arrival-hall.test.mjs
@@ -6,6 +6,11 @@ before(buildServer);
async function createHallCharacter(fixture, name) {
const context = await fixture.visitor();
+ const launched = await context.request.post(fixture.url + '/browser-launch?create=1');
+ assert.equal(launched.status(), 200);
+ const prepared = await context.request.post(fixture.url + '/browser-create',
+ {form: {name, password: 'arrival hall regression password'}});
+ assert.equal(prepared.status(), 204);
// Controlled precondition: the original create packet supplies a Hall player;
// creation-screen coverage belongs to the separate complete-flow regression.
// Same original Atrox Enforcer packet as server/native_creation_test.go.
diff --git a/tests/e2e/mobile-creation.test.mjs b/tests/e2e/mobile-creation.test.mjs
@@ -1,23 +1,25 @@
import assert from 'node:assert/strict';
import {before, test} from 'node:test';
import {buildServer, withFixture} from './fixture.mjs';
-import {GameTest} from '../../tools/client/game_test.mjs';
before(buildServer);
-test('mobile creator preserves proportions across rotation and accepts a real name input',
-{timeout: 360_000}, async () => withFixture('mobile-creation', async fixture => {
+test('mobile naming modal blocks native controls, survives refresh and preserves proportions',
+{timeout: 480_000}, async () => withFixture('mobile-creation', async fixture => {
const context = await fixture.browser.newContext({viewport: {width: 390, height: 844},
isMobile: true, hasTouch: true, deviceScaleFactor: 2,
userAgent: 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 Chrome/130.0.0.0 Mobile Safari/537.36'});
const visitor = await context.request.post(fixture.url + '/browser-launch');
assert.equal(visitor.status(), 200);
- const page = await context.newPage();
- const game = await GameTest.attach(page);
+ const original = await fixture.state(context);
+ const game = await fixture.game(context);
+ const page = game.page;
const touch = await context.newCDPSession(page);
- fixture.games.push(game);
- await page.goto(fixture.url + '/?create=1');
- await page.waitForFunction(() => typeof Module._browser_test_request === 'function', null, {timeout: 180000});
+ const begin = async () => {
+ await page.locator('#menu-button').tap();
+ await Promise.all([page.waitForEvent('load'), page.locator('#create-button').tap()]);
+ await page.waitForFunction(() => typeof Module._browser_test_request === 'function', null, {timeout: 180000});
+ };
const scene = id => game.wait('native creator scene ' + id,
state => state.creation?.scene === id && state.creation.ready, 60000);
const next = () => game.wait('native Next enabled', state => state.regions.some(
@@ -42,6 +44,15 @@ test('mobile creator preserves proportions across rotation and accepts a real na
assert(canvas.y + canvas.height <= page.viewportSize().height + 1);
};
+ await begin();
+ await scene(1001);
+ assert.equal(new URL(page.url()).searchParams.has('create'), false);
+ await page.reload();
+ await game.ready();
+ assert.equal((await fixture.state(context)).id, original.id);
+ assert.equal(game.state.creation, null);
+
+ await begin();
await scene(1001);
await proportions();
await game.save(fixture.output + '/portrait-breed');
@@ -61,26 +72,55 @@ test('mobile creator preserves proportions across rotation and accepts a real na
await scene(1003);
await tap(850, 514);
await next();
+ // Observe the native lifetime signal, including its scene-less ending animation.
+ await page.evaluate(() => {
+ window.creationPhases = [];
+ const publish = Module.onCreationState;
+ Module.onCreationState = state => {
+ publish(state);
+ window.creationPhases.push({active: state.active, screen: renderSize(),
+ width: canvas.getBoundingClientRect().width, height: canvas.getBoundingClientRect().height});
+ };
+ });
await tap(946, 730);
- await scene(1004);
- const name = page.locator('#creation-name');
- await name.tap();
- assert.equal(await name.evaluate(element => document.activeElement === element), true);
- await page.keyboard.insertText('Phonebad');
- await page.keyboard.press('Control+A');
+ await page.locator('#creation-credentials').waitFor({state: 'visible'});
+ await page.locator('#creation-player-name').tap();
+ assert.equal(await page.locator('#creation-player-name').evaluate(element => document.activeElement === element), true);
await page.keyboard.insertText('Phonehero');
- await page.keyboard.press('Enter');
- await page.waitForFunction(() => creationNameBounds?.value === 'Phonehero');
- await game.save(fixture.output + '/portrait-name');
- await tap(945, 730);
+ await page.locator('#creation-password').tap();
+ await page.keyboard.insertText('phone password');
+ await game.snapshot();
+ const blockedSequence = game.sequence;
+ const finish = await game.point(945, 730);
+ await page.mouse.click(finish.x, finish.y);
+ await page.keyboard.press('ArrowLeft');
+ await game.snapshot();
+ assert.equal(await page.locator('#creation-credentials').isVisible(), true);
+ assert.equal((await fixture.state(context)).id, original.id);
+ assert.equal(game.events.some(event => event.sequence > blockedSequence &&
+ event.kind === 'input' && [768, 769, 1025, 1026].includes(event.type)), false);
+ await game.save(fixture.output + '/naming-dialog');
+ await page.locator('#creation-submit').tap();
await game.ready();
await game.wait('full-screen world after native creation', state =>
state.screen[0] === 390 && state.screen[1] === 844);
- assert.equal(await name.isVisible(), false);
+ const phases = await page.evaluate(() => window.creationPhases);
+ assert(phases.some(state => state.active));
+ assert.equal(phases.at(-1).active, false);
+ for (const state of phases.filter(state => state.active)) {
+ assert.deepEqual(state.screen, [1024, 768]);
+ assert(Math.abs(state.width / state.height - 4 / 3) < 0.001);
+ }
const created = await fixture.state(context);
assert.equal(created.name, 'Phonehero');
assert.equal(created.playfield, 4604);
assert.equal(created.items.length, 4);
+ const account = await context.request.get(fixture.url + '/browser-account');
+ assert.equal((await account.json()).adopted, true);
+ await page.reload();
+ await game.ready();
+ assert.equal((await fixture.state(context)).id, created.id);
+ assert.equal(game.state.creation, null);
assert.deepEqual(game.errors, []);
await game.save(fixture.output + '/arrival');
}));
diff --git a/tests/e2e/native-creation.test.mjs b/tests/e2e/native-creation.test.mjs
@@ -1,11 +1,11 @@
import assert from 'node:assert/strict';
import {before, test} from 'node:test';
import {buildServer, withFixture} from './fixture.mjs';
-import {startStarter, finishStarter, enterOmniTraining, saveStarter} from '../../tools/client/create_starter.mjs';
+import {startStarter, enterOmniTraining} from '../../tools/client/create_starter.mjs';
before(buildServer);
-test('native creator preserves cancellation, validates names and saves the complete starter journey',
+test('native creation credentials preserve cancellation and the complete starter journey',
{timeout: 900_000}, async () => withFixture('native-creation', async fixture => {
const context = await fixture.visitor();
const claimed = await context.request.post(fixture.url + '/browser-account/claim',
@@ -41,36 +41,41 @@ test('native creator preserves cancellation, validates names and saves the compl
console.log('PASS: native cancellation preserves the existing character');
await startStarter(game);
- await game.click(507, 130);
- await game.page.keyboard.type('ab', {delay: 60});
- await game.click(945, 730);
- await game.wait('native invalid-name message', state => state.regions.some(
- ([left, top, right, bottom]) => left === 472 && top === 435 && right === 542 && bottom === 455));
- assert.equal(packets.filter(({direction, packet}) => direction === 'framesent' && packet.readUInt32BE(16) === 0x0f).length, 0);
- await game.save(fixture.output + '/invalid-name');
- await game.click(507, 445);
- await game.click(507, 130);
- await game.key('Backspace');
- await game.key('Backspace');
- await game.page.keyboard.type('Existing', {delay: 60});
- await game.click(945, 730);
- await game.wait('server rejects an existing name', state => state.creation?.nameState === 0 &&
- packets.some(({direction, packet}) => direction === 'framereceived' && packet.readUInt32BE(16) === 0x10 && packet.readUInt32BE(20) === 0x1e));
- assert.equal((await fixture.state(context)).id, original.id);
- await game.save(fixture.output + '/duplicate-name');
- console.log('PASS: native short-name and duplicate-name errors preserve the existing character');
- const okay = game.state.regions.find(([left, top, right, bottom]) => right - left === 70 && bottom - top === 20);
- assert(okay);
- await game.click((okay[0] + okay[2]) / 2, (okay[1] + okay[3]) / 2);
- await game.click(507, 130);
- await game.key('End');
- for (let index = 0; index < 8; ++index) await game.key('Backspace');
- await finishStarter(game, 'Nativehero');
+ await game.click(946, 730);
+ await game.page.locator('#creation-credentials').waitFor({state: 'visible'});
+
+ // Browser fields validate credentials at the native naming step, before creation commits.
+ for (const [name, status] of [['ab', 400], ['Existing', 409]]) {
+ await game.page.locator('#creation-player-name').fill(name);
+ await game.page.locator('#creation-password').fill('native password');
+ const [response] = await Promise.all([
+ game.page.waitForResponse(response => response.url().endsWith('/browser-create') && response.request().method() === 'POST'),
+ game.page.locator('#creation-submit').click(),
+ ]);
+ assert.equal(response.status(), status);
+ await game.page.waitForFunction(() => document.querySelector('#creation-error').textContent !== '' &&
+ !document.querySelector('#creation-submit').disabled);
+ assert.equal((await fixture.state(context)).id, original.id);
+ assert.deepEqual((await fixture.state(context)).items, original.items);
+ assert.equal(packets.filter(({direction, packet}) => direction === 'framesent' && packet.readUInt32BE(16) === 0x0f).length, 0);
+ await game.save(fixture.output + '/' + (name === 'ab' ? 'invalid-name' : 'duplicate-name'));
+ }
+ console.log('PASS: short-name and duplicate-name errors preserve the existing character at native naming');
+
+ await game.page.locator('#creation-player-name').fill('Nativehero');
+ await game.page.locator('#creation-password').fill('native password');
+ await game.page.locator('#creation-submit').click();
+ await game.ready();
+ assert.equal(game.local().playfield, 4604);
+ assert.equal(game.local().stats[4], 4);
+ assert.equal(game.local().stats[60], 9);
await game.save(fixture.output + '/arrival');
const created = await fixture.state(context);
assert.equal(created.name, 'Nativehero');
assert.equal(created.items.length, 4);
assert.deepEqual(created.items.map(item => item.templates[0]), [116628, 116629, 121564, 43379]);
+ const account = await context.request.get(fixture.url + '/browser-account');
+ assert.equal((await account.json()).adopted, true);
await enterOmniTraining(game);
await game.save(fixture.output + '/training');
const departed = await fixture.state(context);
@@ -89,10 +94,11 @@ test('native creator preserves cancellation, validates names and saves the compl
await game.wait('starter item picked up', state => state.dragged[0] === 104);
await clickCell(grid(game.state).cells.find(cell => cell.index === 8));
await game.wait('starter layout saved', state => state.dragged[0] === 0 && firstItem(state).index === 8);
- await saveStarter(game, 'Nativehero', 'native password');
+ await game.page.reload();
+ await game.ready();
if (!game.state.grids.some(grid => grid.cells.some(cell => cell.identity[0] === 104))) await game.key('i');
assert.equal(firstItem(game.state).index, 8);
- console.log('PASS: newly created character preferences survive saving and reload');
+ console.log('PASS: newly created character preferences survive reload');
assert.equal((await fixture.state(context)).id, created.id);
assert.deepEqual((await fixture.state(context)).items, departed.items);
diff --git a/tools/client/create_starter.mjs b/tools/client/create_starter.mjs
@@ -21,31 +21,21 @@ export async function startStarter(game) {
await game.click(850, 514);
await game.wait('selected Enforcer enables Next', state => state.regions.some(
([left, top, right, bottom]) => left === 888 && top === 710 && right === 1006 && bottom === 749));
- await game.click(946, 730);
- await game.wait('native naming', state => state.creation?.scene === 1004 && state.creation.ready, 60000);
}
-export async function finishStarter(game, name) {
- // Native Finish commits the chosen character and connects it to Arrival Hall.
- await game.click(507, 130);
- await game.page.keyboard.type(name, {delay: 60});
- await game.click(945, 730);
+export async function finishStarter(game, name, password) {
+ // The native naming step opens the browser's keyboard-capable credential fields.
+ await game.click(946, 730);
+ await game.page.locator('#creation-credentials').waitFor({state: 'visible'});
+ await game.page.locator('#creation-player-name').fill(name);
+ await game.page.locator('#creation-password').fill(password);
+ await game.page.locator('#creation-submit').click();
await game.ready();
assert.equal(game.local().playfield, 4604);
assert.equal(game.local().stats[4], 4);
assert.equal(game.local().stats[60], 9);
}
-export async function saveStarter(game, name, password) {
- // Native naming keeps cookie ownership; explicitly save login credentials in Options.
- await game.page.keyboard.press('Control+Alt+M');
- await game.page.locator('#claim-button').click();
- assert.equal(await game.page.locator('#account-name').inputValue(), name);
- await game.page.locator('#account-password').fill(password);
- await Promise.all([game.page.waitForEvent('load'), game.page.locator('#account-submit').click()]);
- await game.ready();
-}
-
export async function enterOmniTraining(game) {
// Walk through the Hall's central barrier opening to the Omni desk.
if (!game.state.camera.firstPerson) await game.key('F8');
diff --git a/tools/client/test_starter_equipment.mjs b/tools/client/test_starter_equipment.mjs
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import {createRequire} from 'node:module';
import {GameTest} from './game_test.mjs';
-import {startStarter, finishStarter, enterOmniTraining, saveStarter} from './create_starter.mjs';
+import {startStarter, finishStarter, enterOmniTraining} from './create_starter.mjs';
const {chromium} = createRequire(import.meta.url)('playwright');
const [url, output] = process.argv.slice(2);
@@ -263,9 +263,8 @@ try {
await page.goto(url);
await game.ready();
await startStarter(game);
- await finishStarter(game, name);
+ await finishStarter(game, name, 'starter regression password');
await enterOmniTraining(game);
- await saveStarter(game, name, 'starter regression password');
assert.equal(game.local().playfield, 950);
assert.equal(game.local().inventory.length, 7);
assert.equal(game.local().stats[54], 1);
diff --git a/tools/client/test_starter_mission_targets.mjs b/tools/client/test_starter_mission_targets.mjs
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import {createRequire} from 'node:module';
import {GameTest} from './game_test.mjs';
-import {startStarter, finishStarter, enterOmniTraining, saveStarter} from './create_starter.mjs';
+import {startStarter, finishStarter, enterOmniTraining} from './create_starter.mjs';
const {chromium} = createRequire(import.meta.url)('playwright');
const [url, output] = process.argv.slice(2);
@@ -19,9 +19,8 @@ try {
await page.goto(url);
await game.ready();
await startStarter(game);
- await finishStarter(game, 'Missionpick');
+ await finishStarter(game, 'Missionpick', 'mission target regression password');
await enterOmniTraining(game);
- await saveStarter(game, 'Missionpick', 'mission target regression password');
assert.equal(game.local().playfield, 950);
const issued = game.local().inventory;
await game.save(output + '/created');