@wildshard/engine 0.1.21 → 0.1.23
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/lint/shardfile-boundaries.mjs +4 -2
- package/lint/sim-players.json +2 -13
- package/lint/wildshard-plugin.js +1 -1
- package/package.json +10 -2
- package/scripts/apfs-clone.mjs +5 -2
- package/scripts/app-build/catalogue.ts +39 -8
- package/scripts/app-build/serviceWorker.ts +4 -1
- package/scripts/app-build/splitOutput.mjs +33 -11
- package/scripts/audio-download-proof.mjs +1 -1
- package/scripts/check-spelled-paths.mjs +6 -3
- package/scripts/ci-pack.mjs +3 -3
- package/scripts/committed-fast-checks.mjs +2 -2
- package/scripts/engine-ci-shard.mjs +11 -0
- package/scripts/failmode-cases.mjs +1 -1
- package/scripts/failmode-proof.mjs +35 -11
- package/scripts/fight-page-census.mjs +131 -0
- package/scripts/goldens/board.py +44 -11
- package/scripts/goldens/native-residency.d.mts +1 -0
- package/scripts/goldens/native-residency.mjs +18 -4
- package/scripts/grid-crossing-walk-proof.mjs +3 -3
- package/scripts/hover-speed-probe.mjs +2 -2
- package/scripts/keep-copy.mjs +120 -0
- package/scripts/land.mjs +36 -6
- package/scripts/lane-live.mjs +136 -0
- package/scripts/leftovers-report.mjs +47 -0
- package/scripts/loading-card-proof.mjs +42 -9
- package/scripts/loading-flow/benchmax.mjs +57 -7
- package/scripts/loading-flow/stalls.d.mts +2 -0
- package/scripts/loading-flow/stalls.mjs +13 -0
- package/scripts/mmo-bots.mjs +11 -5
- package/scripts/mmo-grid-proof.mjs +74 -0
- package/scripts/mmo-seat-proof.mjs +43 -0
- package/scripts/net-lag-proof.mjs +1 -1
- package/scripts/nightly-heads.ts +13 -13
- package/scripts/nightly-model.ts +26 -12
- package/scripts/nightly.proof.ts +18 -5
- package/scripts/nightly.ts +13 -8
- package/scripts/no-astc-boot.mjs +77 -0
- package/scripts/online-rig.mjs +7 -7
- package/scripts/parity/boot-smoke.mjs +1 -1
- package/scripts/physics-route.json +6 -6
- package/scripts/pins-reuse.mjs +1 -0
- package/scripts/pins-staging.ts +54 -0
- package/scripts/pins.ts +5 -0
- package/scripts/release-cook.mjs +6 -2
- package/scripts/ring3.proof.ts +71 -0
- package/scripts/ring3.ts +100 -0
- package/scripts/scratch-dir.mjs +31 -12
- package/scripts/scratch-sweep.mjs +15 -23
- package/scripts/server-release/items.d.mts +7 -0
- package/scripts/server-release/items.mjs +28 -0
- package/scripts/server-release/publish.mjs +9 -1
- package/scripts/side-parity.mjs +1 -1
- package/scripts/test-products.json +1 -21
- package/scripts/tsconfig.json +2 -0
- package/scripts/vitest-ci-files.ts +5 -1
- package/scripts/vps/cook-follow.d.mts +6 -0
- package/scripts/vps/cook-follow.mjs +45 -0
- package/scripts/vps/harden-apply.sh +10 -1
- package/scripts/vps/rebuild.sh +104 -36
- package/scripts/vps/wildshard-config +106 -3
- package/scripts/warm-native-chrome.mjs +9 -3
- package/scripts/worker-client-fights.mjs +9 -3
- package/scripts/worktree-reap.mjs +15 -131
- package/scripts/worktree.mjs +92 -12
- package/src/client/app/entry.ts +2 -3
- package/src/client/engine/audio/audioLog.ts +7 -2
- package/src/client/engine/boot/contentRead.ts +24 -4
- package/src/client/engine/boot/diagnostics.ts +69 -1
- package/src/client/engine/boot/downloadGiveUp.ts +34 -0
- package/src/client/engine/combat/EquipmentService.ts +2 -0
- package/src/client/engine/core/Game.ts +6 -2
- package/src/client/engine/core/ktx2.ts +5 -3
- package/src/client/engine/core/ktx2Zstd.ts +2 -1
- package/src/client/engine/pwa/sw.js +26 -8
- package/src/client/engine/render/dataLook.ts +14 -7
- package/src/client/engine/render/lookLight.ts +64 -20
- package/src/client/engine/ui/Loading.ts +6 -8
- package/src/client/engine/ui/downloadFailed.ts +54 -0
- package/src/client/engine/ui/lookLightOption.ts +1 -1
- package/src/client/game/audio/cueDirector.ts +2 -1
- package/src/client/game/boot/spawnDownload.ts +12 -1
- package/src/client/game/boss/arenaRoom.ts +4 -3
- package/src/client/game/boss/roamingProjection.ts +1 -1
- package/src/client/game/devScene/hook.ts +1 -1
- package/src/client/game/devScene/liveLook.ts +1 -1
- package/src/client/game/grid/copyPrompts.ts +3 -4
- package/src/client/game/grid/dataCellKit.ts +99 -0
- package/src/client/game/grid/enteredEquipment.ts +11 -2
- package/src/client/game/grid/live.ts +9 -299
- package/src/client/game/grid/liveSession.ts +31 -8
- package/src/client/game/grid/neighbourLife.ts +50 -32
- package/src/client/game/grid/products.ts +21 -7
- package/src/client/game/grid/reveal.ts +7 -2
- package/src/client/game/grid/session.ts +10 -74
- package/src/client/game/plugin/weaponFamily.ts +6 -0
- package/src/client/game/population/signals.ts +1 -1
- package/src/client/game/quest/chapterDirector.ts +1 -0
- package/src/client/game/shardfile/clientBossTelegraph.ts +4 -3
- package/src/client/game/shardfile/clientWorker.ts +35 -9
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/runtimeProduct.ts +9 -5
- package/src/client/game/shardfile/wirePage.ts +5 -2
- package/src/client/game/shardfile/worldSceneTextures.ts +15 -9
- package/src/client/host/online/shell.ts +37 -13
- package/src/cook/game/cookWorker.ts +8 -5
- package/src/cook/game/tierTextures.ts +5 -3
- package/src/server/engine/net/simWorld.ts +3 -4
- package/src/server/game/grid/cellHome.ts +58 -0
- package/src/server/game/grid/room.ts +2 -38
- package/src/server/game/grid/simulation.ts +5 -4
- package/src/server/game/plugin/mover.ts +18 -14
- package/src/server/game/shardfile/declaredKitItems.ts +39 -9
- package/src/server/host/bake/headlessWorker.ts +3 -3
- package/src/server/host/dedicated/cellHost.ts +2 -2
- package/src/server/host/dedicated/cellProtocol.ts +1 -1
- package/src/server/host/dedicated/cellWorker.ts +5 -3
- package/src/server/host/dedicated/dedicatedRoom.ts +8 -3
- package/src/server/host/dedicated/gridCells.ts +5 -3
- package/src/server/host/dedicated/main.ts +12 -7
- package/src/server/host/dedicated/packReader.ts +15 -2
- package/src/server/host/dedicated/playerStore.ts +1 -1
- package/src/server/host/dedicated/workerTable.ts +0 -10
- package/src/server/host/dedicated/world.ts +39 -5
- package/src/server/host/headlessRuntime.ts +11 -6
- package/src/server/host/standalone/cellWorld.ts +21 -7
- package/src/server/host/standalone/gridServer.ts +3 -1
- package/src/server/host/standalone/roadWorld.ts +6 -0
- package/src/shared/engine/physics/gridBorders.ts +15 -1
- package/src/shared/engine/saves/shape.ts +17 -2
- package/src/shared/engine/sim/snapshot.ts +5 -5
- package/src/shared/engine/strings.ts +10 -0
- package/src/shared/game/grid/placementRows.ts +4 -3
- package/src/shared/game/ledger.ts +13 -4
- package/src/shared/game/loot/platformCatalogue.ts +14 -0
- package/src/shared/game/quest/ledger.ts +3 -3
- package/src/shared/game/shardfile/items.ts +9 -1
- package/src/shared/host/headlessJourney.ts +3 -3
- package/src/shared/host/headlessTape.ts +7 -6
- package/src/shared/host/releaseRows.ts +4 -1
- package/src/client/game/grid/cellLoading.ts +0 -110
- package/src/client/game/grid/cellScreens.ts +0 -48
|
@@ -6,7 +6,7 @@ import type { LiveGridWire } from '../grid/liveSession';
|
|
|
6
6
|
import { chosenCell, gotoHosted, pageGoto } from '../../../shared/game/grid/pageMode';
|
|
7
7
|
import type { SystemSpec } from '@wildshard/engine/app/systems';
|
|
8
8
|
import type { Player } from '@wildshard/engine/player/Player';
|
|
9
|
-
import { Vector3, type Object3D } from 'three';
|
|
9
|
+
import { Scene, Vector3, type Object3D } from 'three';
|
|
10
10
|
import { appIdentity } from '@wildshard/engine/app/identity';
|
|
11
11
|
import { bootMark, bootTask } from '@wildshard/engine/boot/timing';
|
|
12
12
|
import { SEAT_GRACE_MS, seatedInTime } from './seatGrace';
|
|
@@ -15,7 +15,8 @@ import { saveEnvironment } from '@wildshard/engine/saves/environment';
|
|
|
15
15
|
import { jsonSlot } from '@wildshard/engine/saves/slots';
|
|
16
16
|
import { syncPageRewards } from '../../../shared/game/saves';
|
|
17
17
|
import type { SaveStorage } from '@wildshard/engine/saves/store';
|
|
18
|
-
import { atMostLeaveWait, holdLeaving } from '@wildshard/engine/boot/lastEnd';
|
|
18
|
+
import { atMostLeaveWait, holdLeaving, markUnload } from '@wildshard/engine/boot/lastEnd';
|
|
19
|
+
import { dropTabArrival, setTitleArrival } from '@wildshard/engine/boot/titleArrival';
|
|
19
20
|
import { countedWait } from '@wildshard/engine/boot/waits';
|
|
20
21
|
import { contentURL } from '@wildshard/engine/boot/contentBase';
|
|
21
22
|
import { diagnosticNow } from '@wildshard/engine/core/clock';
|
|
@@ -57,6 +58,7 @@ import { OWNED_ROW } from '../../../shared/game/loot/ownedRows';
|
|
|
57
58
|
import { declaredKitSlots } from '../../../shared/game/shardfile/items';
|
|
58
59
|
import { earlyStandalone, serverRoute } from './serverRoute';
|
|
59
60
|
import { worldHosted } from '../grid/oneWayIn';
|
|
61
|
+
import { setLampFollow } from '@wildshard/engine/render/lookLight';
|
|
60
62
|
|
|
61
63
|
type Creatures = Pick<RowBodiesView, 'animals' | 'spawn' | 'retire' | 'onWindup' | 'presentHit' | 'presentDeath' | 'presentReward'>;
|
|
62
64
|
/** What a grid page lends: its crossing follows the server, and its creatures are the entered cell's. */
|
|
@@ -128,7 +130,16 @@ function releaseKeep(): ReleaseKeep {
|
|
|
128
130
|
};
|
|
129
131
|
}
|
|
130
132
|
/** E7.2d: the page's seat in the one world, in a shell of the same shape. */
|
|
131
|
-
|
|
133
|
+
/** FM3 mode 23: how the online shell leaves this document on purpose, through the page's own saves (shell.ts `OnlineLeaving`). */
|
|
134
|
+
interface OnlineLeaving { readonly arrive: (slug: string) => void; readonly unarrive: () => void; readonly unload: (reason: string) => void;
|
|
135
|
+
readonly reloadStale: () => Promise<boolean>; readonly reloadByHand: () => Promise<void>; readonly settle: () => void }
|
|
136
|
+
const onlineLeaving: OnlineLeaving = {
|
|
137
|
+
arrive: slug => { setTitleArrival({ slug, mode: 'enter' }, { tab: true }); }, unarrive: dropTabArrival, unload: reason => { markUnload(reason); },
|
|
138
|
+
reloadStale: async () => (await import('@wildshard/engine/boot/browserChunkRecovery')).reloadRefusedBuild(true),
|
|
139
|
+
reloadByHand: async () => { await (await import('@wildshard/engine/boot/browserChunkRecovery')).reloadPastWorker(); },
|
|
140
|
+
settle: () => { void (async () => { (await import('@wildshard/engine/boot/browserChunkRecovery')).settleRefusedBuild(); })(); },
|
|
141
|
+
};
|
|
142
|
+
interface OnlineModule { readonly startOnline: (config: BuildWorld & { keep: ReleaseKeep; leaving: OnlineLeaving; loaded: string; build: string; identity: (name?: string) => NetIdentity; grid?: { readonly cell: string; readonly cells: readonly string[]; readonly placed: (cell: string, at: { readonly x: number; readonly y: number; readonly z: number; readonly yaw: number }) => void; readonly reenter: (cell: string) => void; readonly goto?: boolean } }) => Promise<Shell> }
|
|
132
143
|
interface Shell { readonly redials?: true; devColliders?: (name: string, boxes: readonly DevBox[]) => void; pause: () => void; hold: (on: boolean) => void; bossGod: () => void; raise: (flag: string) => void; join: (id: string, x: number, y: number, z: number) => { readonly client: NetClient; readonly move: (x: number, y: number, z: number) => void }; readonly client: NetClient; readonly booted: Promise<{ readonly restored: boolean }>; place: (x: number, y: number, z: number, yaw: number) => void; hardHits: (by: number) => void; ready: () => void; leave?: () => Promise<void>; save: () => Promise<{ readonly tick: number; readonly ok: boolean }>; probe: () => Promise<{ readonly tickMs: number }>; dispose: () => void }
|
|
133
144
|
|
|
134
145
|
const SAVE_EVERY_MS = 30_000;
|
|
@@ -156,6 +167,10 @@ export interface WorkerClientReport {
|
|
|
156
167
|
owned: Readonly<Record<string, number>>; sky: number | null; day: number | null;
|
|
157
168
|
/** What this page drew of what it only hears, by name. */
|
|
158
169
|
drawn: Readonly<Record<string, number>>;
|
|
170
|
+
/** EG-15: every view word the server said to this page, by name: what `drawn` is held against (scripts/fight-page-census.mjs). */
|
|
171
|
+
heard: Readonly<Record<string, number>>;
|
|
172
|
+
/** Of those, the words for a view this page hasn't built (`wirePage.unbuilt`): not drawn, and not dark. */
|
|
173
|
+
offstage: Readonly<Record<string, number>>;
|
|
159
174
|
/** Movers this page holds, the poses rows have given them, and the highest drift rows have laid. */
|
|
160
175
|
movers: number; posed: number; sand: number;
|
|
161
176
|
/** Bodies this page made and the rows put away, by kind: what its own sim still builds. */
|
|
@@ -165,8 +180,14 @@ export interface WorkerClientReport {
|
|
|
165
180
|
/** What corrections disagreed on, and server-owned transitions that were deliberately not corrections. */
|
|
166
181
|
missed: Readonly<NetPlayer['predictor']['missed']>; misses: readonly (readonly number[])[]; authoritative: Readonly<NetPlayer['predictor']['authoritative']>;
|
|
167
182
|
}
|
|
168
|
-
/** A fight as a proof reads it: its row, where its body stands and the server's name for it.
|
|
169
|
-
|
|
183
|
+
/** A fight as a proof reads it: its row, where its body stands and the server's name for it. `shown` (EG-15): the page's body for that row
|
|
184
|
+
* is in the scene and visible; null when the page holds no row body for it (an open arena draws its own, off its view words). */
|
|
185
|
+
export type WorkerClientFight = EncounterRow & { readonly at: { readonly x: number; readonly y: number; readonly z: number } | null; readonly name: string | null; readonly shown: boolean | null };
|
|
186
|
+
/** Whether an object is drawn: visible, and so is every parent up to a scene. */
|
|
187
|
+
function inScene(object: Object3D): boolean {
|
|
188
|
+
for (let at: Object3D | null = object; at !== null; at = at.parent) { if (!at.visible) return false; if (at instanceof Scene) return true; }
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
170
191
|
declare global { interface Window { __onlinePlayers?: () => OtherPlayers['shown']; __workerClientFights?: () => readonly WorkerClientFight[]; __workerClientHits?: (by: number) => void; __workerClientTravel?: (to: ShardSlug) => void;__workerClientSky?: (name: string) => void; __workerClientTime?: (pick: OptionValue<'time'>) => void; __workerClientRow?: (name: string) => number | undefined; __workerClientFlag?: (flag: string) => void; __workerClientDevColliders?: (name: string, boxes: readonly DevBox[]) => void; __workerClientRows?: (kind: string) => readonly { readonly x: number; readonly y: number; readonly z: number }[]; __workerClientGate?: (flag: string) => boolean; __workerClientBot?: (id: string, x: number, y: number, z: number) => { readonly move: (x: number, y: number, z: number) => void; readonly press: (id: string) => void; readonly end: () => void }; __workerClient?: () => WorkerClientReport; __workerClientSave?: () => Promise<void> } }
|
|
171
192
|
|
|
172
193
|
/** The page's pose inputs, as acts short enough to go. */
|
|
@@ -351,7 +372,7 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
|
|
|
351
372
|
// a page that left while it asked never joins (Codex review): a cancelled load must not take the device's seat
|
|
352
373
|
if (!answered || scope.disposed) throw new Error('The page left before it joined the world');
|
|
353
374
|
const { grid } = ports, booted = grid?.booted;
|
|
354
|
-
return startOnline({ ...world, keep: releaseKeep(), loaded: slug, build, identity: name => deviceIdentity(storage, savePrefix, name),
|
|
375
|
+
return startOnline({ ...world, keep: releaseKeep(), leaving: onlineLeaving, loaded: slug, build, identity: name => deviceIdentity(storage, savePrefix, name),
|
|
355
376
|
...(grid === null || booted === undefined ? {} : { grid: { cell: booted, cells: grid.cells.map(cell => cell.instance), placed: (cell, at) => { grid.serverPlace?.(cell, at); }, reenter: cell => { grid.reenter?.(cell); },
|
|
356
377
|
...(pageGoto() === booted ? { goto: true } : {}) } }) });
|
|
357
378
|
};
|
|
@@ -419,6 +440,8 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
|
|
|
419
440
|
wirePage.led = () => net.predictor.leading; wirePage.rowBody = handle => bodies.get(handle)?.body ?? null;
|
|
420
441
|
wirePage.namedBody = id => { for (const [handle, { body }] of bodies) if (client.entities.get(handle)?.id === id) return body; return null; };
|
|
421
442
|
scope.onDispose(() => { wirePage.unbind(); wirePage.led = () => false; wirePage.rowBody = () => null; wirePage.namedBody = () => null; });
|
|
443
|
+
// SHARD-SOURCE AP24b: a look lamp that follows an actor rides its body, or one of its bones, by the server's name for it
|
|
444
|
+
scope.onDispose(setLampFollow(ports.scene, (actor, bone) => { const body = wirePage.namedBody(actor); return body === null ? null : bone === undefined ? body.mesh : body.mesh.skeleton.getBoneByName(bone) ?? null; }));
|
|
422
445
|
// J116: the lock's body by the server's name for it
|
|
423
446
|
net.lockTarget = () => {
|
|
424
447
|
if (lockOn.state !== 'locked' || lockOn.target === null) return undefined;
|
|
@@ -465,9 +488,11 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
|
|
|
465
488
|
if (shell.redials === true) others = new (await import('@wildshard/engine/net/otherPlayers')).OtherPlayers(client, ports.scene, scope, player.position);
|
|
466
489
|
if (new URLSearchParams(location.search).has('bossGod')) shell.bossGod();
|
|
467
490
|
bootMark('server:ready-send'); shell.ready();
|
|
468
|
-
const
|
|
491
|
+
const heard: Record<string, number> = {};
|
|
492
|
+
const started = diagnosticNow(), report: WorkerClientReport = { drawn: wirePage.drawn, heard, offstage: wirePage.offstage, frames: 0, framesPerSecond: 0, ticksPerSecond: 0, correctionsPerMinute: 0, corrections: 0, retired: {}, spawnMs: {}, missed: net.predictor.missed, misses: net.predictor.misses, authoritative: net.predictor.authoritative, worstOffset: 0, queue: 0, replaysPerFrame: 0, delayMs: 0, jitterMs: 0, interpHeld: 0, interpStarved: 0, mainMsP95: 0, workerTickMs: 0, rows: 0, attacks: 0, hits: 0, kills: 0, refused: 0, held: 0, dropped: 0, hp: 0, falls: 0, closed: null, x: 0, z: 0, cell: 0, serverX: 0, serverZ: 0, restored, savedTick: -1, savedOk: false, receipts: [], quests: {}, flags: [], paid: 0, fights: [], owned: {}, sky: null, day: null, clawed: false, own: null, movers: 0, posed: 0, sand: 0 };
|
|
469
493
|
if (unseated) void shell.booted.then(answer => { report.restored = answer.restored; bootMark('server:seated-late'); return undefined; }, () => undefined);
|
|
470
494
|
scope.onDispose(client.onLedger(receipt => { report.receipts.push(`${receipt.grant}:${receipt.name}`); }));
|
|
495
|
+
scope.onDispose(client.onView(({ name }) => { heard[name] = (heard[name] ?? 0) + 1; }));
|
|
471
496
|
const contacts: NetCombatEvent[] = [];
|
|
472
497
|
scope.onDispose(client.onTravel(() => { contacts.length = 0; }));
|
|
473
498
|
scope.onDispose(client.onCombat(event => {
|
|
@@ -521,7 +546,7 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
|
|
|
521
546
|
let inputs = poses.get(id);
|
|
522
547
|
if (inputs === undefined) { inputs = {}; poses.set(id, inputs); }
|
|
523
548
|
inputs[field] = value;
|
|
524
|
-
for (const [handle, { body }] of bodies) if (client.entities.get(handle)?.id === id) { body.mem[field] = value; break; }
|
|
549
|
+
for (const [handle, { body }] of bodies) if (client.entities.get(handle)?.id === id) { body.mem[field] = value; wirePage.drew(name); break; }
|
|
525
550
|
}));
|
|
526
551
|
const decks = new NetMovers(client, wirePage.movers, player.position);
|
|
527
552
|
scope.onDispose(net.world.addMover(decks));
|
|
@@ -606,7 +631,8 @@ async function startWorkerClient(ports: WorkerClientPorts, card: ReturnType<type
|
|
|
606
631
|
const out: WorkerClientFight[] = [];
|
|
607
632
|
for (const fight of wirePage.encounters()) {
|
|
608
633
|
const body = client.latest === null ? null : client.fields(client.latest, fight.body);
|
|
609
|
-
|
|
634
|
+
const held = bodies.get(fight.body)?.body.mesh ?? null;
|
|
635
|
+
out.push({ ...fight, at: body === null ? null : { x: Number(body['x']), y: Number(body['y']), z: Number(body['z']) }, name: client.entities.get(fight.body)?.id ?? null, shown: held === null ? null : inScene(held) });
|
|
610
636
|
}
|
|
611
637
|
return out;
|
|
612
638
|
};
|
|
@@ -23,6 +23,6 @@ export function shardfileLook(look: Shardfile['look'], assets?: ReadonlyMap<stri
|
|
|
23
23
|
// exposure and vignette); the bloom radius rides the bloom, which the row and the tier gate
|
|
24
24
|
return dataLook({ day: look.day ?? DATA_LOOK_DAY, dayOverride: look.dayOverride, keys: look.keys, lut, neutral: look.grade.tone === 'neutral', aces: look.grade.tone === 'aces',
|
|
25
25
|
exposure: look.grade.exposure, vignette: look.grade.vignette ?? null, bloomRadius: resolved.bloom.radius, sky: look.sky?.graph ?? null,
|
|
26
|
-
light: { rim: resolved.rim, pools: resolved.pools, heightFogDensity: resolved.atmosphere.fogHeightDensity, lamps: resolved.lamps, bounce: resolved.bounce, environment: resolved.environment,
|
|
26
|
+
light: { rim: resolved.rim, pools: resolved.pools, heightFogDensity: resolved.atmosphere.fogHeightDensity, lamps: resolved.lamps, lampsLit: resolved.lampsLit, bounce: resolved.bounce, environment: resolved.environment,
|
|
27
27
|
shadow: resolved.shadow, motes: resolved.motes } });
|
|
28
28
|
}
|
|
@@ -12,6 +12,7 @@ import { ClientAssets } from './clientAssets';
|
|
|
12
12
|
import { buildYield, pacedResolve, workSlice, type WorkSlice } from '@wildshard/engine/core/workSlice';
|
|
13
13
|
import { pageScope } from '@wildshard/engine/app/resources';
|
|
14
14
|
import { waitFor } from '@wildshard/engine/boot/waits';
|
|
15
|
+
import { bootTask } from '@wildshard/engine/boot/timing';
|
|
15
16
|
import { currentOwner } from '@wildshard/engine/app/ownership';
|
|
16
17
|
import { shardProductData } from '../../../shared/game/shardfile/productData';
|
|
17
18
|
import { absentShardProduct, type ShardProduct } from '../../../shared/game/shardfile/shardProduct';
|
|
@@ -374,12 +375,15 @@ export async function runtimeLookMaterials(ctx: Pick<ShardContext, 'scope' | 'ga
|
|
|
374
375
|
}));
|
|
375
376
|
shard = { ...shard, look: { ...look, families: [], materials }, terrain: null, props: null };
|
|
376
377
|
}
|
|
377
|
-
const assets =
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
const assets = await bootTask(`look:material-inputs ${source.identity.slug}`, async () => {
|
|
379
|
+
const files = new Map(product.assets.retained);
|
|
380
|
+
const graphFiles = Object.values(shard.look.materials).flatMap(entry => entry.family === 'graph' && 'file' in entry ? [entry.file] : []);
|
|
381
|
+
for (const ref of graphFiles) files.set(ref, await product.assets.read(ref));
|
|
382
|
+
for (const ref of new Set([...materialTextureRefs(shard.look.materials), ...keptGraphFileTextureRefs(shard.look.materials, hash => files.get(hash))])) files.set(ref, await product.assets.read(ref));
|
|
383
|
+
return files;
|
|
384
|
+
});
|
|
381
385
|
if (ctx.scope.disposed) throw new Error('Runtime look scope unloaded while reading materials');
|
|
382
|
-
return clientMaterials(shard, assets, renderer, ctx.scope, { trustedGraphs: true, ...(graphs === undefined ? {} : { graphs }), ...(units === undefined ? {} : { units }) });
|
|
386
|
+
return bootTask(`look:material-compile ${source.identity.slug}`, () => clientMaterials(shard, assets, renderer, ctx.scope, { trustedGraphs: true, ...(graphs === undefined ? {} : { graphs }), ...(units === undefined ? {} : { units }) }));
|
|
383
387
|
}
|
|
384
388
|
|
|
385
389
|
/** Prepare the requested original graph materials for resident effects and boss storms. */
|
|
@@ -111,8 +111,11 @@ export class WirePage {
|
|
|
111
111
|
}
|
|
112
112
|
/** The kind a row spawns as here: its declared species' page kind, else the wire's `kind` (a native body, an older server). */
|
|
113
113
|
rowKind(species: unknown, kind: string): string { return typeof species === 'string' && species !== '' ? this.speciesKinds.get(species) ?? kind : kind; }
|
|
114
|
-
/** Count
|
|
115
|
-
drew(what: string): void { this.drawn[what] = (this.drawn[what] ?? 0) +
|
|
114
|
+
/** Count a thing drawn, or `times` of them (a frame that draws every word heard since the last). */
|
|
115
|
+
drew(what: string, times = 1): void { this.drawn[what] = (this.drawn[what] ?? 0) + times; }
|
|
116
|
+
/** Words for a view this page hasn't built (a room nobody entered), by name: heard, and rightly not drawn (EG-15). */
|
|
117
|
+
readonly offstage: Record<string, number> = {};
|
|
118
|
+
unbuilt(what: string): void { this.offstage[what] = (this.offstage[what] ?? 0) + 1; }
|
|
116
119
|
|
|
117
120
|
/** One of this player's lines as the server last said it: 0 for none. */
|
|
118
121
|
line(name: string): number { return this.client?.owned.get(name) ?? 0; }
|
|
@@ -16,6 +16,8 @@ import { prepareLentLooks, setLentParam, setLentTexture } from './lentLooks';
|
|
|
16
16
|
import { applyTextureSampler } from './clientMaterials';
|
|
17
17
|
import type { SceneHandles } from './sceneHandles';
|
|
18
18
|
import type { ShardProduct } from '../../../shared/game/shardfile/shardProduct';
|
|
19
|
+
import { waitFor } from '@wildshard/engine/boot/waits';
|
|
20
|
+
import { bootTask } from '@wildshard/engine/boot/timing';
|
|
19
21
|
|
|
20
22
|
/** Client-only: load each declared texture under `owner`, lend it to its compiled looks (they are lent first) and
|
|
21
23
|
* publish a product texture that names a handle, and a volume with its numbers for the world's variant (`cube`). */
|
|
@@ -55,7 +57,8 @@ export async function lendWorldSceneTextures(rows: readonly WorldSceneLentTextur
|
|
|
55
57
|
/** A baked volume: its deflated RGBA8 voxels as a linear 3D texture (GPU-only once uploaded), lent with its box to its looks. */
|
|
56
58
|
async function lendVolume(row: Extract<WorldSceneLentTexture, { kind: 'volume' }>, volume: Extract<WorldSceneLentTexture, { kind: 'volume' }>['files']['cell']['phone'],
|
|
57
59
|
owner: Scope, product: Pick<ShardProduct, 'url'>, handles: SceneHandles): Promise<void> {
|
|
58
|
-
const
|
|
60
|
+
const url = product.url(volume.file);
|
|
61
|
+
const bytes = await bootTask(`texture:volume-inflate ${volume.file}`, () => waitFor('Preparing volume texture', fetchDeflatedBytes(url), 'work', url)), [x, y, z] = volume.size;
|
|
59
62
|
if (owner.disposed) throw new Error('World scene textures unloaded while loading');
|
|
60
63
|
if (bytes.length !== x * y * z * 4) throw new Error(`Lent volume ${row.label} size differs`);
|
|
61
64
|
const texture = owner.own(new Data3DTexture(bytes, x, y, z));
|
|
@@ -70,8 +73,8 @@ async function lendVolume(row: Extract<WorldSceneLentTexture, { kind: 'volume' }
|
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
/** A product's raw r8 texels as a data texture (its wrap and magnification; trilinear with mipmaps, else linear). */
|
|
73
|
-
async function loadRaster(row: Extract<WorldSceneLentTexture, { kind: 'raster' }>, product: Pick<ShardProduct, 'file'>): Promise<Texture> {
|
|
74
|
-
const bytes = Uint8Array.from(await product.file(row.file)), [width, height] = row.size;
|
|
76
|
+
async function loadRaster(row: Extract<WorldSceneLentTexture, { kind: 'raster' }>, product: Pick<ShardProduct, 'file' | 'url'>): Promise<Texture> {
|
|
77
|
+
const bytes = Uint8Array.from(await bootTask(`texture:raster-read ${row.file}`, () => waitFor('Reading texture', product.file(row.file), 'file', product.url(row.file)))), [width, height] = row.size;
|
|
75
78
|
if (bytes.length !== width * height) throw new Error(`Lent raster ${row.label} size differs`);
|
|
76
79
|
const texture = new DataTexture(bytes, width, height, RedFormat, UnsignedByteType);
|
|
77
80
|
texture.wrapS = texture.wrapT = row.wrap === 'repeat' ? RepeatWrapping : ClampToEdgeWrapping;
|
|
@@ -81,10 +84,11 @@ async function loadRaster(row: Extract<WorldSceneLentTexture, { kind: 'raster' }
|
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
/** A product's own KTX2 blob for the tier (its encoded orientation, flipY false), sampled by its row; GPU-only once uploaded. */
|
|
84
|
-
async function loadProduct(row: Extract<WorldSceneLentTexture, { kind: 'product' }>, product: Pick<ShardProduct, 'file'>, loader: KTX2Loader | null): Promise<Texture> {
|
|
87
|
+
async function loadProduct(row: Extract<WorldSceneLentTexture, { kind: 'product' }>, product: Pick<ShardProduct, 'file' | 'url'>, loader: KTX2Loader | null): Promise<Texture> {
|
|
85
88
|
if (loader === null) throw new Error('Product textures need a KTX2 reader');
|
|
86
|
-
const
|
|
87
|
-
const
|
|
89
|
+
const file = row.file[TIER], url = product.url(file);
|
|
90
|
+
const bytes = Uint8Array.from(await bootTask(`texture:read ${file}`, () => waitFor('Reading texture', product.file(file), 'file', url)));
|
|
91
|
+
const texture = await bootTask(`texture:decode ${file}`, () => waitFor('Preparing texture', new Promise<Texture>((resolve, reject) => { loader.parse(bytes.buffer, resolve, reject); }), 'worker', url));
|
|
88
92
|
texture.flipY = false; texture.name = row.label;
|
|
89
93
|
if (row.colour !== undefined) texture.colorSpace = row.colour === 'srgb' ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
90
94
|
applyTextureSampler(texture, row.sampler);
|
|
@@ -95,8 +99,9 @@ async function loadProduct(row: Extract<WorldSceneLentTexture, { kind: 'product'
|
|
|
95
99
|
|
|
96
100
|
async function blob(url: string): Promise<Blob> {
|
|
97
101
|
let type = '';
|
|
98
|
-
const
|
|
99
|
-
|
|
102
|
+
const path = phoneUrl(url);
|
|
103
|
+
const bytes = await bootTask(`texture:layer-read ${path}`, () => waitFor('Reading texture layer', readContent(path, 25_000_000, {fetch: (address, init) => fetch(address, init),
|
|
104
|
+
response: response => {type = response.headers.get('content-type') ?? '';}}), 'file', path));
|
|
100
105
|
return new Blob([bytes], {type});
|
|
101
106
|
}
|
|
102
107
|
|
|
@@ -116,7 +121,8 @@ async function loadLayers(row: Extract<WorldSceneLentTexture, { kind: 'layers' }
|
|
|
116
121
|
const files = await Promise.all(row.layers.map(layer => Promise.all([blob(`${row.base}/${layer.name}.jpg`), layer.alpha ? blob(`${row.base}/${layer.name}-a.jpg`) : null])));
|
|
117
122
|
for (const [i, [rgb, alpha]] of files.entries()) {
|
|
118
123
|
if (slice.due()) await slice.yield();
|
|
119
|
-
const
|
|
124
|
+
const path = `${row.base}/${row.layers[i]?.name ?? i}`;
|
|
125
|
+
const texels = await bootTask(`texture:layer-decode ${path}`, () => waitFor('Preparing texture layer', decodeLayerTexels(rgb, alpha, size), 'worker', path));
|
|
120
126
|
if (texels !== null) { data.set(texels, i * size * size * 4); continue; }
|
|
121
127
|
const colour = await createImageBitmap(rgb), cover = alpha === null ? null : await createImageBitmap(alpha), at = i * size * size * 4;
|
|
122
128
|
try {
|
|
@@ -179,10 +179,32 @@ export function connectOnline(config: OnlineConfig, view: OnlineView): OnlineShe
|
|
|
179
179
|
dispose: () => { records?.dispose(); redial.dispose(); client.dispose(); link?.close('disposed'); } };
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
/** FM3's proof (mode 23, 2026-11-15): how the page leaves this document on purpose. This bundle's saves have no storage (OF4's
|
|
183
|
+
* `keep`), so the tap it hands the next document (`setTitleArrival`), the unload it marks (`lastEnd`) and the reload claims it
|
|
184
|
+
* settles were written nowhere: the new-build Reload came back as a "player reload" and landed on the title. The page lends its own
|
|
185
|
+
* (clientWorker.ts `onlineLeaving`); this module's copies are the fallback for a page that lends none (tests). */
|
|
186
|
+
export interface OnlineLeaving {
|
|
187
|
+
/** QA row 16: the tap that brought the player here, for this tab's next document only */
|
|
188
|
+
readonly arrive: (slug: string) => void;
|
|
189
|
+
/** that tap, when the reload it was for didn't happen */
|
|
190
|
+
readonly unarrive: () => void;
|
|
191
|
+
/** the game is about to navigate on purpose (lastEnd) */
|
|
192
|
+
readonly unload: (reason: string) => void;
|
|
193
|
+
/** J54/J174: reload into the server's build, once per tab; false when there is none to reload into, or this tab already did */
|
|
194
|
+
readonly reloadStale: () => Promise<boolean>;
|
|
195
|
+
/** a player's tap on a stale tab: the next document comes from the network */
|
|
196
|
+
readonly reloadByHand: () => Promise<void>;
|
|
197
|
+
/** a seat on this build settles the reload that brought this tab here */
|
|
198
|
+
readonly settle: () => void;
|
|
199
|
+
}
|
|
200
|
+
const OWN_LEAVING: OnlineLeaving = {
|
|
201
|
+
arrive: slug => { setTitleArrival({ slug, mode: 'enter' }, { tab: true }); }, unarrive: dropTabArrival, unload: reason => { markUnload(reason); },
|
|
202
|
+
reloadStale: async () => (await import('@wildshard/engine/boot/browserChunkRecovery')).reloadRefusedBuild(true),
|
|
203
|
+
reloadByHand: async () => { await (await import('@wildshard/engine/boot/browserChunkRecovery')).reloadPastWorker(); },
|
|
204
|
+
settle: () => { void (async () => { (await import('@wildshard/engine/boot/browserChunkRecovery')).settleRefusedBuild(); })(); },
|
|
205
|
+
};
|
|
184
206
|
/** A seat on this build settles any reload that brought this tab here, so a sitting can ride more than one deploy. */
|
|
185
|
-
async function settled(booted: OnlineShell['booted']): Promise<void> { await booted;
|
|
207
|
+
async function settled(booted: OnlineShell['booted'], leaving: OnlineLeaving): Promise<void> { await booted; leaving.settle(); }
|
|
186
208
|
/** J174: the next build's files, while play goes on. The worker that installs is what the reload lands on. */
|
|
187
209
|
function preload(): void {
|
|
188
210
|
if ('serviceWorker' in navigator) void navigator.serviceWorker.getRegistration().then(found => found?.update()).catch(() => undefined);
|
|
@@ -210,6 +232,8 @@ export interface StartOnline {
|
|
|
210
232
|
* a second store writing the page's device save would drop the keys it doesn't define. */
|
|
211
233
|
readonly keep?: ReleaseKeep;
|
|
212
234
|
readonly recordTag?:string;
|
|
235
|
+
/** mode 23: how the page leaves on purpose, in its own saves (see OnlineLeaving) */
|
|
236
|
+
readonly leaving?: OnlineLeaving;
|
|
213
237
|
}
|
|
214
238
|
/** E7.5 prep: ask the page to leave for the Connection doctor, saying which screen asked. The page's own bundle answers
|
|
215
239
|
* (src/client/engine/ui/errorScreen.ts): it holds the save hold and the loading card's report, which this module can't see. */
|
|
@@ -294,17 +318,17 @@ async function askWorld(config: { readonly release: string; readonly key: string
|
|
|
294
318
|
/** Enter the one world this build names. A stale tab reloads into the server's build once, and only then gives up. */
|
|
295
319
|
export async function startOnline(config: StartOnline): Promise<OnlineShell> {
|
|
296
320
|
// OF4: a verified kept release file dials at once (offline too), and the fresh read follows; with none, the page waits for the read
|
|
297
|
-
const { release: at, key, keep, identity, recordTag, grid, ...link } = config;
|
|
321
|
+
const { release: at, key, keep, identity, recordTag, grid, leaving = OWN_LEAVING, ...link } = config;
|
|
298
322
|
// FM5: with no kept copy and no file, the page says why (offline, the file's server down or busy, a portal, a bad signature) and
|
|
299
323
|
// reads again by release.ts's policy until a verified file answers; Title screen stops the load
|
|
300
324
|
const waiting = new Scope('online.release-wait');
|
|
301
|
-
const toTitle = (): void => {
|
|
325
|
+
const toTitle = (): void => { leaving.unload('release page: title screen'); location.replace(new URL('/', location.origin).toString()); };
|
|
302
326
|
let dial: Awaited<ReturnType<typeof releaseToDial>>;
|
|
303
327
|
try { dial = await releaseToDial(at, key, { keep: keep ?? NO_KEEP, wait: releaseScreens(waiting, { doctor, title: toTitle }) }); } finally { waiting.dispose(); }
|
|
304
328
|
const { file: release, fresh } = dial, { socket } = release;
|
|
305
329
|
// QA row 16: a level page enters only from a tap. A reload this page makes itself carries the tap that brought it here.
|
|
306
|
-
const entering = (slug: string): void => {
|
|
307
|
-
const stale = async (): Promise<boolean> => { entering(link.loaded); const going = await reloadStale(); if (!going)
|
|
330
|
+
const entering = (slug: string): void => { leaving.arrive(slug); };
|
|
331
|
+
const stale = async (): Promise<boolean> => { entering(link.loaded); const going = await leaving.reloadStale(); if (!going) leaving.unarrive(); return going; };
|
|
308
332
|
// only a fresh read says the world moved on: a kept copy's build is the past, and an offline page can't reload anyway
|
|
309
333
|
if (fresh === null && release.engineBuild !== link.build) await stale();
|
|
310
334
|
if (socket === undefined) throw new Error('The release file names no address');
|
|
@@ -321,23 +345,23 @@ export async function startOnline(config: StartOnline): Promise<OnlineShell> {
|
|
|
321
345
|
const screens = linkScreens(scope, {
|
|
322
346
|
retry: () => { shellNow?.retry(); }, dialNow: () => { shellNow?.dialNow(); }, doctor,
|
|
323
347
|
// Play here / Play again reload into the world: the tap that brought the player here comes along (QA row 16)
|
|
324
|
-
reload: () => { entering(link.loaded); void reloadByHand(); },
|
|
348
|
+
reload: () => { entering(link.loaded); void leaving.reloadByHand(); },
|
|
325
349
|
progress: () => shellNow?.progress() ?? { dials: 0, nextDialMs: null, downMs: 0 }, why: () => shellNow?.why() ?? 'closed',
|
|
326
350
|
// FM4b modes 21 and 22: the Slow and Unstable chips read the link's own measurements
|
|
327
351
|
stats: () => shellNow?.client.stats,
|
|
328
352
|
});
|
|
329
353
|
// `reload` is the one ending a screen doesn't answer: the page reloads into the world's build, once (J174)
|
|
330
|
-
const ended = async (): Promise<void> => { if (!await stale()) newBuildPanel(scope, stale, () => { entering(link.loaded); void reloadByHand(); }); };
|
|
354
|
+
const ended = async (): Promise<void> => { if (!await stale()) newBuildPanel(scope, stale, () => { entering(link.loaded); void leaving.reloadByHand(); }); };
|
|
331
355
|
const telemetry=onlineTelemetry(),tag=recordTag??release.channel;
|
|
332
356
|
const shell = connectOnline({ ...link, ...(grid === undefined ? {} : { gridCell: grid.cell, gridCells: grid.cells }), socket: gotoSocket(socket, goto), address: () => gotoSocket(dialing, goto), identity: named,record:{install:telemetry.install,session:crypto.randomUUID(),send:telemetry.send,...(tag===undefined?{}:{tag})} }, {
|
|
333
357
|
link: (state, reason) => { waitingForSeat = state === 'full'; screens.link(state, reason); if (state === 'ended' && reason === 'reload') void ended(); },
|
|
334
358
|
// The cut (5.5): an old server refused a v1 hello. Reload only into another build; on this one, the server is updating.
|
|
335
|
-
cut: () => { void reloadStale(); },
|
|
359
|
+
cut: () => { void leaving.reloadStale(); },
|
|
336
360
|
countdown: said => { screens.countdown(said); preload(); },
|
|
337
361
|
placed: (cell, stand) => { if (stand !== undefined) grid?.placed(cell, stand); },
|
|
338
362
|
// A grid page re-enters the grid in the seat's cell: the tap that brought it here comes along (QA row 16), and the URL stays bare.
|
|
339
|
-
regrid: cell => { entering(link.loaded);
|
|
340
|
-
elsewhere: seat => { entering(seat); const url = new URL(location.href); url.searchParams.set('chunk', seat);
|
|
363
|
+
regrid: cell => { entering(link.loaded); leaving.unload(`online seat in another grid cell (${cell})`); grid?.reenter(cell); },
|
|
364
|
+
elsewhere: seat => { entering(seat); const url = new URL(location.href); url.searchParams.set('chunk', seat); leaving.unload(`online seat elsewhere (${seat})`); location.replace(url); },
|
|
341
365
|
});
|
|
342
366
|
shellNow = shell;
|
|
343
367
|
// the fresh read behind a kept copy: another build reloads into it, as a fresh read before the dial would (two reloads share one
|
|
@@ -351,7 +375,7 @@ export async function startOnline(config: StartOnline): Promise<OnlineShell> {
|
|
|
351
375
|
});
|
|
352
376
|
// a tap the world must hear waits for the link: the hold card says so, and the tap is never sent late
|
|
353
377
|
shell.client.gateActions(what => screens.allow(what));
|
|
354
|
-
void settled(shell.booted);
|
|
378
|
+
void settled(shell.booted, leaving);
|
|
355
379
|
const chat = chatLines(scope, shell.client, document.body, screens.holdChat);
|
|
356
380
|
voiceUi(scope, new VoiceChat(scope, shell.voice), chat);
|
|
357
381
|
scope.listen(window,'pagehide',()=>{shell.flushRecords();});
|
|
@@ -236,23 +236,26 @@ export interface GcReport {readonly kept: number; readonly deleted: number; read
|
|
|
236
236
|
export const PACK_BUDGET_BYTES = 4_000_000_000;
|
|
237
237
|
/** A part younger than this may belong to a cook that hasn't written its index yet. */
|
|
238
238
|
const GC_GRACE_MS = 3_600_000;
|
|
239
|
+
/** PAGE-SIZE PZ2's content sets (`content/<set>/…`, page-release content.mjs). They are content-named and name no build,
|
|
240
|
+
* so garbage collection never takes one; a set's own retention waits for a build-to-set record. */
|
|
241
|
+
const CONTENT_SETS = 'content/';
|
|
239
242
|
|
|
243
|
+
/** The cook's usage: `objects`, `bytes` and `share` count only its own keys, never the page's content sets (`CONTENT_SETS`),
|
|
244
|
+
* which it neither writes nor collects. From 2026-11-14 they filled the 4 GB budget alone (32.7 of 33.53 GB) and every
|
|
245
|
+
* job failed "Over the pack budget". `byPrefix` still lists every prefix, content sets included, so a report shows them. */
|
|
240
246
|
function usageOf(rows: readonly StoredObject[], budget: number): StoreUsage {
|
|
241
247
|
const byPrefix: Record<string, {count: number; bytes: number}> = {};
|
|
242
248
|
let objects = 0, bytes = 0;
|
|
243
249
|
for (const row of rows) {
|
|
244
250
|
const path = row.key.split('/'), name = path.slice(0, path.length > 3 ? 3 : Math.min(2, path.length - 1)).join('/'), kept = byPrefix[name] ?? {count: 0, bytes: 0};
|
|
245
|
-
kept.count++; kept.bytes += row.bytes; byPrefix[name] = kept;
|
|
251
|
+
kept.count++; kept.bytes += row.bytes; byPrefix[name] = kept;
|
|
252
|
+
if (!row.key.startsWith(CONTENT_SETS)) { objects++; bytes += row.bytes; }
|
|
246
253
|
}
|
|
247
254
|
return {objects, bytes, share: bytes / budget, byPrefix};
|
|
248
255
|
}
|
|
249
256
|
|
|
250
257
|
export async function storeUsage(store: PackStore, budget: number): Promise<StoreUsage> { return usageOf(await store.list(''), budget); }
|
|
251
258
|
|
|
252
|
-
/** PAGE-SIZE PZ2's content sets (`content/<set>/…`, page-release content.mjs). They are content-named and name no build,
|
|
253
|
-
* so garbage collection never takes one; a set's own retention waits for a build-to-set record. */
|
|
254
|
-
const CONTENT_SETS = 'content/';
|
|
255
|
-
|
|
256
259
|
/** J83: keep what a kept build's index names, and delete the rest, indexes of other builds included.
|
|
257
260
|
* PAGE-SIZE PZ5: a kept build's server book (`assets/spawn/server-<build>.json`, page-release packs.mjs) and every part it
|
|
258
261
|
* names are kept too, so a carried build's solo server still finds them; the content sets are never collected. */
|
|
@@ -252,14 +252,16 @@ export function ktx2GpuBytes(bytes: Uint8Array): number {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
/** S12b: the largest side a phone draws from one KTX2 table row, or undefined to keep the file as it is. The table's source
|
|
255
|
-
* key is the author's hint (D5): a `#layer` twin (a terrain layer, tiled at a texel a metre)
|
|
256
|
-
*
|
|
255
|
+
* key is the author's hint (D5): a `#layer` twin (a terrain layer, tiled at a texel a metre), a horizon strip and a painted
|
|
256
|
+
* sky panorama (a `panorama` file or a `sky/` folder: the whole sky, seen at screen size) are kept on purpose; every other
|
|
257
|
+
* row is 512 on a phone. The panorama was cut to 258 x 47 from its 4128 x 760 phone file and Nalati's sky drew as a blur
|
|
258
|
+
* (SHARD-REPOS SH-nalati-6, 2026-11-15). */
|
|
257
259
|
export const PHONE_TIER_MAX = 512;
|
|
258
260
|
/** S12d: the cap a kept row (a `#layer` twin, a horizon) is encoded under: none it reaches, so it keeps its own size and only
|
|
259
261
|
* its encoding changes to 6×6, as S4's hand-made set had it. */
|
|
260
262
|
export const KEPT_ENCODE_MAX = 16_384;
|
|
261
263
|
export function phoneTierSize(source: string): number | undefined {
|
|
262
|
-
return source.endsWith('#layer') || /\/horizon
|
|
264
|
+
return source.endsWith('#layer') || /\/(?:horizon|sky)\/|\/panorama[.-][^/]*$/u.test(source) ? undefined : PHONE_TIER_MAX;
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
/** One phone file the cook made: `from` is the table target it stands in for, `url` its own content-named URL. */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { NetCommand } from '@wildshard/wire/netCommand';
|
|
2
2
|
import type { AnimalPoseSample } from '../../../shared/engine/entities/AnimalSim';
|
|
3
3
|
import type { SimHost } from '../sim';
|
|
4
|
-
import { leadPlayer } from '../../../shared/engine/sim/leadPlayer';
|
|
5
4
|
import type { AnimalNetView } from '../../../shared/engine/net/animalNet';
|
|
6
5
|
import { actRoutes } from '../../../shared/engine/sim/actRoutes';
|
|
7
6
|
import { CombatWire, type CombatEvent } from './combatWire';
|
|
@@ -39,10 +38,10 @@ export class SimNetWorld implements NetWorld {
|
|
|
39
38
|
private readonly frame: number;
|
|
40
39
|
private readonly filings: (() => readonly LedgerFiling[]) | undefined;
|
|
41
40
|
private readonly turn = { still: new Set<string>(), extra: new Map<string, NetCommand>() };
|
|
42
|
-
/** `frame` names the cell this host's positions are local to; 0 is the highway, and any world that is not on a grid. `filings` reads the tick's grants, which the host's owner holds: the sim keeps none. */
|
|
43
|
-
constructor(host: SimHost, frame = 0, filings?: () => readonly LedgerFiling[]) {
|
|
41
|
+
/** `frame` names the cell this host's positions are local to; 0 is the highway, and any world that is not on a grid. `filings` reads the tick's grants, which the host's owner holds: the sim keeps none. `owner` selects the default network seat explicitly; legacy standalone callers use actor.player. */
|
|
42
|
+
constructor(host: SimHost, frame = 0, filings?: () => readonly LedgerFiling[], owner = 'actor.player') {
|
|
44
43
|
this.host = host; this.frame = frame; this.filings = filings; this.wire = new CombatWire(host); keepHitHistory(host);
|
|
45
|
-
this.player = this.playerOf(
|
|
44
|
+
this.player = this.playerOf(owner);
|
|
46
45
|
}
|
|
47
46
|
/** A player, as the client that owns it reads it. */
|
|
48
47
|
playerOf(id: string): NetPlayer {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Actor } from '@wildshard/engine/combat/pipeline';
|
|
2
|
+
import { gridZone } from '../../../shared/game/grid/rules';
|
|
3
|
+
import type { SimHost } from '@wildshard/engine/sim';
|
|
4
|
+
import type { AnimalSim } from '@wildshard/engine/entities/AnimalSim';
|
|
5
|
+
import { CELL_ABOVE, CELL_BELOW, CHUNK_HALF } from '@wildshard/engine/core/config';
|
|
6
|
+
import { gridCreatureConstraint, installGridBorders } from '@wildshard/engine/physics/gridBorders';
|
|
7
|
+
import { mountedPlayerOf } from '@wildshard/engine/game/riding/native';
|
|
8
|
+
import { CharacterMotor } from '@wildshard/engine/physics/CharacterMotor';
|
|
9
|
+
|
|
10
|
+
/** A late controller may already have moved a driven boss before its own body step.
|
|
11
|
+
* Start the physics query inside the home; this port has no hidden continuation. */
|
|
12
|
+
function bindHome(host: SimHost, actor: AnimalSim, mounted: readonly AnimalSim[]): void {
|
|
13
|
+
const previous = actor.motionConstraint, radius = actor.dims.bodyRadius * actor.scale, limit = Math.max(0, CHUNK_HALF - radius - .001);
|
|
14
|
+
const constrain = gridCreatureConstraint(() => host.physics, radius), start = { x: 0, y: 0, z: 0 };
|
|
15
|
+
actor.motionConstraint = (from, to) => {
|
|
16
|
+
previous?.(from, to);
|
|
17
|
+
if (mounted.includes(actor)) return;
|
|
18
|
+
start.x = Math.max(-limit, Math.min(limit, from.x)); start.z = Math.max(-limit, Math.min(limit, from.z));
|
|
19
|
+
start.y = Math.max(-CELL_BELOW + radius + .001, Math.min(CELL_ABOVE - radius - .001, from.y));
|
|
20
|
+
constrain(start, to);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** MP5.1: one cell's unmounted creatures stay home. Players and their mounted traveller remain free to cross. */
|
|
24
|
+
export function installCellHome(host: SimHost): void {
|
|
25
|
+
const bound = new WeakSet<AnimalSim>(), mounted: AnimalSim[] = [];
|
|
26
|
+
// Resolve the live object on every request: ids repeat between cells, and
|
|
27
|
+
// seats and creatures can join or leave after installation.
|
|
28
|
+
const interior = (actor: Actor): boolean => {
|
|
29
|
+
const player = host.players.get(actor.id);
|
|
30
|
+
if (player?.health === actor) return gridZone(player.position) === 'shard';
|
|
31
|
+
const creature = host.entities.get(actor.id);
|
|
32
|
+
return creature?.combatActor() === actor && gridZone(creature.position) === 'shard';
|
|
33
|
+
};
|
|
34
|
+
host.events.answer('damage.admit', request => request !== null && interior(request.target)
|
|
35
|
+
&& (request.source === 'env' || interior(request.source)) ? request : null, host.scope);
|
|
36
|
+
const sync = (): void => {
|
|
37
|
+
mounted.length = 0;
|
|
38
|
+
for (const player of host.players.values()) { const ride = mountedPlayerOf(host, player.id); if (ride?.mounted === true && ride.horse !== null) mounted.push(ride.horse); }
|
|
39
|
+
for (const actor of host.entities.values()) if (!bound.has(actor)) { bindHome(host, actor, mounted); bound.add(actor); }
|
|
40
|
+
};
|
|
41
|
+
// A dismount or a controller can put a capsule outside before its move.
|
|
42
|
+
// Rapier then keeps it on the wall's outside face; repair that invalid start
|
|
43
|
+
// after body resolution, while ordinary in-home movement needs no reset.
|
|
44
|
+
const repair = (): void => {
|
|
45
|
+
for (const actor of host.entities.values()) {
|
|
46
|
+
if (mounted.includes(actor)) continue;
|
|
47
|
+
const limit = Math.max(0, CHUNK_HALF - actor.dims.bodyRadius * actor.scale - .001);
|
|
48
|
+
const x = Math.max(-limit, Math.min(limit, actor.position.x)), z = Math.max(-limit, Math.min(limit, actor.position.z));
|
|
49
|
+
if (x === actor.position.x && z === actor.position.z) continue;
|
|
50
|
+
actor.position.x = x; actor.position.z = z;
|
|
51
|
+
if (actor.motor instanceof CharacterMotor) actor.motor.resetAt(actor.position);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
installGridBorders(host.physics, host.scope); sync(); repair();
|
|
55
|
+
host.onStep('grid.home', sync, { joined: true, snapshot: () => null, restore: value => { if (value !== null) throw new Error('Invalid cell home continuation'); },
|
|
56
|
+
physicsRestored: () => { installGridBorders(host.physics, host.scope); sync(); repair(); } });
|
|
57
|
+
host.onStep('grid.home.poses', repair, undefined, 'afterBodies');
|
|
58
|
+
}
|
|
@@ -4,12 +4,6 @@ import type { GridAssembly, GridPoint } from '../../../shared/game/grid/assembly
|
|
|
4
4
|
import { installGridCrossing, type GridCrossingSession } from '../../../shared/game/grid/crossing';
|
|
5
5
|
import type { GridSimulation } from './simulation';
|
|
6
6
|
import type { GridLoadout } from '../../../shared/game/grid/wallet';
|
|
7
|
-
import { CHUNK_HALF } from '@wildshard/engine/core/config';
|
|
8
|
-
|
|
9
|
-
/** How far from a cell's edge a player on the road has its world opened (the road between two cells is 62.5 m). */
|
|
10
|
-
const WARM_ROAD_METRES = 55;
|
|
11
|
-
/** The least a tick's move toward it counts as heading there (a walk is 0.07 m a tick); a capsule settling is not. */
|
|
12
|
-
const WARM_STEP_METRES = 0.02;
|
|
13
7
|
|
|
14
8
|
/** A player's completed hand-off: the `travel` a client's view follows (E5-REPLICATION §6.3.4). */
|
|
15
9
|
export interface GridTravel { readonly player: string; readonly from: string | null; readonly to: string | null }
|
|
@@ -28,12 +22,6 @@ export class GridRoom {
|
|
|
28
22
|
private readonly crossings = new Map<string, { readonly session: GridCrossingSession; readonly scope: Scope }>();
|
|
29
23
|
private readonly travels: GridTravel[] = [];
|
|
30
24
|
private readonly scope = new Scope('grid-room');
|
|
31
|
-
/** each player's last cell left for the road, and the cells opened ahead of them on this stretch of road (GC5): each at
|
|
32
|
-
* most once a stretch, so two players on the road never evict each other's cell tick after tick, and a failed open is not
|
|
33
|
-
* retried every tick (the crossing still prepares it at the line and reports a failure) */
|
|
34
|
-
private readonly departed = new Map<string, string>();
|
|
35
|
-
private readonly opened = new Map<string, Set<string>>();
|
|
36
|
-
private readonly feet = new Map<string, { x: number; z: number }>();
|
|
37
25
|
constructor(grid: GridSimulation, assembly: GridAssembly, ports: GridRoomPorts) {
|
|
38
26
|
this.grid = grid; this.assembly = assembly; this.ports = ports;
|
|
39
27
|
for (const player of grid.players()) this.watch(player);
|
|
@@ -42,7 +30,7 @@ export class GridRoom {
|
|
|
42
30
|
const { grid } = this, scope = this.scope.child(`crossing:${player}`);
|
|
43
31
|
const session = installGridCrossing({ current: () => grid.current(player), prepare: (from, to) => grid.prepare(from, to, player), ready: instance => grid.ready(instance),
|
|
44
32
|
checkpoint: instance => grid.checkpoint(instance), target: feet => grid.target(feet, player) }, this.assembly, instance => this.ports.loadout(player, instance), scope,
|
|
45
|
-
(from, to) => { this.travels.push({ player, from, to });
|
|
33
|
+
(from, to) => { this.travels.push({ player, from, to }); });
|
|
46
34
|
this.crossings.set(player, { session, scope });
|
|
47
35
|
}
|
|
48
36
|
/** Another player comes onto the highway at `at`, world coordinates, or into the world at `site`, in its own. */
|
|
@@ -51,40 +39,16 @@ export class GridRoom {
|
|
|
51
39
|
leave(player: string): boolean {
|
|
52
40
|
const crossing = this.crossings.get(player);
|
|
53
41
|
if (crossing === undefined || !this.grid.leave(player)) return false;
|
|
54
|
-
crossing.scope.dispose(); this.crossings.delete(player);
|
|
42
|
+
crossing.scope.dispose(); this.crossings.delete(player);
|
|
55
43
|
return true;
|
|
56
44
|
}
|
|
57
45
|
/** Everyone's own crossing, once per fixed tick, before any world steps. */
|
|
58
46
|
cross(): void {
|
|
59
47
|
for (const [player, { session }] of this.crossings) {
|
|
60
48
|
const feet = this.grid.worldFeet(player);
|
|
61
|
-
this.warm(player, feet);
|
|
62
49
|
session.step(feet);
|
|
63
50
|
}
|
|
64
51
|
}
|
|
65
|
-
/** GC5 (preview's in-page server, J311): a player on the road has the nearest cell ahead opened before they reach its line,
|
|
66
|
-
* as the page builds its own: opened only at the 6 m line, a cell's world held them at its wall for its whole load. The
|
|
67
|
-
* cell they left is not ahead. A failed open stays the crossing's to report. */
|
|
68
|
-
private warm(player: string, feet: Readonly<GridPoint>): void {
|
|
69
|
-
const previous = this.feet.get(player);
|
|
70
|
-
this.feet.set(player, { x: feet.x, z: feet.z });
|
|
71
|
-
if (this.grid.current(player) !== null) { this.opened.delete(player); return; }
|
|
72
|
-
if (previous === undefined) return;
|
|
73
|
-
const left = this.departed.get(player), edge = (p: Readonly<{ x: number; z: number }>, cell: { readonly origin: GridPoint }): number =>
|
|
74
|
-
Math.max(Math.abs(p.x - cell.origin.x), Math.abs(p.z - cell.origin.z)) - CHUNK_HALF;
|
|
75
|
-
let best: string | undefined, bestDistance = WARM_ROAD_METRES;
|
|
76
|
-
for (const cell of this.assembly.cells) {
|
|
77
|
-
// only a cell they draw nearer to: not one behind them, nor the one they left
|
|
78
|
-
const distance = edge(feet, cell);
|
|
79
|
-
if (cell.instance === left || distance > bestDistance || distance > edge(previous, cell) - WARM_STEP_METRES) continue;
|
|
80
|
-
best = cell.instance; bestDistance = distance;
|
|
81
|
-
}
|
|
82
|
-
if (best === undefined || this.grid.ready(best)) return;
|
|
83
|
-
const opened = this.opened.get(player) ?? new Set<string>();
|
|
84
|
-
if (opened.has(best)) return;
|
|
85
|
-
opened.add(best); this.opened.set(player, opened);
|
|
86
|
-
void this.grid.prefetch([best]).catch(() => undefined);
|
|
87
|
-
}
|
|
88
52
|
/** One fixed tick: everyone's own crossing, then every occupied world. */
|
|
89
53
|
step(commands?: ReadonlyMap<string, SimTickCommand>): void { this.cross(); this.grid.stepAll(commands); }
|
|
90
54
|
/** Every hand-off since the last call. */
|