diff --git a/client/game.html b/client/game.html index 628fbbf..46a5f55 100644 --- a/client/game.html +++ b/client/game.html @@ -28,7 +28,7 @@ -
THE FIRST REACH

Aeternalis

One life. A world on borrowed time.

+
THE FIRST REACH

Aeternalis

One life. A world on borrowed time.

JOURNEY ENDED

Your story remains.

World directory
diff --git a/client/src/main.ts b/client/src/main.ts index f9f80f9..ab3de11 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -277,10 +277,10 @@ async function boot() { travelButton.onclick=()=>{if(!snapshot)return;input.clear();walkTo=undefined;pendingAction=undefined;send('move');void showTravel({worldId:config.worldId,route:config.kind==='hub'?'hub':snapshot.world.phase==='won'?'portal':'escape',beforeTravel:()=>{requestedClose=true;},afterTravel:departed=>{requestedClose=departed;}});}; $('zoom').value = String(view.distance); view.addChunks(chunks); view.updateEntities(chunks.flatMap(c => c.resources)); - $('connection-status').textContent = 'World online'; visible('dev-boss', config.development); let me: { character: Character | null; active?: { worldId: string; state: string; name: string } } | undefined; try { me = await api('/api/me'); } catch { if (config.development) { await api('/auth/dev', {}); me = await api('/api/me'); } } + $('connection-status').textContent = 'World online'; if (!me && !config.development) { visible('join-form', false); visible('login', true); } else if (me?.character) { $('arrival').close(); @@ -336,5 +336,7 @@ async function boot() { else if (hit.point) { selection(); walkTo = hit.point; pendingAction = undefined; } }); Object.defineProperty(window, '__aeternalis', { value: { diagnostics: () => view.diagnostics(), get snapshot() { return snapshot; }, get walkTo() { return walkTo; }, get pendingAction() { return pendingAction; }, get keys() { return input.keys; } }, configurable: true }); + // Authentication and all input handlers must be ready before character creation. + $('join').disabled = !me || !!me.character || !!me.active || config.kind === 'hub'; } boot().catch(error => { console.error(error); $('arrival-error').textContent = `Unable to enter the world: ${error.message}`; $('connection-status').textContent = 'Unavailable'; }); diff --git a/tests/game.spec.ts b/tests/game.spec.ts index 4cc1cc1..174865f 100644 --- a/tests/game.spec.ts +++ b/tests/game.spec.ts @@ -5,8 +5,8 @@ async function enter(page, name = 'Wayfarer') { await expect(page.locator('#connection-status')).toHaveText('World online'); await page.getByLabel('Character name').fill(name); await page.getByRole('button', { name: 'Enter world' }).click(); - await expect(page.locator('#game-controls')).toBeVisible(); await expectWorldReady(page); + await expect(page.locator('#game-controls')).toBeVisible(); } async function expectWorldReady(page, characterId?: string) { @@ -80,6 +80,13 @@ test('desktop renders models, moves authoritatively, gathers, and reconnects', a test('mobile controls fit and move the character', async ({ page }) => { await page.setViewportSize({ width: 390, height: 844 }); + // Hold authentication at the network boundary: entry must stay unavailable + // until it completes, even when the world preview has already loaded. + await page.route('**/api/me', async route => { + await expect(page.getByRole('button', { name: 'Enter world' })).toBeDisabled(); + await expect(page.locator('#connection-status')).not.toHaveText('World online'); + await route.continue(); + }, { times: 1 }); await enter(page, 'Mobile'); await expect(page.getByRole('button', { name: 'Move north' })).toBeVisible(); const before = await page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position.z);