commit 98deeffa0a7474c1933fb39f8be349c2e79c6640
parent f613f18336d731e836e396ca5c92c39b9f3ca995
Author: anon <anon@example.com>
Date: Fri, 6 Nov 2026 22:07:23 +0000
Fix mobile native creation and Arrival Hall corridor exits
Diffstat:
14 files changed, 740 insertions(+), 34 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -35,7 +35,12 @@ research separately. More screenshots and test cases do not count as new gamepla
## P0: first experience
-- [x] **Use the original native character creation flow.** Options now launches
+- [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
+ 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,
diff --git a/client/browser/index.html b/client/browser/index.html
@@ -10,6 +10,9 @@
@font-face { font-family: GameVerdana; src: url('browser-assets/fonts/verdana.ttf'); }
#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; }
@@ -61,6 +64,7 @@
</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>
@@ -137,6 +141,7 @@
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
pixelMode.value = localStorage.getItem('ao-pixel-mode') === 'retina' ? 'retina' : 'css';
let runtimeReady = false, gameReady = false, restarting = false;
+ let creatorActive = false, creatorSeen = false;
let sessionReplaced = false;
let accountRequest = false, accountClosed = null;
let recording = null, reportURL = null;
@@ -200,10 +205,16 @@
// Keep CSS layout fixed while the render worker changes its backing pixels.
function renderSize() {
+ if (creatorActive) return [1024, 768];
const scale = pixelMode.value === 'retina' ? devicePixelRatio : 1;
return [Math.round(canvas.clientWidth * scale), Math.round(canvas.clientHeight * scale)];
}
function updateResolution() {
+ if (creatorActive) {
+ const width = Math.min(gameSurface.clientWidth, gameSurface.clientHeight * 4 / 3);
+ canvas.style.width = `${width}px`;
+ canvas.style.height = `${width * 3 / 4}px`;
+ }
if (!canvas.clientWidth || !canvas.clientHeight) return;
const [width, height] = renderSize();
document.querySelector('#render-size').textContent = `${width} x ${height} pixels`;
@@ -213,6 +224,16 @@
Module._browser_hud_insets(inset, document.fullscreenElement ? inset : 0);
}
}
+ function setCreatorActive(active) {
+ if (creatorActive === active) return;
+ creatorActive = active;
+ if (active) gameSurface.dataset.creation = '';
+ else {
+ delete gameSurface.dataset.creation;
+ canvas.style.width = canvas.style.height = '';
+ }
+ updateResolution();
+ }
pixelMode.onchange = () => {
localStorage.setItem('ao-pixel-mode', pixelMode.value);
updateResolution();
@@ -235,6 +256,7 @@
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.
@@ -383,6 +405,7 @@ show();
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'});
@@ -406,6 +429,66 @@ 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;
+ 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;
+ }
+ 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;
+ });
+ }
+ };
+ 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;
+ }
+ };
const movePad = document.querySelector('#move-pad');
const autorunButton = document.querySelector('#autorun-button');
const gameToolbar = document.querySelector('#game-toolbar');
@@ -900,6 +983,13 @@ show();
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
@@ -134,6 +134,20 @@ addToLibrary({
});
Module.onTouchRegions?.({regions, screenWidth, screenHeight});
},
+ ao_creation_state__proxy: 'sync',
+ ao_creation_state__deps: ['$UTF8ToString', '$stringToNewUTF8', 'free', 'browser_creation_name'],
+ ao_creation_state: (bounds, name) => {
+ Module.setCreationName ||= value => {
+ const text = stringToNewUTF8(value);
+ _browser_creation_name(text);
+ _free(text);
+ };
+ const offset = bounds >> 2;
+ Module.onCreationState?.({active: !!HEAP32[offset],
+ name: HEAP32[offset + 3] ? {x: HEAP32[offset + 1], y: HEAP32[offset + 2],
+ width: HEAP32[offset + 3], height: HEAP32[offset + 4], value: UTF8ToString(name)} : null,
+ screenWidth: HEAP32[offset + 5], screenHeight: HEAP32[offset + 6]});
+ },
$AOFrameWait: 0,
ao_frame_begin__deps: ['$AOProfile', '$AOFrameWait', '$AOTest'],
ao_frame_begin: (timestamp) => {
diff --git a/client/runtime/browser_resolution.c b/client/runtime/browser_resolution.c
@@ -17,6 +17,7 @@ static _Atomic int orbit_zoom;
static _Atomic int cursor_hidden;
static _Atomic uint32_t hud_insets;
static _Atomic int chat_scroll_pixels;
+static _Atomic(char *) requested_creation_name;
static int chat_scroll_remainder;
static uint32_t chat_width_owner;
static unsigned chat_max_width;
@@ -30,6 +31,37 @@ static struct {
void ao_chat_bounds(int x, int y, int width, int height, int screen_width, int screen_height,
int output_x, int output_y, int output_width, int output_height);
void ao_touch_regions(const int *regions, unsigned count, int screen_width, int screen_height);
+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)};
+ const char *name = "";
+ /* NameScene_t::sub_2B0338B0 reads the InputWindow_t and its native string. */
+ if (scene && scene == MEM32(0x2b0ee7e0)) {
+ uint32_t input = MEM32(scene + 0x88);
+ if (input && MEM8(MEM32(input + 4) + 8)) {
+ uint32_t window = MEM32(input);
+ for (unsigned i = 0; i < 4; ++i) bounds[i + 1] = MEM32(window + 0x2c + i * 4);
+ uint32_t text = MEM32(MEM32(MEM32(input + 8) + 0x50) + 4);
+ if (text) name = (const char *)ADDR(text);
+ }
+ }
+
+ /* Include native edits and random-name replies even when layout is unchanged. */
+ static void *previous;
+ static size_t previous_size;
+ size_t size = sizeof(bounds) + strlen(name) + 1;
+ if (previous_size == size && !memcmp(previous, bounds, sizeof(bounds)) &&
+ !strcmp((const char *)previous + sizeof(bounds), name)) return;
+ previous = realloc(previous, size);
+ if (!previous) abort();
+ previous_size = size;
+ memcpy(previous, bounds, sizeof(bounds));
+ memcpy((char *)previous + sizeof(bounds), name, size - sizeof(bounds));
+ ao_creation_state(previous, (const char *)previous + sizeof(bounds));
+}
static void publish_touch_regions(void)
{
@@ -92,6 +124,13 @@ 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)
+{
+ char *copy = strdup(name);
+ if (!copy) abort();
+ free(atomic_exchange(&requested_creation_name, copy));
+}
+
EMSCRIPTEN_KEEPALIVE void browser_chat_viewport(unsigned bottom)
{
atomic_store(&chat_viewport_bottom, bottom);
@@ -154,6 +193,26 @@ static void call_method(uint32_t address, uint32_t object, unsigned count,
assert(g_esp == stack);
}
+static void update_creation_name(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;
+ }
+ }
+ free(name);
+}
+
static void orbit_frame(void)
{
/* Consume each wheel once, even when several events arrive between frames. */
@@ -635,9 +694,11 @@ void browser_resize_frame(void)
{
if (!atomic_load(&requested_size) && !atomic_load(&chat_viewport_bottom) && !mobile_chat.chat &&
!atomic_load(&orbit_active) && !orbit_running && !atomic_load(&wheel_x) &&
- !atomic_load(&wheel_y) && !atomic_load(&hud_insets) && !hud_adjusted) {
+ !atomic_load(&wheel_y) && !atomic_load(&hud_insets) && !hud_adjusted &&
+ !atomic_load(&requested_creation_name)) {
publish_chat_bounds();
publish_touch_regions();
+ publish_creation_state();
return;
}
@@ -652,12 +713,14 @@ void browser_resize_frame(void)
uint16_t control = g_fpu_cw;
resize_frame();
+ update_creation_name();
orbit_frame();
position_mobile_chat();
position_mobile_hud();
scroll_mobile_chat();
publish_chat_bounds();
publish_touch_regions();
+ publish_creation_state();
g_eax = registers[0]; g_ecx = registers[1]; g_edx = registers[2];
g_ebx = registers[3]; g_esi = registers[4]; g_edi = registers[5];
diff --git a/client/tests/browser_controls.mjs b/client/tests/browser_controls.mjs
@@ -6,7 +6,7 @@ import test from 'node:test';
function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149.0'}, saved = null, ready = true} = {}) {
const elements = new Map();
const keys = [], characters = [], mouse = [], orbits = [], sizes = [], chatViewports = [], cursorHidden = [], hudInsets = [];
- const scrolls = [], zooms = [], wheels = [], cameraWheels = [];
+ const scrolls = [], zooms = [], wheels = [], cameraWheels = [], creationNames = [];
const repeats = [];
const modifiers = [];
const timers = new Map();
@@ -47,6 +47,7 @@ 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');
@@ -78,6 +79,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._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]);
@@ -113,10 +115,88 @@ 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),
+ creationNames, creationState: state => context.Module.onCreationState(state),
element: selector => document.querySelector(selector),
hold: () => { for (const callback of timers.values()) callback(); timers.clear(); }};
}
+test('creator keeps its original render dimensions while the phone rotates', () => {
+ const game = page();
+ game.creationState({active: true, name: null});
+ assert.deepEqual(game.sizes.at(-1), [1024, 768]);
+ assert.equal(game.canvas.style.width, '520px');
+ assert.equal(game.canvas.style.height, '390px');
+
+ game.element('#game-surface').clientWidth = 390;
+ game.element('#game-surface').clientHeight = 844;
+ game.window.dispatchEvent(new Event('resize'));
+ assert.equal(game.canvas.style.width, '390px');
+ assert.equal(game.canvas.style.height, '292.5px');
+ assert.deepEqual(game.sizes.at(-1), [1024, 768]);
+
+ game.creationState({active: false, name: null});
+ assert.equal(game.canvas.style.width, '');
+ assert.equal(game.canvas.style.height, '');
+ assert.deepEqual(game.sizes.at(-1), [844, 390]);
+});
+
+test('mobile name field sends complete composed edits once', () => {
+ 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');
+ 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');
+
+ const enter = new Event('keydown', {cancelable: true});
+ Object.assign(enter, {key: 'Enter'});
+ game.window.dispatchEvent(enter);
+ assert.equal(enter.defaultPrevented, true);
+ 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);
+});
+
+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('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();
+ await Promise.resolve();
+ assert.equal(restored, 0);
+ assert.equal(game.document.activeElement, name);
+ name.blur();
+ assert.equal(restored, 1);
+});
+
test('wheel over native UI bypasses the camera gesture and preserves wheel units', () => {
const game = page({navigator: {userAgent: 'Mozilla/5.0 (X11; Linux x86_64) Chrome/156.0.0.0'}});
game.touchRegions({screenWidth: 844, screenHeight: 390, regions: [
diff --git a/client/tests/browser_loading.mjs b/client/tests/browser_loading.mjs
@@ -12,7 +12,7 @@ function fixture(response) {
percentages.push(value);
}};
const downloadFill = {style: {set width(value) { widths.push(value); }}};
- const canvas = {addEventListener() {}, getContext() { return null; }};
+ const canvas = {style: {}, dataset: {}, addEventListener() {}, getContext() { return null; }};
const context = vm.createContext({
console, WebAssembly, Response, TransformStream, URL, crossOriginIsolated: true,
location: {href: 'http://localhost/'}, history: {replaceState() {}},
diff --git a/client/tests/browser_resolution.c b/client/tests/browser_resolution.c
@@ -2,6 +2,7 @@
#include <assert.h>
void browser_request_resize(unsigned width, unsigned height);
+void browser_creation_name(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);
@@ -26,6 +27,10 @@ static unsigned toolbar_changes;
static int touch_regions[10];
static unsigned touch_count, touch_updates;
static int touch_width, touch_height;
+static int creation_bounds[7];
+static char creation_name[256];
+static unsigned creation_updates;
+static unsigned creation_edits;
static unsigned orbit_updates, orbit_stops;
static float orbit_x, orbit_y;
static unsigned camera_repositions, camera_syncs;
@@ -119,6 +124,78 @@ void ao_touch_regions(const int *regions, unsigned count, int screen_width, int
++touch_updates;
}
+void ao_creation_state(const int *bounds, const char *name)
+{
+ memcpy(creation_bounds, bounds, sizeof(creation_bounds));
+ snprintf(creation_name, sizeof(creation_name), "%s", name);
+ ++creation_updates;
+}
+
+static void set_creation_name(void)
+{
+ assert(g_ecx == 0x50005900);
+ strcpy((char *)ADDR(0x50005b00), (const char *)ADDR(MEM32(g_esp + 4)));
+ ++creation_edits;
+ g_eax = 999;
+ g_st[0] = -1;
+ g_flag_cf = 0;
+ g_esp += 8;
+}
+
+static void creator_name_tracks_native_field_and_random_replies(void)
+{
+ MEM32(0x27048be8) = 1024;
+ MEM32(0x27048bec) = 768;
+ MEM32(0x2b0ee7d0) = MEM32(0x2b0ee7e0) = 0x50005500;
+ MEM32(0x50005588) = 0x50005600;
+ MEM32(0x50005600) = 0x50005700;
+ MEM32(0x50005604) = 0x50005800;
+ MEM32(0x50005608) = 0x50005900;
+ MEM8(0x50005808) = 1;
+ MEM32(0x50005950) = 0x50005a00;
+ MEM32(0x50005a04) = 0x50005b00;
+ memcpy((void *)ADDR(0x5000572c), (int[]){358, 123, 310, 16}, 16);
+ strcpy((char *)ADDR(0x50005b00), "Nativehero");
+
+ browser_resize_frame();
+ unsigned published = creation_updates;
+ browser_resize_frame();
+
+ assert(!memcmp(creation_bounds, (int[]){1, 358, 123, 310, 16, 1024, 768}, sizeof(creation_bounds)));
+ assert(!strcmp(creation_name, "Nativehero"));
+ assert(creation_updates == published);
+
+ strcpy((char *)ADDR(0x50005b00), "Randomhero");
+ browser_resize_frame();
+
+ assert(!strcmp(creation_name, "Randomhero") && creation_updates == published + 1);
+
+ char replacement[] = "Phonehero";
+ uint32_t stack = g_esp;
+ browser_creation_name("Phonebad");
+ browser_creation_name(replacement);
+ replacement[0] = 'X';
+
+ browser_resize_frame();
+
+ assert(!strcmp(creation_name, "Phonehero") && creation_edits == 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_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");
+ browser_resize_frame();
+
+ assert(creation_bounds[0] == 0 && creation_bounds[3] == 0 && !creation_name[0]);
+ assert(creation_edits == 1);
+}
+
static void toggle_toolbar(void)
{
assert(g_ecx == 0x50003600);
@@ -340,6 +417,7 @@ recomp_func_t recomp_lookup(uint32_t address)
case 0x38001f50: return get_camera_target;
case 8: return set_camera_position;
case 0x38004290: return synchronize_camera;
+ case 0x2701f310: return set_creation_name;
default: abort();
}
}
@@ -908,6 +986,7 @@ int main(void)
wheel_camera_consumes_a_burst_once();
stopping_camera_cancels_pending_wheels();
wheel_camera_preserves_an_active_touch_orbit();
+ creator_name_tracks_native_field_and_random_replies();
puts("Browser resize, guest state, mobile chat, camera orbit, wheel and pinch zoom checks passed");
return 0;
}
diff --git a/docs/arrival-hall.md b/docs/arrival-hall.md
@@ -2,10 +2,11 @@
Native character creation enters playfield 4604 before selecting a faction.
The player receives the profession starter kit there. Faction maps and gifts
-are issued only when leaving the Hall through one of its three representatives.
-Right-click a representative and choose the explicit departure option in the
-original client's conversation window. The other choice ends the conversation
-without committing a side.
+are issued only when leaving the Hall. Walk down the corridor marked Clan,
+Neutral or Omni to choose that faction and enter its training ground. Talking
+to a representative is optional. Their native conversation also offers an
+explicit departure choice; the other choice ends the conversation without
+committing a side.
The provisional entry position `[190, 1.52, 200]` is clear lobby floor facing the
three booths. The central gap between the queue barriers is walkable via XZ
@@ -44,13 +45,35 @@ selection. A bounded search of that mirror found no representative dialogue
transcripts. The implemented conversation is concise provisional guidance, with
no invented historical lore or claim to reproduce the original wording.
-Resource `1000026/4604` contains no type-51016 door records. Its payload SHA-256
-is `6c11a9db46ce2a55c6cc446e0242adc69b715ae75cf8c420d01625eee8f37024`;
-the extraction is retained locally in `local/native-creation-arrival/`.
-Native conversation departure is an explicit reconstruction policy until the
-original commitment and exit trigger is established. Training destinations use
-`server/starting.go` and the existing authored training-door transforms and
-clearance policy described in [character creation](character-creation.md).
+Resource `1000026/4604` contains no type-51016 door records, but it does contain
+six type-51005 collision statels. Its payload SHA-256 is
+`6c11a9db46ce2a55c6cc446e0242adc69b715ae75cf8c420d01625eee8f37024`.
+The complete records and decoded descriptors are retained locally in
+`local/native-creation-arrival/statels.json`.
+
+| Collision statel | Authored label | XYZ | Set Side (stat 33) |
+| --- | --- | --- | --- |
+| `51005:0xc00011fc` | Neutral | 182.74585, 1.3142736, 157.6853 | 0 |
+| `51005:0xc00411fc` | Clan | 192.28783, 1.3145673, 157.6162 | 1 |
+| `51005:0xc00511fc` | Omni | 172.67474, 1.3137777, 157.44034 | 2 |
+
+Each has event 3 (OnCollide), a Set53026 assignment to Side, profession-dependent
+SpawnItemACG53064 functions, and Teleport53016 to `[183,2,154]`, `[192,2,154]`
+or `[173,2,154]` in the current playfield. The three further statels
+`0xc00111fc`, `0xc00211fc` and `0xc00311fc` sit at those corridor ends, are named
+"Exit to clan", "Exit to neutral" and "Exit to Omni-Tek", and run function53142
+with arguments `[0,65000,0,0]`. The original server routing behind that last
+function and the precise native collision meshes remain unresolved.
+
+The server handles departure within two metres of the authored Side-assignment
+statel, before the blocked end of each corridor. This envelope is provisional;
+the positions and faction assignments are original data. Native walking
+reproduced the missing transition at neutral `[182.53348,1.04013,156.85481]` and
+Clan `[191.99001,1.04013,156.50694]` before the fix. The server completes the
+side/item/zone transaction directly instead of requiring a separate local
+teleport to the second statel. Training destinations use `server/starting.go`
+and the existing authored training-door transforms and clearance policy
+described in [character creation](character-creation.md).
Original items 201025 and 201026 execute the client commands
`/afcm_addprogram PROGRAM_ARRIVAL_HALL` and
@@ -69,9 +92,12 @@ copy the spawn conversation flag into that stat; default action
`kkr.dll!sub_3602C350` reads it. Without the stat replay, a right-click on a
dressed representative sends a player-trade request instead of opening dialogue.
Departure rechecks the active world connection, living player, neutral state,
-Hall playfield, representative identity, visibility and ten-metre proximity.
+and Hall playfield. Corridor departure rechecks proximity to the authored
+collision statel; conversation departure checks representative identity,
+visibility and ten-metre proximity.
A pending trade must finish first, and the inventory must have room for all
-issued items. These are current server policies.
+issued items. A refused corridor attempt is reported once; stepping out and
+back retries it. These are current server policies.
One item-store transaction writes the side, training position and return door,
chosen startup map, and the existing Clan or Omni startup gifts. Only after
@@ -83,8 +109,9 @@ connection's repeated answer cannot issue rewards again. Reconnection resumes
the committed destination and inventory.
Focused protocol tests in `server/arrival_hall_test.go` cover all three sides,
-repeated answers, persistence after restart, cancellation, distance/playfield
-changes, unoffered choices, and rollback of a failed transaction. These are
+repeated answers, all three corridors without conversation, stopped-player
+crossings, persistence after restart, cancellation, distance/playfield changes,
+unoffered choices, failure/retry, inventory refusal and transaction rollback. These are
controlled fixture checks, not earned-progression evidence.
`tests/e2e/arrival-hall.test.mjs` establishes a neutral Hall character with the
@@ -94,3 +121,6 @@ departure. The test checks the training playfield, exactly one starting map,
the ended conversation, and unchanged inventory after a cold restart. The native
widget retains its transcript until the player closes it. This
isolates Hall behavior; it does not stand in for the full creator UI journey.
+The same file also places controlled new characters at each corridor entrance
+and uses real native walking input to cross all three authored triggers, checking
+the destination, side and exact deferred rewards against server state.
diff --git a/docs/character-creation.md b/docs/character-creation.md
@@ -11,6 +11,25 @@ camera-file parser, including buffered pushback, EOF reset and text positions.
The guest CRT also supplies the ASCII case conversion and classification used
by breed selection and the original name validator.
+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.
+
+`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.
+
The browser routes the creator's login connection to `browser-create`, using
the existing browser cookie for authorization. `server/native_creation.go`
handles the native challenge/login exchange (`0x22/0x24`, `0x25/0x0e`), random
diff --git a/server/arrival_hall.go b/server/arrival_hall.go
@@ -45,18 +45,44 @@ func arrivalHallDialogue(group, choice string) gamedata.Dialogue {
func (server *server) leaveArrivalHall(client *worldClient, npcID uint32, side uint16) (string, error) {
server.updateMutex.Lock()
defer server.updateMutex.Unlock()
+ return server.leaveArrivalHall_locked(client, npcID, side)
+}
+
+func arrivalHallExit(position [3]float32) (uint16, bool) {
+ // Original OnCollide statels set Side at the three corridor ends. See arrival-hall.md.
+ for side, exit := range [3][3]float32{
+ {182.74585, 1.3142736, 157.6853},
+ {192.28783, 1.3145673, 157.6162},
+ {172.67474, 1.3137777, 157.44034},
+ } {
+ x, y, z := position[0]-exit[0], position[1]-exit[1], position[2]-exit[2]
+ if x*x+y*y+z*z <= 2*2 {
+ return uint16(side), true
+ }
+ }
+ return 0, false
+}
+
+func (server *server) leaveArrivalHall_locked(client *worldClient, npcID uint32, side uint16) (string, error) {
server.mutex.Lock()
player, npc := server.characters[client.id], server.characters[npcID]
if server.clients[client.id] != client || !client.ready || client.loading || player.health == 0 ||
- player.playfield != 4604 || unpackAppearance(player.appearance).Side != 0 ||
- npc == nil || !npc.npc || npc.playfield != 4604 || !client.npcs[npcID] {
+ player.playfield != 4604 || unpackAppearance(player.appearance).Side != 0 {
server.mutex.Unlock()
return "", nil
}
- selected, representative := arrivalHallSide(npc.npcDefinitionID)
position := predictedPosition_locked(player, time.Now())
- x, y, z := npc.position[0]-position[0], npc.position[1]-position[1], npc.position[2]-position[2]
- if !representative || selected != side || x*x+y*y+z*z > 10*10 {
+ selected, permitted := arrivalHallExit(position)
+ if npcID != 0 {
+ if npc == nil || !npc.npc || npc.playfield != 4604 || !client.npcs[npcID] {
+ server.mutex.Unlock()
+ return "", nil
+ }
+ selected, permitted = arrivalHallSide(npc.npcDefinitionID)
+ x, y, z := npc.position[0]-position[0], npc.position[1]-position[1], npc.position[2]-position[2]
+ permitted = permitted && x*x+y*y+z*z <= 10*10
+ }
+ if !permitted || selected != side {
server.mutex.Unlock()
return "", nil
}
@@ -87,7 +113,7 @@ func (server *server) leaveArrivalHall(client *worldClient, npcID uint32, side u
slot := updated.inventory.freeSlot()
if slot == 94 {
server.mutex.Unlock()
- return "Make room in your inventory for your starting map and equipment, then speak to me again.", nil
+ return "Make room in your inventory for your starting map and equipment, then try leaving again.", nil
}
definition := gamedata.ItemTemplates[template]
updated.inventory.LastID++
@@ -110,9 +136,10 @@ func (server *server) leaveArrivalHall(client *worldClient, npcID uint32, side u
// Departure is the one-time completion gate; reconnect resumes the committed zone.
updated.savedProfile, updated.savedPosition, updated.savedVitals = updated.profile(), start, updated.vitals()
- updates := map[*worldClient][][]byte{client: {
- npcDialoguePacket(0x270a4c62, client.id, npcID, []byte{0, 0, 0, 5, 0, 0, 0, 0}),
- }}
+ updates := make(map[*worldClient][][]byte)
+ if client.dialogue != nil {
+ updates[client] = append(updates[client], npcDialoguePacket(0x270a4c62, client.id, client.dialogue.npc, []byte{0, 0, 0, 5, 0, 0, 0, 0}))
+ }
client.dialogue = nil
server.replaceUser_locked(player, &updated, updates)
server.mutex.Unlock()
diff --git a/server/arrival_hall_test.go b/server/arrival_hall_test.go
@@ -139,6 +139,157 @@ func TestArrivalHallFactionDepartureCommitsOnceAndSurvivesRestart(t *testing.T)
}
}
+func TestArrivalHallCorridorsCommitOnceWithoutConversation(t *testing.T) {
+ for _, scenario := range []struct {
+ side uint16
+ position [3]float32
+ playfield uint32
+ templates []uint32
+ }{
+ {0, [3]float32{183, 1.04, 158}, 954, []uint32{116628, 116629, 121569, 29092, 116697}},
+ {1, [3]float32{192, 1.04, 158}, 952, []uint32{116628, 116629, 121569, 29092, 116696, 96358}},
+ {2, [3]float32{173, 1.04, 158}, 950, []uint32{116628, 116629, 121569, 29092, 116693, 99719, 29426}},
+ } {
+ t.Run(fmt.Sprint(scenario.side), func(t *testing.T) {
+ world, _ := arrivalHallTestWorld(t, "4604/district/0/fixed/1")
+ connection := connectZoningClient(t, world, true)
+ world.mutex.Lock()
+ world.characters[1].position = scenario.position
+ world.mutex.Unlock()
+
+ // A stopped player already inside a corridor must still leave on the zoning tick.
+ done := make(chan struct{})
+ go func() { world.advanceZoneCrossings(time.Now()); close(done) }()
+ for _, key := range []uint32{0x43197d22, 0x3c} {
+ packet, err := readPacket(connection)
+ if err != nil || binary.BigEndian.Uint32(packet[16:20]) != key {
+ t.Fatalf("corridor native departure: %x %v", packet, err)
+ }
+ }
+ <-done
+ world.advanceZoneCrossings(time.Now())
+ restored := newTestInventoryServer(t)
+
+ player := restored.characters[1]
+ var templates []uint32
+ for _, item := range player.inventory.Items {
+ templates = append(templates, item.Template)
+ }
+ if player.playfield != scenario.playfield || unpackAppearance(player.appearance).Side != scenario.side ||
+ !slices.Equal(templates, scenario.templates) || player.returnDoor == nil ||
+ !reflect.DeepEqual(player.inventory.Items, world.characters[1].inventory.Items) || restored.nextItem != world.nextItem {
+ t.Fatalf("corridor departure lost faction, destination or items: %+v %v", player.record(), templates)
+ }
+ })
+ }
+}
+
+func TestArrivalHallCorridorsIgnoreOtherPositionsAndStates(t *testing.T) {
+ for _, scenario := range []string{"lobby", "desk", "between exits", "above exit", "other playfield", "already sided", "dead"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, _ := arrivalHallTestWorld(t, "4604/district/0/fixed/1")
+ connectZoningClient(t, world, true)
+ world.mutex.Lock()
+ player := world.characters[1]
+ player.position = [3]float32{183, 1.04, 158}
+ switch scenario {
+ case "lobby":
+ player.position = [3]float32{190, 1.04, 200}
+ case "desk":
+ player.position = [3]float32{186, 1.04, 163}
+ case "between exits":
+ player.position = [3]float32{188, 1.04, 158}
+ case "above exit":
+ player.position[1] = 5
+ case "other playfield":
+ player.playfield = 705
+ case "already sided":
+ player.appearance |= 2 << 9
+ case "dead":
+ player.health = 0
+ }
+ before, items := player.record(), maps.Clone(world.items)
+ world.mutex.Unlock()
+
+ world.advanceZoneCrossings(time.Now())
+
+ if !reflect.DeepEqual(player.record(), before) || !reflect.DeepEqual(world.items, items) {
+ t.Fatalf("invalid corridor entry changed player or items: %+v", player.record())
+ }
+ })
+ }
+}
+
+func TestArrivalHallCorridorFailedCommitLeavesCharacterAndItemsUnchanged(t *testing.T) {
+ world, _ := arrivalHallTestWorld(t, "4604/district/0/fixed/1")
+ connection := connectZoningClient(t, world, true)
+ world.mutex.Lock()
+ world.characters[1].position = [3]float32{173, 1.04, 158}
+ before, items, lastItem := world.characters[1].record(), maps.Clone(world.items), world.nextItem
+ world.mutex.Unlock()
+ if _, err := world.db.Exec("CREATE TRIGGER reject_corridor BEFORE UPDATE OF playfield ON characters BEGIN SELECT RAISE(ABORT, 'corridor failure'); END"); err != nil {
+ t.Fatal(err)
+ }
+
+ world.advanceZoneCrossings(time.Now())
+
+ if !reflect.DeepEqual(world.characters[1].record(), before) || !reflect.DeepEqual(world.items, items) || world.nextItem != lastItem {
+ t.Fatal("failed corridor departure published partial state")
+ }
+
+ // A failed exit can be retried by stepping out and back after the failure clears.
+ if _, err := world.db.Exec("DROP TRIGGER reject_corridor"); err != nil {
+ t.Fatal(err)
+ }
+ world.mutex.Lock()
+ world.characters[1].position = [3]float32{173, 1.04, 164}
+ world.mutex.Unlock()
+ world.advanceZoneCrossings(time.Now())
+ world.mutex.Lock()
+ world.characters[1].position = [3]float32{173, 1.04, 158}
+ world.mutex.Unlock()
+ done := make(chan struct{})
+ go func() { world.advanceZoneCrossings(time.Now()); close(done) }()
+ for _, key := range []uint32{0x43197d22, 0x3c} {
+ packet, err := readPacket(connection)
+ if err != nil || binary.BigEndian.Uint32(packet[16:20]) != key {
+ t.Fatalf("retried corridor departure: %x %v", packet, err)
+ }
+ }
+ <-done
+ if world.characters[1].playfield != 950 || len(world.characters[1].inventory.Items) != 7 {
+ t.Fatal("retried corridor departure did not reach Omni training with its items")
+ }
+}
+
+func TestArrivalHallCorridorInventoryRefusalIsNotRepeatedEveryTick(t *testing.T) {
+ world, _ := arrivalHallTestWorld(t, "4604/district/0/fixed/1")
+ player := world.characters[1]
+ inventory := player.inventory
+ inventory.Items = slices.Clone(inventory.Items)
+ for len(inventory.Items) < 29 {
+ item := inventory.Items[2]
+ inventory.LastID++
+ item.ID, item.Slot = inventory.LastID, inventory.freeSlot()
+ inventory.Items = append(inventory.Items, item)
+ }
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ connectZoningClient(t, world, true)
+ world.mutex.Lock()
+ player.position = [3]float32{173, 1.04, 158}
+ before, items := player.record(), maps.Clone(world.items)
+ world.mutex.Unlock()
+
+ world.advanceZoneCrossings(time.Now())
+ world.advanceZoneCrossings(time.Now())
+
+ if !reflect.DeepEqual(player.record(), before) || !reflect.DeepEqual(world.items, items) || len(world.clients[1].doorMessages) != 1 {
+ t.Fatal("inventory refusal changed state or repeated without leaving the exit")
+ }
+}
+
func TestArrivalHallChoiceRevalidatesPositionAndCanBeCancelled(t *testing.T) {
for _, scenario := range []string{"cancel", "distant", "other playfield", "unoffered"} {
t.Run(scenario, func(t *testing.T) {
diff --git a/server/zoning.go b/server/zoning.go
@@ -226,6 +226,7 @@ func (server *server) advanceZoneCrossings(now time.Time) {
// The native client sends start/stop controls rather than every walking frame.
server.mutex.Lock()
var destinations []userData
+ hallExits := make(map[*worldClient]uint16)
updates := make(map[*worldClient][][]byte)
server.advanceCityDoors_locked(now, updates)
messages := make(map[*chatClient][][]byte)
@@ -240,14 +241,26 @@ func (server *server) advanceZoneCrossings(now time.Time) {
}
client.doorMessages = nil
}
- if !server.characters[id].movement.active() && server.characters[id].followTarget == 0 {
- continue
- }
character := *server.characters[id]
if character.health == 0 {
continue
}
character.position = predictedPosition_locked(&character, now)
+ // Include stopped players: a native stop packet can already be inside the exit.
+ if character.playfield == 4604 {
+ side, inside := arrivalHallExit(character.position)
+ origin := doorOrigin{4604, uint32(side) + 1}
+ if !inside {
+ client.enteredDoor = doorOrigin{}
+ } else if client.enteredDoor != origin {
+ client.enteredDoor = origin
+ hallExits[client] = side
+ }
+ continue
+ }
+ if !character.movement.active() && character.followTarget == 0 {
+ continue
+ }
destination, err := server.zoneDestination_locked(&character, client)
if err != nil {
log.Printf("Automatic mission zoning: %v", err)
@@ -259,6 +272,17 @@ func (server *server) advanceZoneCrossings(now time.Time) {
}
server.mutex.Unlock()
server.sendCombatUpdates(updates)
+ for client, side := range hallExits {
+ message, err := server.leaveArrivalHall_locked(client, 0, side)
+ if err != nil {
+ log.Printf("Arrival Hall exit: %v", err)
+ }
+ if message != "" {
+ server.mutex.Lock()
+ client.doorMessages = append(client.doorMessages, message)
+ server.mutex.Unlock()
+ }
+ }
for client, packets := range messages {
for _, packet := range packets {
if err := client.send(packet); err != nil {
diff --git a/tests/e2e/arrival-hall.test.mjs b/tests/e2e/arrival-hall.test.mjs
@@ -4,8 +4,7 @@ import {buildServer, withFixture} from './fixture.mjs';
before(buildServer);
-test('Arrival Hall native choice can be cancelled and commits departure once', {timeout: 360_000}, async () =>
-withFixture('arrival-hall', async fixture => {
+async function createHallCharacter(fixture, name) {
const context = await fixture.visitor();
// Controlled precondition: the original create packet supplies a Hall player;
// creation-screen coverage belongs to the separate complete-flow regression.
@@ -14,7 +13,7 @@ withFixture('arrival-hall', async fixture => {
await setup.goto(fixture.url + '/_test/player');
const body = Buffer.from('000000040000000061' +
'0000c79c00000000000000000000000000009c5000000000' +
- '00000000000000040000000000000005416c696365' +
+ '000000000000000400000000' + name.length.toString(16).padStart(8, '0') + Buffer.from(name).toString('hex') +
'000000040000000100000009000000000000000000000000000000000000001d0000006e00000002', 'hex');
const packet = Buffer.alloc((20 + body.length + 3) & ~3);
for (const offset of [0, 2, 4]) packet.writeUInt16BE(1, offset);
@@ -31,6 +30,12 @@ withFixture('arrival-hall', async fixture => {
}), Array.from(packet));
assert.equal(Buffer.from(result).readUInt32BE(16), 0x11);
await setup.close();
+ return context;
+}
+
+test('Arrival Hall native choice can be cancelled and commits departure once', {timeout: 360_000}, async () =>
+withFixture('arrival-hall', async fixture => {
+ const context = await createHallCharacter(fixture, 'Observer');
const before = await fixture.setup(context, 'position', {playfield: 4604,
position: [186.17244, 1.8, 168], rotation: [0, 1, 0, 0]});
assert.equal(before.items.length, 4);
@@ -76,3 +81,36 @@ withFixture('arrival-hall', async fixture => {
assert.deepEqual((await fixture.state(restored)).items, departed.items);
for (const client of [game, resumed]) assert.deepEqual(client.errors, []);
}));
+
+test('All Arrival Hall corridors choose a faction without talking to an NPC', {timeout: 360_000}, async () =>
+withFixture('arrival-hall-corridors', async fixture => {
+ for (const scenario of [
+ {name: 'neutral', x: 183, side: 0, playfield: 954, templates: [116697]},
+ {name: 'clan', x: 192, side: 1, playfield: 952, templates: [116696, 96358]},
+ {name: 'omni', x: 173, side: 2, playfield: 950, templates: [116693, 99719, 29426]},
+ ]) {
+ const context = await createHallCharacter(fixture, scenario.name);
+ // Isolate each authored corridor from the independently verified lobby route.
+ const before = await fixture.setup(context, 'position', {playfield: 4604,
+ position: [scenario.x, 1.52, 164], rotation: [0, 1, 0, 0]});
+ assert.equal(before.items.length, 4);
+ const game = await fixture.game(context);
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ await game.save(fixture.output + '/' + scenario.name + '-before');
+
+ await game.walk(scenario.x, 154);
+ await game.wait('corridor training destination', state => game.local(state)?.playfield === scenario.playfield, 60000);
+ await game.ready();
+ await game.save(fixture.output + '/' + scenario.name + '-training');
+
+ const departed = await fixture.state(context);
+ assert.equal(departed.playfield, scenario.playfield);
+ assert.equal(game.local().stats[33], scenario.side);
+ assert.equal(departed.items.length, 4 + scenario.templates.length);
+ for (const template of scenario.templates) {
+ assert.equal(departed.items.filter(item => item.templates.includes(template)).length, 1);
+ }
+ assert.deepEqual(game.errors, []);
+ await context.close();
+ }
+}));
diff --git a/tests/e2e/mobile-creation.test.mjs b/tests/e2e/mobile-creation.test.mjs
@@ -0,0 +1,86 @@
+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 => {
+ 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 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 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(
+ ([left, top, right, bottom]) => left === 888 && top === 710 && right === 1006 && bottom === 749));
+ const tap = async (x, y) => {
+ const point = await game.point(x, y);
+ const sequence = game.sequence;
+ await touch.send('Input.dispatchTouchEvent', {type: 'touchStart', touchPoints: [point]});
+ await game.waitInput(sequence, 1024);
+ await game.snapshot();
+ await touch.send('Input.dispatchTouchEvent', {type: 'touchEnd', touchPoints: []});
+ await game.waitInput(sequence, 1026);
+ await game.snapshot();
+ };
+ const proportions = async () => {
+ await game.snapshot();
+ assert.deepEqual(game.state.screen, [1024, 768]);
+ const canvas = await page.locator('#canvas').boundingBox();
+ assert(Math.abs(canvas.width / canvas.height - 4 / 3) < 0.001);
+ assert(canvas.x >= 0 && canvas.y >= 0);
+ assert(canvas.x + canvas.width <= page.viewportSize().width + 1);
+ assert(canvas.y + canvas.height <= page.viewportSize().height + 1);
+ };
+
+ await scene(1001);
+ await proportions();
+ await game.save(fixture.output + '/portrait-breed');
+ await page.setViewportSize({width: 844, height: 390});
+ await proportions();
+ await game.save(fixture.output + '/landscape-breed');
+ await tap(880, 350);
+ await next();
+ await tap(946, 730);
+ await scene(1002);
+ await page.setViewportSize({width: 390, height: 844});
+ await proportions();
+ await tap(404, 130);
+ await tap(919, 214);
+ await tap(920, 444);
+ await tap(946, 730);
+ await scene(1003);
+ await tap(850, 514);
+ await next();
+ 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.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 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 created = await fixture.state(context);
+ assert.equal(created.name, 'Phonehero');
+ assert.equal(created.playfield, 4604);
+ assert.equal(created.items.length, 4);
+ assert.deepEqual(game.errors, []);
+ await game.save(fixture.output + '/arrival');
+}));