@wildshard/engine 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/lint/engine-sides.json +5 -0
- package/package.json +5 -2
- package/scripts/app-build/gen.ts +11 -0
- package/scripts/cell-mem-bench.mjs +2 -0
- package/scripts/chaos-proxy-core.mjs +14 -1
- package/scripts/chaos-proxy-proof.mjs +22 -0
- package/scripts/check-devserver.mjs +1 -1
- package/scripts/failmode-cases.d.mts +8 -0
- package/scripts/failmode-cases.mjs +97 -0
- package/scripts/failmode-proof.mjs +532 -0
- package/scripts/grid-crossing-nightly.mjs +5 -4
- package/scripts/grid-crossing-report.mjs +5 -2
- package/scripts/grid-crossing-tour.mjs +36 -12
- package/scripts/grid-crossing-walk-proof.mjs +4 -2
- package/scripts/hover-speed-probe.mjs +136 -0
- package/scripts/land.mjs +2 -1
- package/scripts/loading-flow/benchmax.mjs +34 -11
- package/scripts/loading-flow/deskbench.mjs +276 -0
- package/scripts/loading-flow/stalls.d.mts +17 -3
- package/scripts/loading-flow/stalls.mjs +82 -3
- package/scripts/net-lag-proof.mjs +3 -2
- package/scripts/nightly-model.ts +9 -6
- package/scripts/offline-proof.mjs +7 -1
- package/scripts/online-rig.mjs +9 -7
- package/scripts/parity/boot-smoke.mjs +13 -2
- package/scripts/pin-format.ts +5 -2
- package/scripts/pins-reuse.d.mts +1 -0
- package/scripts/pins-reuse.mjs +22 -0
- package/scripts/release-cook.mjs +109 -0
- package/scripts/scratch-dir.mjs +95 -0
- package/scripts/scratch-sweep.mjs +182 -0
- package/scripts/tsconfig.json +2 -12
- package/scripts/vps/harden-prometheus.sh +3 -0
- package/scripts/vps/rebuild.sh +35 -9
- package/scripts/vps/wildshard-apply.mjs +5 -1
- package/scripts/vps/wildshard-config +117 -1
- package/scripts/worktree-reap.mjs +54 -8
- package/scripts/worktree.mjs +19 -5
- package/src/client/engine/anim/rigParser.ts +2 -2
- package/src/client/engine/boot/contentRead.ts +54 -5
- package/src/client/engine/boot/gpuFiles.ts +3 -3
- package/src/client/engine/boot/leaveAfterPaint.ts +4 -1
- package/src/client/engine/core/Game.ts +63 -19
- package/src/client/engine/core/gpuOnly.ts +10 -0
- package/src/client/engine/core/renderBudget.ts +134 -0
- package/src/client/engine/core/shadowLayer.ts +18 -0
- package/src/client/engine/explore/pick.ts +13 -1
- package/src/client/engine/net/predictor.ts +12 -4
- package/src/client/engine/net/redial.ts +40 -5
- package/src/client/engine/player/TouchControls.ts +3 -2
- package/src/client/engine/render/dataLook.ts +70 -7
- package/src/client/engine/render/families/pbr.ts +2 -0
- package/src/client/engine/render/families/registry.ts +11 -2
- package/src/client/engine/render/families/sceneSurface.ts +118 -0
- package/src/client/engine/render/look.ts +7 -1
- package/src/client/engine/render/precompile.ts +4 -2
- package/src/client/engine/render/tiers.ts +4 -1
- package/src/client/engine/telemetry/browserErrors.ts +3 -1
- package/src/client/engine/ui/ErrorModal.ts +1 -1
- package/src/client/engine/ui/Loading.ts +14 -2
- package/src/client/engine/ui/errorScreen.ts +51 -9
- package/src/client/engine/ui/hoverBoost.ts +31 -4
- package/src/client/engine/ui/styles/touch.css +6 -0
- package/src/client/engine/world/declaredProps.ts +5 -1
- package/src/client/engine/world/skyRig.ts +4 -1
- package/src/client/engine/world/terrainTileView.ts +64 -23
- package/src/client/game/boot/spawnDownload.ts +44 -6
- package/src/client/game/devScene/hook.ts +149 -12
- package/src/client/game/devScene/liveLook.ts +21 -0
- package/src/client/game/grid/live.ts +47 -10
- package/src/client/game/grid/liveSession.ts +25 -6
- package/src/client/game/grid/pageEntry.ts +12 -1
- package/src/client/game/grid/productInputs.ts +22 -11
- package/src/client/game/grid/session.ts +15 -4
- package/src/client/game/grid/shardfileFar.ts +13 -2
- package/src/client/game/session/finish.ts +4 -1
- package/src/client/game/shardfile/client.ts +24 -7
- package/src/client/game/shardfile/clientPropMaterials.ts +4 -1
- package/src/client/game/shardfile/clientSource.ts +7 -3
- package/src/client/game/shardfile/clientViews.ts +36 -8
- package/src/client/game/shardfile/clientWorker.ts +4 -4
- package/src/client/game/shardfile/constructionCheckpoint.ts +2 -2
- package/src/client/game/shardfile/groundMerge.ts +59 -5
- package/src/client/game/shardfile/hybrid.ts +2 -0
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/slabLibrary.ts +115 -49
- package/src/client/game/shardfile/tileContent.ts +1 -1
- package/src/client/game/shardfile/tileDriver.ts +38 -11
- package/src/client/game/shardfile/wirePage.ts +7 -3
- package/src/client/game/shardfile/worldScenes.ts +17 -10
- package/src/client/host/online/doctor.ts +20 -7
- package/src/client/host/online/doctorView.ts +2 -0
- package/src/client/host/online/linkScreens.ts +95 -11
- package/src/client/host/online/reconnectStrip.ts +3 -2
- package/src/client/host/online/release.ts +87 -16
- package/src/client/host/online/releaseScreens.ts +108 -0
- package/src/client/host/online/shell.ts +24 -5
- package/src/client/host/online/voice.ts +45 -1
- package/src/client/host/online/voiceUi.ts +24 -6
- package/src/client/host/standalone/shell.ts +37 -1
- package/src/server/engine/sim/playerSim.ts +1 -1
- package/src/server/game/grid/simulation.ts +12 -6
- package/src/server/game/quest/eliteDrops.ts +7 -3
- package/src/server/game/riding/nativeTaming.ts +13 -2
- package/src/server/host/dedicated/cellHost.ts +21 -2
- package/src/server/host/dedicated/cellProtocol.ts +2 -0
- package/src/server/host/dedicated/cellWorker.ts +1 -1
- package/src/server/host/dedicated/dedicatedRoom.ts +38 -8
- package/src/server/host/dedicated/roadRoom.ts +3 -0
- package/src/server/host/dedicated/serverMetrics.ts +9 -0
- package/src/server/host/dedicated/workerTable.ts +31 -24
- package/src/server/host/standalone/gridServer.ts +1 -1
- package/src/server/host/standalone/serverHost.ts +56 -10
- package/src/server/host/standalone/serverProduct.ts +9 -7
- package/src/server/host/standalone/serverRuntime.ts +1 -1
- package/src/shared/engine/boot/loadingWaits.ts +10 -2
- package/src/shared/engine/core/config.ts +3 -0
- package/src/shared/engine/core/framePacing.ts +12 -1
- package/src/shared/engine/physics/terrainTiles.ts +20 -4
- package/src/shared/engine/player/hoverSpeed.ts +3 -3
- package/src/shared/engine/strings.ts +12 -1
- package/src/shared/game/devColliders.ts +60 -0
- package/src/shared/game/devGameplay.ts +41 -0
- package/src/shared/game/grid/rules.ts +12 -0
|
@@ -56,6 +56,8 @@ export interface WorkerReading {
|
|
|
56
56
|
/** SERVER-CELLS SC1: this worker thread's own memory beyond its heap, and its event-loop lag in ms (`loopLag`), when it measures them. */
|
|
57
57
|
readonly external?: number; readonly arrayBuffers?: number;
|
|
58
58
|
readonly lag?: { readonly p50: number; readonly p99: number; readonly max: number };
|
|
59
|
+
/** SERVER-CELLS SC8: each cell that ticked in this reading, its mean ms per tick (its awake cost; `workerTable`'s weights come from these). */
|
|
60
|
+
readonly cellMs?: Readonly<Record<string, number>>;
|
|
59
61
|
}
|
|
60
62
|
/** What a cell tells the worker it runs on. */
|
|
61
63
|
export type RoomNews =
|
|
@@ -29,7 +29,7 @@ if (port === null) throw new Error('A cell runs in a worker');
|
|
|
29
29
|
for (const row of placed ?? []) placeCell(row);
|
|
30
30
|
const reads: PackReads = { fetched: 0, fetchedBytes: 0, cached: 0, refused: 0 };
|
|
31
31
|
const rapier = await loadRapier(await readFile(new URL('rapier.wasm', import.meta.url)));
|
|
32
|
-
runCells(port as unknown as CellPort, { slugs, build, bootId: () => randomBytes(4).toString('hex'), memory: () => process.memoryUsage(), ...(metrics === true ? { lag: loopLag() } : {}), closed: () => { process.exit(0); }, ...(holdMs === undefined ? {} : { holdMs }), ...(emptyMs === undefined ? {} : { emptyMs }),...(playtest===undefined?{}:{playtest}),...(crossing === true ? { road: async () => {
|
|
32
|
+
runCells(port as unknown as CellPort, { slugs, build, developerBoost: process.env['WORLD_BOOST'] !== 'off', bootId: () => randomBytes(4).toString('hex'), memory: () => process.memoryUsage(), ...(metrics === true ? { lag: loopLag() } : {}), closed: () => { process.exit(0); }, ...(holdMs === undefined ? {} : { holdMs }), ...(emptyMs === undefined ? {} : { emptyMs }),...(playtest===undefined?{}:{playtest}),...(crossing === true ? { road: async () => {
|
|
33
33
|
// A build whose server book has no grid pack gives a road with no strips: this line says so before anyone falls through it.
|
|
34
34
|
const strips = await readPackGrid(build, { origin, cache }, reads);
|
|
35
35
|
console.info(JSON.stringify({ at: 'road.pack', strips: strips.length, ...reads }));
|
|
@@ -18,13 +18,15 @@ import type { FallFloor } from '../standalone/fallFloor';
|
|
|
18
18
|
import { ledgerFilings } from '../standalone/ledgerFilings';
|
|
19
19
|
import { questBooks } from '@wildshard/engine/quest/players';
|
|
20
20
|
import { mountedPlayerOf } from '@wildshard/engine/game/riding/native';
|
|
21
|
+
import { nativeTamingControls } from '@wildshard/engine/game/riding/nativeTaming';
|
|
21
22
|
import { carryDoc, exportPlayer, importPlayer, parseDoc, PLAYER_DOC_VERSION, type PlayerDoc } from './playerDoc';
|
|
22
23
|
import { PlayerStore, recoverPlayer } from './playerStore';
|
|
23
24
|
import { ShopGate } from './shopGate';
|
|
24
25
|
import { HOLD_MS, type ResumeAt, type RoomNews, type SeatEntry } from './cellProtocol';
|
|
25
26
|
import { LEFT } from './socketPump';
|
|
26
27
|
import type {PlaytestHit} from './playtest';
|
|
27
|
-
import { cellFrame, cellName } from './gridCells';
|
|
28
|
+
import { cellFrame, cellName, gridAssembly } from './gridCells';
|
|
29
|
+
import { gridBoardLimitAt } from '@wildshard/engine/game/grid/rules';
|
|
28
30
|
import {hitHistoryOf} from '@wildshard/engine/combat/rewind';
|
|
29
31
|
import { entrywaysStand, floorBelow } from '@wildshard/engine/physics/query';
|
|
30
32
|
import type { GridAssembly } from '@wildshard/engine/game/grid/assembly';
|
|
@@ -44,6 +46,8 @@ const DEBOUNCE_MS = 1000, EVERY_MS = 60_000;
|
|
|
44
46
|
/** A player who holds a seat, with or without a live link. */
|
|
45
47
|
interface Seat {
|
|
46
48
|
readonly device: string; readonly name: string; readonly body: string; readonly store: PlayerStore; readonly fall: FallFloor;
|
|
49
|
+
/** SC10: this device's own body id (`entry.body`), which `body` is unless it holds the lead seat: what it was paid here is kept under it. */
|
|
50
|
+
readonly own: string;
|
|
47
51
|
transport: Transport | null;
|
|
48
52
|
/** The link's client in this room's `NetRoom`, and how to stop hearing its close, while it stands. */
|
|
49
53
|
client: number | null; closeOff: (() => void) | null;
|
|
@@ -216,13 +220,16 @@ export class DedicatedRoom implements CrossTarget {
|
|
|
216
220
|
} }
|
|
217
221
|
catch (error) { return `recovery: ${String(error)}`; }
|
|
218
222
|
const store = new PlayerStore(doc?.store ?? {}, () => { const own = this.seats.get(entry.device); if (own !== undefined) this.dirty(own); });
|
|
219
|
-
const seat: Seat = { device: entry.device, name: entry.name, read: entry.doc, body, store, fall: this.cell.fallFloor(), transport, client: null, closeOff: null, holdEnds: null, seq: entry.seq, receipted: doc?.ledger.serial ?? 0, dirtyAt: null, savedAt: now, stand: null, version: 0 };
|
|
223
|
+
const seat: Seat = { device: entry.device, name: entry.name, read: entry.doc, body, own: entry.body, store, fall: this.cell.fallFloor(), transport, client: null, closeOff: null, holdEnds: null, seq: entry.seq, receipted: doc?.ledger.serial ?? 0, dirtyAt: null, savedAt: now, stand: null, version: 0 };
|
|
220
224
|
this.seats.set(entry.device, seat); this.bodies.set(body, seat); this.departed.delete(body);
|
|
221
|
-
|
|
225
|
+
// SC10 review: the lead seat takes back what this device was paid here when it last left (kept under its own id)
|
|
226
|
+
const away = this.departed.get(entry.body);
|
|
227
|
+
if (lead) { this.departed.delete(entry.body); this.movePaid(entry.body, LEAD_SEAT); this.unparkLead(); }
|
|
222
228
|
// Two who join together would otherwise stand inside each other.
|
|
223
229
|
const aside = SPAWN_ASIDE[(this.joined++) % SPAWN_ASIDE.length] ?? 0, stand = { ...spawn, x: spawn.x + aside };
|
|
224
230
|
const player = lead ? this.lead : host.addPlayer(body, at ?? doc?.at ?? stand, at?.yaw ?? doc?.at.yaw ?? spawn.yaw);
|
|
225
231
|
player.netName = entry.name;
|
|
232
|
+
this.capBoard(player);
|
|
226
233
|
if (lead) player.resetPose(stand, spawn.yaw);
|
|
227
234
|
book.seat(body, doc?.ledger ?? { serial: 0, rows: [] });
|
|
228
235
|
// Bind owned modifiers to the fresh body baseline before restoring its already modified health.
|
|
@@ -230,11 +237,23 @@ export class DedicatedRoom implements CrossTarget {
|
|
|
230
237
|
catch (error) {
|
|
231
238
|
// No save or live link is installed on a failed continuation. Keep the durable copies intact.
|
|
232
239
|
this.seats.delete(entry.device); this.bodies.delete(body); this.cell.owned.drop(body); book.drop(body);
|
|
233
|
-
|
|
240
|
+
// review MUST: a failed continuation keeps what this device was paid here, on the clock it left on
|
|
241
|
+
if (lead) this.clearLead(entry.body, away ?? now); else host.removePlayer(body);
|
|
234
242
|
return `doc: ${String(error)}`;
|
|
235
243
|
}
|
|
236
244
|
return seat;
|
|
237
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* QA 11-15 row 8: a grid cell's board cap is the page's (`installGridHoverSpeed`): 14 m/s inside (G39), easing to the road's 30 over
|
|
248
|
+
* the strip (G60), 30 throughout a road-class padding cell (G540). Read from world feet: this cell's x and z moved by its placement.
|
|
249
|
+
* A cell the grid doesn't place keeps the standalone 14.
|
|
250
|
+
*/
|
|
251
|
+
private capBoard(player: PlayerSim): void {
|
|
252
|
+
player.hoverSpeedLimit = () => {
|
|
253
|
+
const assembly = this.options.road?.assembly ?? gridAssembly(), cell = assembly.cells.find(row => row.instance === this.name);
|
|
254
|
+
return cell === undefined ? 14 : gridBoardLimitAt(assembly, assembly.world(player.position, cell));
|
|
255
|
+
};
|
|
256
|
+
}
|
|
238
257
|
/** GC30: whether a walker off the road stands at this cell's entryways (`entrywaysStand`); else its worker's road walls it. */
|
|
239
258
|
entrywaysStand(): boolean { return entrywaysStand(this.host.physics, ARRIVAL_LIFT); }
|
|
240
259
|
/** GC15: this seat's feet left for cell `to`, standing at `at` in that cell's own frame. The door reads their save there and orders `handOver`. */
|
|
@@ -339,7 +358,7 @@ export class DedicatedRoom implements CrossTarget {
|
|
|
339
358
|
this.playerRefusals.delete(seat.body);
|
|
340
359
|
actRoutes(this.host).identities.delete(seat.body);
|
|
341
360
|
this.seats.delete(seat.device); this.bodies.delete(seat.body); this.cell.owned.drop(seat.body); this.book.drop(seat.body);
|
|
342
|
-
if (seat.body === LEAD_SEAT) this.clearLead(); else { this.host.removePlayer(seat.body); this.departed.set(seat.body, this.options.now()); }
|
|
361
|
+
if (seat.body === LEAD_SEAT) this.clearLead(seat.own, this.options.now()); else { this.host.removePlayer(seat.body); this.departed.set(seat.body, this.options.now()); }
|
|
343
362
|
this.options.post({ kind: 'left', device: seat.device, seats: this.seats.size });
|
|
344
363
|
}
|
|
345
364
|
private flushRefusals(): void {
|
|
@@ -353,12 +372,23 @@ export class DedicatedRoom implements CrossTarget {
|
|
|
353
372
|
transport?.close('refused');
|
|
354
373
|
}
|
|
355
374
|
}
|
|
356
|
-
/**
|
|
357
|
-
|
|
375
|
+
/**
|
|
376
|
+
* The seat goes back to how boot left it, and what it was paid goes with who earned it: the next player's bounty is their own (J105).
|
|
377
|
+
* SC10 review: it goes under the leaver's own id, as any other body's stays, so a lead who bounces across an edge cannot re-farm a
|
|
378
|
+
* bounty; it is forgotten `FORGET_PAID_MS` after `left`. The seat's taming session goes too: the next lead starts wild.
|
|
379
|
+
*/
|
|
380
|
+
private clearLead(own: string, left: number): void {
|
|
358
381
|
actRoutes(this.host).identities.delete(LEAD_SEAT);
|
|
359
|
-
this.
|
|
382
|
+
this.movePaid(LEAD_SEAT, own);
|
|
383
|
+
this.departed.set(own, left);
|
|
384
|
+
nativeTamingControls(this.host)?.release(LEAD_SEAT);
|
|
360
385
|
importPlayer(this.host, this.lead, this.blank); this.parkLead();
|
|
361
386
|
}
|
|
387
|
+
/** What `from` was paid here is `to`'s now. */
|
|
388
|
+
private movePaid(from: string, to: string): void {
|
|
389
|
+
const { ledgerDedupe } = this.host.slots, paid = `${LOOT_ROW}${from}:`;
|
|
390
|
+
for (let index = 0; index < ledgerDedupe.length; index++) { const row = ledgerDedupe[index]; if (row?.startsWith(paid) === true) ledgerDedupe[index] = `${LOOT_ROW}${to}:${row.slice(paid.length)}`; }
|
|
391
|
+
}
|
|
362
392
|
/** What a body was paid here goes: the next one to hold it, or its own return after a long while, earns afresh (J105, SC10). */
|
|
363
393
|
private forgetPaid(body: string): void {
|
|
364
394
|
const { ledgerDedupe } = this.host.slots, paid = `${LOOT_ROW}${body}:`;
|
|
@@ -8,6 +8,7 @@ import type { Transport } from '@wildshard/engine/net/transport';
|
|
|
8
8
|
import type { SimHost } from '@wildshard/engine/sim';
|
|
9
9
|
import type { PlayerSim } from '@wildshard/engine/sim/playerSim';
|
|
10
10
|
import { carryMotion, motionOf } from '@wildshard/engine/game/grid/simulation';
|
|
11
|
+
import { gridBoardLimitAt } from '@wildshard/engine/game/grid/rules';
|
|
11
12
|
import type { GridAssembly, GridCell } from '@wildshard/engine/game/grid/assembly';
|
|
12
13
|
import type { GridCollisionStrip } from '@wildshard/engine/game/grid/gridCollision';
|
|
13
14
|
import { mountedPlayerOf } from '@wildshard/engine/game/riding/native';
|
|
@@ -87,6 +88,8 @@ export class RoadRoom implements CrossTarget {
|
|
|
87
88
|
if (this.seats.has(entry.device)) return 'held';
|
|
88
89
|
const player = this.host.addPlayer(entry.body, at, at.yaw);
|
|
89
90
|
player.netName = entry.name;
|
|
91
|
+
// QA 11-15 row 8: the road's board cap is the page's (G60: 30 m/s on the deck, easing to 14 over a cell's strip); its frame is the world's
|
|
92
|
+
player.hoverSpeedLimit = () => gridBoardLimitAt(this.assembly, player.position);
|
|
90
93
|
player.resetPose(at, at.yaw);
|
|
91
94
|
if (motion !== undefined) carryMotion(motion, player);
|
|
92
95
|
const seat: RoadSeat = { device: entry.device, name: entry.name, body: entry.body, transport, client: null, closeOff: null, holdEnds: null, asked: null, askedAt: 0, fall: new FallFloor(ROAD_FLOOR, true, at) };
|
|
@@ -40,6 +40,9 @@ export class ServerMetrics {
|
|
|
40
40
|
private readonly lag: Gauge<'thread' | 'quantile'>;
|
|
41
41
|
private readonly memory: Gauge<'thread' | 'kind'>;
|
|
42
42
|
private readonly tick: Gauge<'worker' | 'quantile'>;
|
|
43
|
+
private readonly cellTick: Gauge<'cell'>;
|
|
44
|
+
/** Each worker's cells awake in its last reading. */
|
|
45
|
+
private readonly ticking = new Map<number, ReadonlySet<string>>();
|
|
43
46
|
private readonly rate: Gauge<'worker'>;
|
|
44
47
|
private readonly drops: Counter<'worker'>;
|
|
45
48
|
private readonly awake: Gauge<'worker'>;
|
|
@@ -60,6 +63,7 @@ export class ServerMetrics {
|
|
|
60
63
|
this.memory = new Gauge({ name: 'wildshard_thread_memory_bytes', help: 'Each thread\'s own heap, external and array-buffer bytes (a worker\'s from its last reading).', labelNames: ['thread', 'kind'], registers,
|
|
61
64
|
collect() { const own = process.memoryUsage(); this.set({ thread: 'main', kind: 'heap' }, own.heapUsed); this.set({ thread: 'main', kind: 'external' }, own.external); this.set({ thread: 'main', kind: 'arrayBuffers' }, own.arrayBuffers); } });
|
|
62
65
|
this.tick = new Gauge({ name: 'wildshard_tick_seconds', help: 'Tick time per worker over its last 10 s reading.', labelNames: ['worker', 'quantile'], registers });
|
|
66
|
+
this.cellTick = new Gauge({ name: 'wildshard_cell_tick_seconds', help: 'SC8: each awake cell\'s mean tick time over its worker\'s last 10 s reading (its awake cost).', labelNames: ['cell'], registers });
|
|
63
67
|
this.rate = new Gauge({ name: 'wildshard_ticks_per_second', help: 'Ticks per second per worker over its last 10 s reading.', labelNames: ['worker'], registers });
|
|
64
68
|
this.drops = new Counter({ name: 'wildshard_tick_drops_total', help: 'Ticks a worker\'s clock dropped to catch up.', labelNames: ['worker'], registers });
|
|
65
69
|
this.registry.registerMetric(new Gauge({ name: 'wildshard_cells_resident', help: 'Cells open in memory, per worker (from /health\'s table).', labelNames: ['worker'], registers: [],
|
|
@@ -83,6 +87,11 @@ export class ServerMetrics {
|
|
|
83
87
|
const worker = String(index);
|
|
84
88
|
for (const [quantile, ms] of [['0.5', row.p50], ['0.95', row.p95], ['0.99', row.p99], ['1', row.max]] as const) this.tick.set({ worker, quantile }, ms / 1000);
|
|
85
89
|
this.rate.set({ worker }, row.ticksPerSecond);
|
|
90
|
+
// a cell gone back to sleep stops reporting its last awake cost (review SHOULD)
|
|
91
|
+
const awake = new Set(Object.keys(row.cellMs ?? {}));
|
|
92
|
+
for (const cell of this.ticking.get(index) ?? []) if (!awake.has(cell)) this.cellTick.remove({ cell });
|
|
93
|
+
this.ticking.set(index, awake);
|
|
94
|
+
for (const [cell, ms] of Object.entries(row.cellMs ?? {})) this.cellTick.set({ cell }, ms / 1000);
|
|
86
95
|
this.drops.inc({ worker }, Math.max(0, row.drops));
|
|
87
96
|
this.awake.set({ worker }, row.awake);
|
|
88
97
|
this.players.set({ worker }, row.players);
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
// J182, J185: which worker runs which cell. Fixed at startup, never by load, and a cell never moves. How many workers, and how many cells fit
|
|
2
2
|
// one, is a startup setting a bench decides (E7.3e), so nothing here is a promise about the number.
|
|
3
|
+
// SERVER-CELLS SC8: the table is weighed by each cell's measured awake cost (its mean tick ms with a player in it), not by name.
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* SC8: each cell's awake cost, ms per tick with one player in it: `cell-mem-bench.mjs`'s `cellMs` (the worker readings' per-cell
|
|
7
|
+
* tick time; `/metrics` serves the same as `wildshard_cell_tick_seconds{cell}`), COSTS_MEASURED. Re-measure when a shard grows.
|
|
8
|
+
*/
|
|
9
|
+
const COST: ReadonlyMap<string, number> = new Map<string, number>([
|
|
10
|
+
['nalati-grasslands', 2.741], ['driftwood-isle', 1.755], ['pine-hollow', 1.594], ['blender-template', 1.311], ['far-reach', 0.866], ['template-2', 0.746], ['sunscar-dunes', 0.682], ['nine-dragon-stack', 0.63], ['pastel-plain', 0.608], ['open-plot-0-3', 0.606], ['ink-cel-valley', 0.576], ['open-plot-0-4', 0.374], ['open-plot-4-2', 0.281], ['open-plot-4-4', 0.269], ['open-plot-4-3', 0.244], ['open-plot-4-0', 0.221], ['open-plot-0-0', 0.211], ['open-plot-4-1', 0.206], ['open-plot-2-4', 0.202], ['open-plot-2-0', 0.195], ['open-plot-0-2', 0.186], ['open-plot-3-4', 0.184], ['open-plot-3-0', 0.183], ['open-plot-1-0', 0.18], ['open-plot-0-1', 0.175],
|
|
11
|
+
]);
|
|
12
|
+
/** SC8: the measurement the costs come from. */
|
|
13
|
+
export const COSTS_MEASURED = 'opus-cells3, 2026-11-14 ~02:00 Cancún: cell-mem-bench --remote wildshard-agent --counts 25, release 7251ca24 (v0.1.19) packs, a bot in every cell';
|
|
14
|
+
/** A cell with no measured cost (a new Open Plot) weighs as a measured Open Plot does. */
|
|
15
|
+
const UNMEASURED = 0.206;
|
|
16
|
+
/** Cells that always share a worker. */
|
|
17
|
+
const TOGETHER: readonly (readonly string[])[] = [['sunscar-dunes', 'far-reach']];
|
|
8
18
|
/** What each channel starts on (J185). Production tries 4 and goes to 8 only if the bench says it doesn't fit. Staging runs on pinned CPUs. The cap is per grid (J182). */
|
|
9
19
|
const SETTINGS: Readonly<Record<string, { readonly workers: number; readonly seats: number }>> = { production: { workers: 4, seats: 32 }, staging: { workers: 2, seats: 16 } };
|
|
10
20
|
|
|
@@ -25,28 +35,25 @@ export function worldCrossing(value: string | undefined): boolean {
|
|
|
25
35
|
throw new Error(`WORLD_CROSSING=${value}: only worker (the default) or off`);
|
|
26
36
|
}
|
|
27
37
|
|
|
38
|
+
/** SC8: a cell's awake cost in ms per tick (measured, or an Open Plot's when it has none). */
|
|
39
|
+
export function cellCost(slug: string): number { return COST.get(slug) ?? UNMEASURED; }
|
|
40
|
+
|
|
28
41
|
/**
|
|
29
|
-
* The table for the cells this server opens: one row a worker, at most `workers` rows
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* where it was, so Driftwood's crossings to Sunscar and Sky Reach stay on one worker; a crossing between workers is GC15's move.
|
|
42
|
+
* The table for the cells this server opens: one row a worker, at most `workers` rows, no empty row. SC8: heaviest first, each cell (or
|
|
43
|
+
* group that shares a worker) goes to the row whose awake cost is lowest so far (fewest cells on a tie, then the first row), so the
|
|
44
|
+
* busiest worker carries as little awake cost as the cells allow. One cell is one worker; GC31: one worker holds every cell. A crossing
|
|
45
|
+
* between workers is GC15's move, so no cell needs a neighbour's worker.
|
|
34
46
|
*/
|
|
35
47
|
export function workerTable(cells: readonly string[], workers: number): readonly (readonly string[])[] {
|
|
36
|
-
const open = new Set(cells),
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// the unnamed cells sit at the end of `over`, so the last cell is the one to move while it is unnamed
|
|
46
|
-
for (let moving = over.at(-1); moving !== undefined && !named.has(moving); moving = over.at(-1)) {
|
|
47
|
-
const lightest = kept.reduce((best, row) => (row.length < best.length ? row : best));
|
|
48
|
-
if (over.length <= lightest.length + 1) break;
|
|
49
|
-
over.pop(); lightest.push(moving);
|
|
48
|
+
const open = [...new Set(cells)].sort(), grouped = new Set(TOGETHER.flat());
|
|
49
|
+
const units = [...TOGETHER.map(group => group.filter(slug => open.includes(slug))).filter(group => group.length > 0), ...open.filter(slug => !grouped.has(slug)).map(slug => [slug])];
|
|
50
|
+
const weight = (unit: readonly string[]): number => unit.reduce((total, slug) => total + cellCost(slug), 0);
|
|
51
|
+
if (units.length === 0) return [];
|
|
52
|
+
units.sort((a, b) => weight(b) - weight(a) || (a[0] ?? '').localeCompare(b[0] ?? ''));
|
|
53
|
+
const rows = Array.from({ length: Math.max(1, Math.min(workers, units.length)) }, () => ({ cells: [] as string[], cost: 0 }));
|
|
54
|
+
for (const unit of units) {
|
|
55
|
+
const row = rows.reduce((best, next) => (next.cost < best.cost || (next.cost === best.cost && next.cells.length < best.cells.length) ? next : best));
|
|
56
|
+
row.cells.push(...unit); row.cost += weight(unit);
|
|
50
57
|
}
|
|
51
|
-
return
|
|
58
|
+
return rows.map(row => row.cells);
|
|
52
59
|
}
|
|
@@ -218,7 +218,7 @@ export class StandaloneGrid {
|
|
|
218
218
|
netWorldInput(routes, inputs); netBuys(routes, inputs);
|
|
219
219
|
const stepping = sessionPlayer(this.grid.hostOf(site));
|
|
220
220
|
this.grid.hostOf(site).physics.near?.update(stepping.position.x, stepping.position.z);
|
|
221
|
-
if (world === undefined) this.grid.stepSite(site, commandsOf(inputs)); else world.step(inputs);
|
|
221
|
+
if (world === undefined) this.grid.stepSite(site, commandsOf(inputs)); else { this.grid.capBoards(site); world.step(inputs); }
|
|
222
222
|
const host = this.grid.hostOf(site), player = sessionPlayer(host);
|
|
223
223
|
// The page used to catch a fall, on its own body. The server's world has nothing below it, so it would fall for ever.
|
|
224
224
|
world?.fall.step(player, () => { host.combat.fall(player.health, player.position, { kind: 'out-of-world', label: '' }); });
|
|
@@ -20,15 +20,18 @@ import type { HeadlessRuntimeInput } from '../headlessRuntime';
|
|
|
20
20
|
import { StandaloneGrid } from './gridServer';
|
|
21
21
|
import { isHarnessFlag, isHarnessGod, isHarnessHits, isHarnessJoin, isHarnessMove, isHarnessPlace } from '../../../shared/host/standalone/harnessPlace';
|
|
22
22
|
import { WorkerLoopback } from '../../../shared/host/standalone/workerLoopback';
|
|
23
|
-
import { isDevColliders, swapDevBoxes } from '@wildshard/engine/game/devColliders';
|
|
23
|
+
import { isDevColliders, isDevGround, swapDevBoxes, swapDevGround } from '@wildshard/engine/game/devColliders';
|
|
24
|
+
import { isDevRestart, withDevGameplay, type DevGameplay, type DevPlace, type DevRestarted } from '@wildshard/engine/game/devGameplay';
|
|
25
|
+
import type { Shardfile } from '@wildshard/format/shardSchema';
|
|
24
26
|
import { ProgressSaves, ProgressWatch } from './progressWatch';
|
|
25
27
|
|
|
26
28
|
type Boot = Extract<ShellMessage, { kind: 'boot' }>;
|
|
27
29
|
/** How the composition reaches what a worker and a Node test get differently. */
|
|
28
30
|
export interface StandaloneServerOptions {
|
|
29
31
|
readonly control: MessagePort; readonly game: MessagePort;
|
|
30
|
-
/** Read and verify a shard's server inputs: the home cell's, and each cell's as the grid admits it.
|
|
31
|
-
|
|
32
|
+
/** Read and verify a shard's server inputs: the home cell's, and each cell's as the grid admits it. `patch` (DEVSERVER, SHARD-SOURCE
|
|
33
|
+
* AP19) changes the read shardfile before the input is made of it. */
|
|
34
|
+
readonly load: (boot: Boot, slug: string, patch?: (shard: Shardfile) => Shardfile) => Promise<HeadlessRuntimeInput>;
|
|
32
35
|
/** The road's collision, read once a grid session boots. A lone cell has no road and never asks; a proof that stays in a cell needs none. */
|
|
33
36
|
readonly strips?: (boot: Boot) => Promise<readonly GridCollisionStrip[]>;
|
|
34
37
|
/** A save read back but would not restore, and boot moved to the one before it. */
|
|
@@ -84,26 +87,69 @@ export function runStandaloneServer(options: StandaloneServerOptions): { dispose
|
|
|
84
87
|
changed.poll(now);
|
|
85
88
|
};
|
|
86
89
|
|
|
90
|
+
/** The grid's boot options for `message`; `patch` changes the watched shard's read shardfile (AP19's restart), never a neighbour's. */
|
|
91
|
+
const gridOptions = (message: Boot, local: ForwardedStorage, patch?: (shard: Shardfile) => Shardfile): Parameters<typeof StandaloneGrid.boot>[0] => {
|
|
92
|
+
const { arrival, residents } = options.proof ?? {}, watched = new Set([message.slug]);
|
|
93
|
+
return { slug: message.slug, build: message.build, book, saves, storage: local, savePrefix: message.savePrefix, now: diagnosticNow, ...(message.lone === true ? { lone: true } : {}),
|
|
94
|
+
load: slug => options.load(message, slug, watched.has(slug) ? patch : undefined), strips: () => options.strips?.(message) ?? Promise.resolve([]), stepped, ...(options.onSaveRefused === undefined ? {} : { refused: options.onSaveRefused }), ...(options.reports === undefined ? {} : { reports: options.reports }),
|
|
95
|
+
...(arrival === undefined ? {} : { arrival }), ...(residents === undefined ? {} : { residents }), ...(options.goto === undefined ? {} : { goto: options.goto }) };
|
|
96
|
+
};
|
|
97
|
+
|
|
87
98
|
const boot = async (message: Boot): Promise<void> => {
|
|
88
99
|
bootMark('server:boot-configuration');
|
|
89
100
|
storage = new ForwardedStorage(message.saves, write => { post({ kind: 'write', ...write }); });
|
|
90
|
-
const local = storage
|
|
101
|
+
const local = storage;
|
|
91
102
|
installWorkerIdentity(message.savePrefix);
|
|
92
103
|
allowDeveloperBoost(); // this server is the player's own device; a page only sends the button with Developer on
|
|
93
104
|
installSaveEnvironment({ storage: saveScope => saveScope === 'session' ? null : local, persistent: () => true, persist: () => Promise.resolve(false) });
|
|
94
|
-
const server = await bootTask('server:world-boot', () => StandaloneGrid.boot(
|
|
95
|
-
load: slug => options.load(message, slug), strips: () => options.strips?.(message) ?? Promise.resolve([]), stepped, ...(options.onSaveRefused === undefined ? {} : { refused: options.onSaveRefused }), ...(options.reports === undefined ? {} : { reports: options.reports }),
|
|
96
|
-
...(arrival === undefined ? {} : { arrival }), ...(residents === undefined ? {} : { residents }), ...(options.goto === undefined ? {} : { goto: options.goto }) }));
|
|
105
|
+
const server = await bootTask('server:world-boot', () => StandaloneGrid.boot(gridOptions(message, local)));
|
|
97
106
|
grid = server;
|
|
98
107
|
const { restored } = server;
|
|
99
108
|
if (restored?.ledger !== undefined) book.restore(restored.ledger);
|
|
100
109
|
server.connect(new WorkerLoopback(game));
|
|
101
110
|
watch.look(server.host, book.filed); // where the world stands before its first tick: what that tick moves is progress
|
|
102
111
|
// SHARD-SOURCE AP5: `wildshard watch`'s part colliders, in this world as in the page's (DEVSERVER only: the define folds it away)
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
// and (AP18) its ground: the heightfield, the height query, and the players lifted out of a hill raised under them
|
|
113
|
+
const devBoxes = new Map<string, Scope>(), devGround: { scope: Scope | null } = { scope: null };
|
|
114
|
+
const groundPorts = { heightQuery: (heightAt: (x: number, z: number) => number) => { grid?.host.setHeightQuery(heightAt); }, players: () => (grid ?? server).host.players.entries(),
|
|
115
|
+
place: (at: { x: number; y: number; z: number; yaw: number }, player: string) => { try { grid?.place(at, player); } catch (cause) { console.warn('[devGround] a player stays where it was', cause); } } };
|
|
116
|
+
// AP19: `wildshard watch`'s soft restart. Save, put the world down, boot it again on the new sections from that save (its
|
|
117
|
+
// progress and its player's place), give the page its new link and put the player where the page says it stands. The page
|
|
118
|
+
// sends its held boxes and ground again once this answers.
|
|
119
|
+
let restarting = false;
|
|
120
|
+
const restart = typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__ ? async (gameplay: DevGameplay, at: DevPlace | null, link: MessagePort, reply: MessagePort): Promise<void> => {
|
|
121
|
+
const started = diagnosticNow(), old = grid;
|
|
122
|
+
const answer = (ok: boolean, reason?: string): void => { reply.postMessage({ ok, ms: Math.round(diagnosticNow() - started), ...(reason === undefined ? {} : { reason }) } satisfies DevRestarted, []); reply.close(); };
|
|
123
|
+
if (old === undefined || restarting) { answer(false, 'no world to restart'); return; }
|
|
124
|
+
// the clock comes back only as it was: a hidden tab's or a failed world's server stays paused
|
|
125
|
+
const running = clock?.running ?? false;
|
|
126
|
+
restarting = true; clock?.pause();
|
|
127
|
+
try {
|
|
128
|
+
await saveWorld();
|
|
129
|
+
old.dispose(); grid = undefined;
|
|
130
|
+
for (const held of devBoxes.values()) held.dispose();
|
|
131
|
+
devBoxes.clear(); devGround.scope?.dispose(); devGround.scope = null;
|
|
132
|
+
const next = await StandaloneGrid.boot(gridOptions(message, local, shard => withDevGameplay(shard, gameplay)));
|
|
133
|
+
grid = next;
|
|
134
|
+
next.connect(new WorkerLoopback(link));
|
|
135
|
+
if (at !== null) next.place(at);
|
|
136
|
+
watch.look(next.host, book.filed);
|
|
137
|
+
next.open();
|
|
138
|
+
answer(true);
|
|
139
|
+
} catch (cause) { answer(false, cause instanceof Error ? cause.message : String(cause)); }
|
|
140
|
+
finally { restarting = false; if (running) clock?.start(); }
|
|
141
|
+
} : null;
|
|
142
|
+
if (options.harness !== undefined) options.harness.onmessage = (event: MessageEvent<unknown>): void => {
|
|
143
|
+
const [port, reply] = event.ports, live = grid;
|
|
144
|
+
if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__ && restart !== null && isDevRestart(event.data) && port !== undefined && reply !== undefined) { void restart(event.data.wildshardDevRestart, event.data.at, port, reply); return; }
|
|
145
|
+
// while a restart runs there is no world: the page sends its boxes and ground again once it answers
|
|
146
|
+
if (live === undefined) return;
|
|
147
|
+
if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__ && isDevColliders(event.data)) swapDevBoxes(live.host.physics, live.host.scope, devBoxes, event.data.wildshardDevColliders, event.data.boxes);
|
|
148
|
+
else if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__ && isDevGround(event.data)) swapDevGround(live.host.physics, live.host.scope, devGround, event.data.wildshardDevGround, groundPorts);
|
|
149
|
+
else if (isHarnessJoin(event.data) && port !== undefined) live.join(event.data, new WorkerLoopback(port)); else if (isHarnessFlag(event.data)) live.raise(event.data.flag); else if (isHarnessMove(event.data)) live.place(event.data, event.data.move); else if (isHarnessPlace(event.data)) live.place(event.data); else if (isHarnessHits(event.data)) live.hardHits(event.data.hits); else if (isHarnessGod(event.data)) live.bossGod();
|
|
150
|
+
};
|
|
105
151
|
clock = new ServerClock({ now: diagnosticNow, wait: (ms, run) => { const timer = scope.timeout(ms, run); return () => { scope.cancelTimer(timer); }; },
|
|
106
|
-
step: () => { try {
|
|
152
|
+
step: () => { const live = grid; if (live === undefined) return; try { live.tick(); progress(live); } catch (error) { fail(error); } } });
|
|
107
153
|
options.proof?.booted?.(server);
|
|
108
154
|
bootMark('server:booted-send');
|
|
109
155
|
post({ kind: 'booted', tick: server.host.state.tick, restored: restored !== undefined });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Rapier } from '@wildshard/engine/physics/rapier';
|
|
2
2
|
import { bootTask, bootProgress, bootTiming } from '@wildshard/engine/boot/timing';
|
|
3
3
|
import { isOutputIndex } from '@wildshard/format/outputAddress';
|
|
4
|
-
import { parseShardfile } from '@wildshard/format/shardSchema';
|
|
4
|
+
import { parseShardfile, type Shardfile } from '@wildshard/format/shardSchema';
|
|
5
5
|
import { contentHash } from '@wildshard/engine/game/shardfile/contentHash';
|
|
6
6
|
import { nodeNamedJsonCheck, nodeOutputDescriptorChecks } from '@wildshard/engine/game/shardfile/outputChecksNode';
|
|
7
7
|
import { carryOutputDescriptor, isBuildValidatedOutput, outputDescriptor, resolveOutputDescriptor, serverReadsFile } from '@wildshard/engine/game/shardfile/outputDescriptor';
|
|
@@ -133,12 +133,13 @@ function serverPackReader(root: string, slug: string, build: () => string, sourc
|
|
|
133
133
|
* P1-E5.2: the worker's product reader, loadHeadlessProduct over `fetch`. It verifies the same index, sizes and SHA-256
|
|
134
134
|
* addresses with the same checks; only where the bytes come from differs.
|
|
135
135
|
*/
|
|
136
|
-
export function fetchServerProduct(base: string, rapier: Rapier, held?: HeldRead): Promise<HeadlessRuntimeInput> {
|
|
137
|
-
return readServerProduct(new URL(base, globalThis.location.href).href, workerBuild, serverBytes, rapier, held);
|
|
136
|
+
export function fetchServerProduct(base: string, rapier: Rapier, held?: HeldRead, patch?: (shard: Shardfile) => Shardfile): Promise<HeadlessRuntimeInput> {
|
|
137
|
+
return readServerProduct(new URL(base, globalThis.location.href).href, workerBuild, serverBytes, rapier, held, undefined, patch);
|
|
138
138
|
}
|
|
139
139
|
/** A shard's server inputs under `root`, whichever server is reading: `source` is what differs. `hash`, a placed slug's shardfile (SA47),
|
|
140
|
-
* lets a slug the build's book lacks open from the cook's index.
|
|
141
|
-
|
|
140
|
+
* lets a slug the build's book lacks open from the cook's index. `patch` (DEVSERVER, SHARD-SOURCE AP19: `withDevGameplay`) changes
|
|
141
|
+
* the read shardfile before the product is made of it. */
|
|
142
|
+
export async function readServerProduct(root: string, build: () => string, source: ServerRead, rapier: Rapier, held?: HeldRead, hash?: string, patch?: (shard: Shardfile) => Shardfile): Promise<HeadlessRuntimeInput> {
|
|
142
143
|
const slug = new URL('.', root).pathname.split('/').at(-2) ?? '';
|
|
143
144
|
// C2: all of it is in the pack this build's book names, the server class only there (J91). The page lends what it holds
|
|
144
145
|
// (DL25), so that moves no bytes. A host with no book, or one offline after a new build, reads what the device kept.
|
|
@@ -155,8 +156,9 @@ export async function readServerProduct(root: string, build: () => string, sourc
|
|
|
155
156
|
// on bytes its build has already checked and the page has just read without checking. As on the page, only a build's own verdict
|
|
156
157
|
// for exactly these bytes spares the checks. A product with none, an outside one, keeps them.
|
|
157
158
|
const assembled = await bootTask('server:descriptor-read-and-verification', () => resolveOutputDescriptor(input, { offline: false, firstParty: true, hash: contentHash, read, checks: nodeOutputDescriptorChecks }));
|
|
158
|
-
const built = isBuildValidatedOutput(assembled),
|
|
159
|
-
if (!built) carryOutputDescriptor(assembled,
|
|
159
|
+
const built = isBuildValidatedOutput(assembled), parsed = built ? assembled : parseShardfile(assembled);
|
|
160
|
+
if (!built) carryOutputDescriptor(assembled, parsed);
|
|
161
|
+
const shard = patch === undefined ? parsed : patch(parsed);
|
|
160
162
|
const descriptor = outputDescriptor(shard);
|
|
161
163
|
if (descriptor === undefined) throw new Error('Standalone output has no verified index');
|
|
162
164
|
const files = new Map<string, { readonly path: string; readonly hash: string; readonly bytes: number }>();
|
|
@@ -37,7 +37,7 @@ export function runServerWorker(event: MessageEvent<unknown>): void {
|
|
|
37
37
|
const [control, game, harness, reads] = event.ports;
|
|
38
38
|
if (control === undefined || game === undefined) return;
|
|
39
39
|
const held = reads === undefined ? undefined : askHeldReads(reads);
|
|
40
|
-
runStandaloneServer({ control, game, ...harness === undefined ? {} : { harness }, ...typeof start.goto === 'string' ? { goto: start.goto } : {}, load: async (boot, slug) => fetchServerProduct(new URL(`../${slug}/`, new URL(boot.base, globalThis.location.href)).href, await rapierOf(held), held),
|
|
40
|
+
runStandaloneServer({ control, game, ...harness === undefined ? {} : { harness }, ...typeof start.goto === 'string' ? { goto: start.goto } : {}, load: async (boot, slug, patch) => fetchServerProduct(new URL(`../${slug}/`, new URL(boot.base, globalThis.location.href)).href, await rapierOf(held), held, patch),
|
|
41
41
|
strips: boot => fetchGridCollision(boot.base),
|
|
42
42
|
onSaveRefused: error => { console.warn('Standalone save refused, falling back', error); } });
|
|
43
43
|
}
|
|
@@ -16,6 +16,12 @@ export interface LoadingWaitEntry {
|
|
|
16
16
|
retryNavigation?: boolean;
|
|
17
17
|
/** Exact transport identity for diagnostics; never the human work caption. */
|
|
18
18
|
resource?: string;
|
|
19
|
+
/** FM6 (meta MMO-FAILURE-MODES-PLAN modes 33 to 35, 43, 44): the failure catalogue's ids for this wait (`packs-5xx`, `packs-429`,
|
|
20
|
+
* `book-5xx`, `storage-full`, `packs-5xx pack-broken`) and the line a player reads for it, with no address or raw error. */
|
|
21
|
+
failmode?: string;
|
|
22
|
+
line?: string;
|
|
23
|
+
/** A retry actually scheduled for this time (`diagnosticNow`): the card counts down to it. None scheduled, no countdown. */
|
|
24
|
+
dueAt?: number;
|
|
19
25
|
}
|
|
20
26
|
export interface LoadingWaitState { version: 1; sequence: number; pending: Map<number, LoadingWaitEntry> }
|
|
21
27
|
const loadingWaitKey = Symbol.for('engine.loading.waits.v1');
|
|
@@ -40,7 +46,7 @@ export function loadingWaitState(target: object = waitCarrier()): LoadingWaitSta
|
|
|
40
46
|
const state: LoadingWaitState = { version: 1, sequence: 0, pending: new Map() };
|
|
41
47
|
Reflect.set(target, loadingWaitKey, state); return state;
|
|
42
48
|
}
|
|
43
|
-
export type LoadingWaitOptions = Partial<Pick<LoadingWaitEntry, 'kind' | 'step' | 'owner' | 'startedAt' | 'progressAt' | 'loadedBytes' | 'totalBytes' | 'retry' | 'inline' | 'resource' | 'retryNavigation'>>;
|
|
49
|
+
export type LoadingWaitOptions = Partial<Pick<LoadingWaitEntry, 'kind' | 'step' | 'owner' | 'startedAt' | 'progressAt' | 'loadedBytes' | 'totalBytes' | 'retry' | 'inline' | 'resource' | 'retryNavigation' | 'failmode' | 'line' | 'dueAt'>>;
|
|
44
50
|
/** Register work without changing its lifetime or concurrency. Only an explicit
|
|
45
51
|
* failed-operation callback offers RETRY; pending work never implies reload. */
|
|
46
52
|
export function beginLoadingWait(label: string, options: LoadingWaitOptions = {}): number {
|
|
@@ -49,7 +55,9 @@ export function beginLoadingWait(label: string, options: LoadingWaitOptions = {}
|
|
|
49
55
|
startedAt: options.startedAt ?? now, progressAt: options.progressAt ?? now, loadedBytes: options.loadedBytes ?? 0,
|
|
50
56
|
totalBytes: options.totalBytes ?? null, retry: options.retry ?? null,
|
|
51
57
|
progress: '', inline: options.inline ?? false, ...(options.resource === undefined ? {} : {resource: options.resource}),
|
|
52
|
-
...(options.retryNavigation === undefined ? {} : {retryNavigation: options.retryNavigation})
|
|
58
|
+
...(options.retryNavigation === undefined ? {} : {retryNavigation: options.retryNavigation}),
|
|
59
|
+
...(options.failmode === undefined ? {} : {failmode: options.failmode}), ...(options.line === undefined ? {} : {line: options.line}),
|
|
60
|
+
...(options.dueAt === undefined ? {} : {dueAt: options.dueAt}) });
|
|
53
61
|
return id;
|
|
54
62
|
}
|
|
55
63
|
/** Only real byte growth or a semantic progress-key change changes the reported progress age. */
|
|
@@ -22,6 +22,9 @@ export const CELL_ABOVE: number = contentBounds.CELL_ABOVE;
|
|
|
22
22
|
export const CONTENT_MB: 1000000 = contentBounds.CONTENT_MB;
|
|
23
23
|
/** Provisional phone caps v1 (SF22a); shadow draws count in each draw cap. */
|
|
24
24
|
export const CONTENT_CAPS: { readonly l0: { readonly size: 62.5; readonly resident: number; readonly compressed: number; readonly triangles: 40000; readonly draws: 8; }; readonly l1: { readonly size: 125; readonly resident: number; readonly compressed: number; readonly triangles: 10000; readonly draws: 2; }; readonly far: { readonly resident: number; readonly compressed: 1000000; readonly triangles: 8000; readonly draws: 1; }; readonly library: { readonly resident: number; readonly compressed: number; }; readonly sim: { readonly resident: number; readonly compressed: number; }; readonly engineBase: number; readonly playing: number; readonly loading: number; readonly l0Count: 40; readonly l1Count: 32; readonly farCount: 9; readonly simCount: 4; readonly libraryCount: 4; readonly overlap: number; readonly residentFactor: 1.11; readonly nearRadius: 150; readonly shadowRadius: 80; readonly pitch: 562.5; } = contentBounds.CONTENT_CAPS;
|
|
25
|
+
/** GC13: the phone tier's playing envelope, G65's 1.0 GB (the shared caps' Explorer figure is 1.2 GB until SHARD-PLATFORM
|
|
26
|
+
* closes): a phone page admits, retains and evicts against this, so a straight walk stays under it. */
|
|
27
|
+
export const PHONE_PLAYING_BYTES: number = 1000 * contentBounds.CONTENT_MB;
|
|
25
28
|
|
|
26
29
|
export const TERRAIN_RES = 256; // vertices per side
|
|
27
30
|
|
|
@@ -50,6 +50,16 @@ const HELD_SLICE_MIN_MS = 4;
|
|
|
50
50
|
let heldSliceAt = Number.NEGATIVE_INFINITY;
|
|
51
51
|
/** Frames drawn while held, for `heldFrameTurn`. */
|
|
52
52
|
let heldFrames = 0;
|
|
53
|
+
/** GRID-CROSSING GC6 (QA 11-14 row 6, Jake on staging: a 37 s card crossing into Nalati at 2992x1434@2): a build the traveller
|
|
54
|
+
* is about to need (the world of the cell ahead, its entry on the road) is on the crossing's critical path. Its slices then
|
|
55
|
+
* get URGENT_BUILD_MS after each drawn frame, whatever the display's rate and whether the next vsync is due: the ordinary
|
|
56
|
+
* quarter of the fastest display interval gave a 120 Hz screen 2 ms a frame, and at 30 fps that is 6% of the wall clock, so
|
|
57
|
+
* an 11 s world took 30 s. The grid sets it while such a build runs; off by default. */
|
|
58
|
+
export const URGENT_BUILD_MS = 8;
|
|
59
|
+
let urgent = false;
|
|
60
|
+
export function setBuildUrgent(on: boolean): void { urgent = on; }
|
|
61
|
+
/** Whether a build the traveller is about to need is running (`setBuildUrgent`). */
|
|
62
|
+
export function buildUrgent(): boolean { return urgent; }
|
|
53
63
|
/** Whether the traveller waits for the build (a grid cell's loading screen shows); the grid sets it, off by default.
|
|
54
64
|
* The page sets it through `setBuildHeldTimed` (`heldTiming.ts`), which also times each held interval on Developer pages. */
|
|
55
65
|
export function setBuildHeld(on: boolean): void {
|
|
@@ -104,6 +114,7 @@ export function frameBudgetSpent(budgetMs: number, now: number = diagnosticNow()
|
|
|
104
114
|
// D110: a frame that overran its interval (drawn after the next was due: a phone at 4x CPU) is due the moment it lands,
|
|
105
115
|
// so the due rule would end every slice before it starts and no sliced build would run again; after such a frame the
|
|
106
116
|
// builds get their ordinary slice instead
|
|
117
|
+
if (urgent) return presenting(now) && now - lastDrawn >= Math.min(budgetMs, URGENT_BUILD_MS);
|
|
107
118
|
const overran = lastDrawn - lastFrameAt >= interval - DUE_SLACK_MS;
|
|
108
119
|
return presenting(now) && (now - lastDrawn >= Math.min(budgetMs, interval / 4, BUILD_FRAME_MS / 2) || (!overran && frameDue(now)));
|
|
109
120
|
}
|
|
@@ -175,5 +186,5 @@ export function paceYield(plain: () => Promise<void>, owner?: Scope, budgetMs?:
|
|
|
175
186
|
}
|
|
176
187
|
|
|
177
188
|
function yieldDue(budgetMs: number | undefined, now: number): boolean {
|
|
178
|
-
return !held && frameDue(now) || (budgetMs !== undefined && frameBudgetSpent(budgetMs, now));
|
|
189
|
+
return !held && (!urgent || budgetMs === undefined) && frameDue(now) || (budgetMs !== undefined && frameBudgetSpent(budgetMs, now));
|
|
179
190
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type { Collider } from '@dimforge/rapier3d-simd';
|
|
2
2
|
import type { Scope } from '../app/scope';
|
|
3
3
|
import { withOwner } from '../app/ownership';
|
|
4
|
-
import { decodeTerrainTile } from '@wildshard/format/terrainTileBytes';
|
|
4
|
+
import { decodeTerrainTile, type TerrainTileData } from '@wildshard/format/terrainTileBytes';
|
|
5
5
|
import type { Physics } from './Physics';
|
|
6
6
|
import { groups } from './groups';
|
|
7
|
-
import { tagCollider } from './surface';
|
|
7
|
+
import { isTerrainCollider, tagCollider } from './surface';
|
|
8
8
|
|
|
9
9
|
/** Install the baked critical heightfield in the local physics world; the owning scope removes it on unload. */
|
|
10
10
|
export function addBakedTerrainCollider(physics: Physics, bytes: Uint8Array, scope: Scope): Collider {
|
|
11
|
-
const data = decodeTerrainTile(bytes)
|
|
11
|
+
const data = decodeTerrainTile(bytes);
|
|
12
12
|
if (data.colours !== undefined) throw new Error('Collider terrain must contain heights only');
|
|
13
|
-
|
|
13
|
+
return addTerrainTileCollider(physics, data, scope);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A heights lattice (row-major, as the wire carries it) as the world's ground heightfield, owned by `scope`. */
|
|
17
|
+
export function addTerrainTileCollider(physics: Physics, data: Pick<TerrainTileData, 'resolution' | 'x' | 'z' | 'size' | 'heights'>, scope: Scope): Collider {
|
|
18
|
+
const r = data.resolution, heights = new Float32Array(r * r);
|
|
14
19
|
for (let z = 0; z < r; z++) for (let x = 0; x < r; x++) heights[x * r + z] = data.heights[z * r + x] ?? 0;
|
|
15
20
|
const collider = withOwner(scope, () => physics.world.createCollider(physics.R.ColliderDesc.heightfield(r - 1, r - 1, heights, { x: data.size, y: 1, z: data.size })
|
|
16
21
|
.setTranslation(data.x + data.size / 2, 0, data.z + data.size / 2).setCollisionGroups(groups('WORLD')).setFriction(0.9)));
|
|
@@ -18,3 +23,14 @@ export function addBakedTerrainCollider(physics: Physics, bytes: Uint8Array, sco
|
|
|
18
23
|
// Physics already owns the scoped handle and forgets its capture before freeing a replaced world.
|
|
19
24
|
return collider;
|
|
20
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* SHARD-SOURCE AP18 (DEVSERVER): `wildshard watch`'s new ground. The lattice goes in as the world's heightfield under
|
|
29
|
+
* `scope`, then every other terrain heightfield leaves the world (the boot's, or the last swap's). Returns how many went.
|
|
30
|
+
*/
|
|
31
|
+
export function swapTerrainCollider(physics: Physics, data: Pick<TerrainTileData, 'resolution' | 'x' | 'z' | 'size' | 'heights'>, scope: Scope): number {
|
|
32
|
+
const fresh = addTerrainTileCollider(physics, data, scope), old: Collider[] = [];
|
|
33
|
+
physics.world.forEachCollider(collider => { if (collider !== fresh && isTerrainCollider(collider)) old.push(collider); });
|
|
34
|
+
for (const collider of old) physics.world.removeCollider(collider, true);
|
|
35
|
+
return old.length;
|
|
36
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/** Base cruise is 14 m/s standalone or a grid cap ≤ 30. Developer boost
|
|
1
|
+
/** Base cruise is 14 m/s standalone or a grid cap ≤ 30. Developer boost is 4× everywhere: 56 in a shard, 120 on the road (J-road-4x). */
|
|
2
2
|
export function hoverSpeed(limit?: number, boost = false): number {
|
|
3
3
|
const base = limit ?? 14;
|
|
4
4
|
if (!Number.isFinite(base) || base <= 0 || base > 30) throw new RangeError('Invalid hover speed cap');
|
|
5
|
-
//
|
|
6
|
-
return boost ? base
|
|
5
|
+
// Jake 11-15 12:10: "Road push should be a 4x as well. So this should go to 120". 4× of the cap stays smooth over the strip.
|
|
6
|
+
return boost ? base * 4 : base;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/** m/s² the board loses gliding with no input, at or below the 14 m/s standalone cruise (25 % of its acceleration). */
|
|
@@ -431,6 +431,16 @@ export const ENGINE_STRINGS = {
|
|
|
431
431
|
"s_doctor_note": "Check every link the online world needs: this page, the signed release, the packs, the server and this browser.",
|
|
432
432
|
"s_doctor_open": "Check connection",
|
|
433
433
|
"s_doctor_failed": "Connection doctor",
|
|
434
|
+
"s_doctor_http_title": "The check didn't open",
|
|
435
|
+
"s_doctor_http_body": "The Connection check couldn't load just now. You're still here: try again, or go back to the game.",
|
|
436
|
+
"s_doctor_http_retry": "Try again",
|
|
437
|
+
"s_doctor_http_checking": "Checking…",
|
|
438
|
+
"s_doctor_http_back": "Back to the game",
|
|
439
|
+
"s_doctor_http_details": "Details",
|
|
440
|
+
"s_doctor_http_fact": "⟦0⟧. A check that opens says only that its page answered.",
|
|
441
|
+
"s_doctor_http_status": "HTTP ⟦0⟧",
|
|
442
|
+
"s_doctor_http_none": "No HTTP response",
|
|
443
|
+
"s_doctor_http_slow": "No answer in ⟦0⟧ s",
|
|
434
444
|
"s_build_title": "Build",
|
|
435
445
|
"s_build_running": "Running now",
|
|
436
446
|
"s_build_check": "Check",
|
|
@@ -738,7 +748,8 @@ export const ENGINE_STRINGS = {
|
|
|
738
748
|
"s_e94f3b418bf5": "Deletes the downloaded game files (every cache and the service worker) so the next load is a first visit. Keeps saves, settings and the review login.",
|
|
739
749
|
"s_9c6373f9a730": "Sound effects: MOSS-SoundEffect v2 · Stable Audio 3 Medium — Powered by Stability AI",
|
|
740
750
|
"s_ef691a454428": "Powered by Stability AI",
|
|
741
|
-
"s_7fc7e56bbd7f": "Music: MiniMax-Music3"
|
|
751
|
+
"s_7fc7e56bbd7f": "Music: MiniMax-Music3",
|
|
752
|
+
"s_hover_boost": "Boost"
|
|
742
753
|
} as const;
|
|
743
754
|
export type EngineStringKey = keyof typeof ENGINE_STRINGS;
|
|
744
755
|
const overrides: Partial<Record<EngineStringKey, string>> = {};
|