@wildshard/engine 0.1.15 → 0.1.17
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 +15 -0
- package/index.html +157 -11
- package/lint/engine-sides.json +16 -0
- package/lint/host-register.json +496 -0
- package/lint/ratchet.json +2 -2
- package/lint/shard-imports.d.mts +1 -0
- package/lint/shard-imports.mjs +56 -8
- package/lint/wildshard-plugin.js +22 -4
- package/package.json +16 -5
- package/scripts/app-build/buildIdentity.d.mts +3 -1
- package/scripts/app-build/buildIdentity.mjs +25 -5
- package/scripts/app-build/builtAt.d.mts +4 -0
- package/scripts/app-build/builtAt.mjs +21 -0
- package/scripts/app-build/serviceWorker.ts +16 -2
- package/scripts/app-build/versionFiles.ts +2 -1
- package/scripts/app-build-pipeline.mjs +4 -1
- package/scripts/audio-download-proof.mjs +843 -0
- package/scripts/build-app.mjs +4 -0
- package/scripts/build-mirror.d.mts +2 -0
- package/scripts/build-mirror.mjs +5 -4
- package/scripts/built-product.mjs +3 -3
- package/scripts/cell-mem/metrics-preload.mjs +65 -0
- package/scripts/cell-mem-bench.mjs +130 -0
- package/scripts/check-chunks.mjs +2 -1
- package/scripts/devserver-client.d.mts +5 -0
- package/scripts/devserver-client.mjs +68 -0
- package/scripts/engine-ci-budget.ts +7 -1
- package/scripts/format-lock.mjs +20 -11
- package/scripts/generate-title-launch.mjs +3 -2
- package/scripts/grid-crossing-walk-proof.mjs +16 -8
- package/scripts/heavy-lane.py +25 -1
- package/scripts/host-ruler/register-migrate.mjs +242 -0
- package/scripts/host-ruler/register.d.mts +36 -0
- package/scripts/host-ruler/register.mjs +116 -0
- package/scripts/host-ruler/roots.d.mts +29 -0
- package/scripts/host-ruler/roots.mjs +333 -0
- package/scripts/host-ruler/server-roots.d.mts +23 -0
- package/scripts/host-ruler/server-roots.mjs +272 -0
- package/scripts/main-watch.d.mts +1 -1
- package/scripts/main-watch.mjs +10 -6
- package/scripts/map-hash.mjs +3 -6
- package/scripts/mmo-bots.mjs +2 -2
- package/scripts/offline-proof-rules.d.mts +1 -0
- package/scripts/offline-proof-rules.mjs +22 -1
- package/scripts/online-rig.mjs +4 -4
- package/scripts/page-release/flow.d.mts +1 -0
- package/scripts/page-release/flow.mjs +6 -2
- package/scripts/page-release.mjs +5 -1
- package/scripts/physics-route.json +0 -71
- package/scripts/pins-catalogue.ts +103 -0
- package/scripts/pins-reuse.mjs +3 -1
- package/scripts/pins.ts +22 -14
- package/scripts/preview-grid.ts +203 -0
- package/scripts/road-preload-proof.mjs +167 -0
- package/scripts/server-release/publish.mjs +2 -2
- package/scripts/server-release/served-slug.d.mts +2 -0
- package/scripts/server-release/served-slug.mjs +10 -0
- package/scripts/server-release/sign.d.mts +1 -0
- package/scripts/server-release/sign.mjs +3 -7
- package/scripts/shard-components.mjs +0 -2
- package/scripts/shard-outputs.d.mts +8 -0
- package/scripts/shard-outputs.mjs +45 -11
- package/scripts/side-parity.d.mts +2 -1
- package/scripts/side-parity.mjs +25 -4
- package/scripts/test-amber.d.mts +1 -0
- package/scripts/test-amber.mjs +10 -0
- package/scripts/test-products.json +3 -3
- package/scripts/tracked-public.d.mts +1 -0
- package/scripts/tracked-public.mjs +17 -0
- package/src/cli/engine.mjs +8 -0
- package/src/client/app/bootRoute.ts +4 -1
- package/src/client/app/dropModal.ts +15 -2
- package/src/client/app/entry.ts +67 -11
- package/src/client/app/slugPath.ts +5 -0
- package/src/client/engine/audio/Audio.ts +20 -2
- package/src/client/engine/boot/bakedTextures.ts +3 -2
- package/src/client/engine/boot/bootTrace.ts +6 -1
- package/src/client/engine/boot/bytes.ts +4 -3
- package/src/client/engine/boot/clearDownloads.ts +1 -1
- package/src/client/engine/boot/contentRead.ts +4 -0
- package/src/client/engine/boot/dropNotice.ts +20 -6
- package/src/client/engine/boot/gpuFiles.ts +25 -2
- package/src/client/engine/boot/lastEnd.ts +8 -2
- package/src/client/engine/boot/shardPrefetch.ts +7 -1
- package/src/client/engine/boot/sw.ts +19 -0
- package/src/client/engine/core/Game.ts +11 -3
- package/src/client/engine/core/GpuRecovery.ts +7 -0
- package/src/client/engine/core/Volumetrics.ts +5 -0
- package/src/client/engine/core/assets.ts +27 -20
- package/src/client/engine/core/bootstrap.ts +1 -2
- package/src/client/engine/core/ktx2.ts +84 -11
- package/src/client/engine/explore/Compare.ts +2 -2
- package/src/client/engine/explore/TouchFly.ts +3 -5
- package/src/client/engine/input/dom.ts +12 -0
- package/src/client/engine/net/predictor.ts +6 -2
- package/src/client/engine/player/Player.ts +10 -2
- package/src/client/engine/player/TouchControls.ts +12 -4
- package/src/client/engine/pwa/sw.js +47 -8
- package/src/client/engine/render/drawCheck.ts +96 -0
- package/src/client/engine/saves/staleBuildNote.ts +46 -0
- package/src/client/engine/telemetry/browserErrors.ts +157 -20
- package/src/client/engine/telemetry/screenOutbox.ts +61 -0
- package/src/client/engine/telemetry/staleBuildReport.ts +12 -0
- package/src/client/engine/ui/DeathFade.ts +99 -11
- package/src/client/engine/ui/ErrorModal.ts +13 -6
- package/src/client/engine/ui/Feedback.ts +2 -1
- package/src/client/engine/ui/Loading.ts +10 -6
- package/src/client/engine/ui/Map.ts +2 -1
- package/src/client/engine/ui/WeaponStrip.ts +2 -1
- package/src/client/engine/ui/backGuard.ts +104 -0
- package/src/client/engine/ui/hudAdapters.ts +30 -4
- package/src/client/engine/ui/loading.css +17 -0
- package/src/client/engine/ui/namePrompt.ts +6 -5
- package/src/client/engine/ui/styles/combat.css +12 -0
- package/src/client/engine/ui/styles/namePrompt.css +4 -2
- package/src/client/game/boot/audio.generated.ts +0 -294
- package/src/client/game/boot/bytes.generated.ts +0 -11
- package/src/client/game/boot/versions.generated.ts +0 -11
- package/src/client/game/compendium/keepsakes.ts +16 -6
- package/src/client/game/grapple/tool.ts +10 -7
- package/src/client/game/grid/cellLoading.ts +23 -12
- package/src/client/game/grid/cellScreens.ts +39 -74
- package/src/client/game/grid/liveSession.ts +40 -7
- package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
- package/src/client/game/grid/nearPlaceholderView.ts +9 -3
- package/src/client/game/grid/oneWayIn.ts +92 -27
- package/src/client/game/grid/pageEntry.ts +19 -0
- package/src/client/game/grid/pageShell.ts +1 -1
- package/src/client/game/grid/plotAudio.ts +114 -0
- package/src/client/game/grid/products.ts +55 -5
- package/src/client/game/grid/roadLookPlatform.ts +2 -2
- package/src/client/game/grid/session.ts +38 -22
- package/src/client/game/grid/spawnGround.ts +68 -0
- package/src/client/game/grid/voidLook.ts +29 -23
- package/src/client/game/loot/runtime.ts +3 -1
- package/src/client/game/mainMenu.ts +14 -6
- package/src/client/game/riding/hud.ts +6 -4
- package/src/client/game/session/finish.ts +17 -3
- package/src/client/game/session/play.ts +8 -2
- package/src/client/game/session/session.ts +4 -1
- package/src/client/game/shardfile/clientWorker.ts +41 -12
- package/src/client/game/shardfile/serverRoute.ts +10 -22
- package/src/client/game/slugPage.css +11 -0
- package/src/client/game/slugPage.ts +84 -0
- package/src/client/game/systems/viewmodel/heldView.ts +6 -3
- package/src/client/game/titleDeck.ts +55 -32
- package/src/client/host/online/doctor.ts +7 -6
- package/src/client/host/online/linkScreens.ts +16 -0
- package/src/client/host/online/release.ts +51 -5
- package/src/client/host/online/shell.ts +48 -27
- package/src/client/host/standalone/shell.ts +7 -3
- package/src/cook/game/audioReport.ts +57 -0
- package/src/cook/game/entryTotals.ts +26 -6
- package/src/cook/game/installedRuntimeReads.ts +3 -0
- package/src/server/engine/sim/respawn.ts +6 -1
- package/src/server/engine/sim.ts +3 -0
- package/src/server/game/grid/simulation.ts +35 -0
- package/src/server/game/loot/harvest.ts +2 -0
- package/src/server/game/loot/keepsakeProgression.ts +40 -0
- package/src/server/game/loot/playerOwned.ts +5 -1
- package/src/server/game/plugin/simulation.ts +4 -0
- package/src/server/game/population/nativeBake.ts +2 -1
- package/src/server/game/quest/chapterRecords.ts +2 -0
- package/src/server/game/quest/serverChapters.ts +4 -0
- package/src/server/game/quest/serverDoors.ts +11 -5
- package/src/server/game/roomRespawn.ts +4 -0
- package/src/server/game/shardfile/installedSides.ts +18 -0
- package/src/server/game/shardfile/nativeAssemblyHosts.ts +19 -10
- package/src/server/game/shardfile/nativeAssemblyInput.ts +1 -4
- package/src/server/host/bake/headlessWorker.ts +5 -1
- package/src/server/host/dedicated/cellHost.ts +98 -29
- package/src/server/host/dedicated/cellProtocol.ts +11 -1
- package/src/server/host/dedicated/cellWorker.ts +9 -3
- package/src/server/host/dedicated/crossing.ts +6 -2
- package/src/server/host/dedicated/dedicatedRoom.ts +21 -8
- package/src/server/host/dedicated/gridCells.ts +52 -9
- package/src/server/host/dedicated/main.ts +31 -12
- package/src/server/host/dedicated/placementFile.ts +72 -0
- package/src/server/host/dedicated/releaseFile.ts +17 -10
- package/src/server/host/dedicated/roadRoom.ts +21 -5
- package/src/server/host/dedicated/workerTable.ts +13 -1
- package/src/server/host/dedicated/world.ts +81 -9
- package/src/server/host/headlessRuntime.ts +10 -5
- package/src/server/host/installers.ts +62 -0
- package/src/server/host/openWorld.ts +59 -0
- package/src/server/host/ropeDecks.ts +2 -0
- package/src/server/host/standalone/cellWorld.ts +25 -19
- package/src/server/host/standalone/fallFloor.ts +2 -2
- package/src/server/host/standalone/gridServer.ts +7 -4
- package/src/server/host/standalone/roadWorld.ts +41 -4
- package/src/shared/engine/audio/bootAudio.ts +33 -0
- package/src/shared/engine/level/spec.ts +3 -3
- package/src/shared/engine/net/acts.ts +3 -0
- package/src/shared/engine/physics/query.ts +27 -0
- package/src/shared/engine/physics/terrain.ts +19 -28
- package/src/shared/engine/saves/saves.lock.json +15 -0
- package/src/shared/engine/sim/actRoutes.ts +2 -0
- package/src/shared/game/compendium/keepsakeProgression.ts +24 -0
- package/src/shared/game/grid/catalogue.ts +12 -5
- package/src/shared/game/grid/catalogueSlot.ts +11 -0
- package/src/shared/game/grid/farProxy.ts +6 -5
- package/src/shared/game/grid/pageMode.ts +1 -1
- package/src/shared/game/grid/roadLayout.ts +26 -3
- package/src/shared/game/grid/singleplayer.json +0 -13
- package/src/shared/game/grid/voidFloor.ts +122 -0
- package/src/shared/game/strings.ts +15 -0
- package/src/shared/host/standalone/netInput.ts +2 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// AUDIO AU6 (J303, J295): the cook's audio report. One row per shard and tier from its cooked client manifest: the
|
|
2
|
+
// recordings DOWNLOAD fetches (the shard's own and the engine's shared files alike, AU1's list), their MB on the wire and
|
|
3
|
+
// their share of DOWNLOAD, judged against Jake's lines: green to 6 MB, amber over 6, red over 10 (J303). The report never
|
|
4
|
+
// fails a build or main: an overrun is an AMBER line that CI's budget reporter annotates and main-watch receipts (J295).
|
|
5
|
+
|
|
6
|
+
/** A recording a spawn manifest lists (AU1): engine music and sound effects and a shard's own audio mounts. */
|
|
7
|
+
const AUDIO_URL = /^\/assets\/(?:music|sfx)\/[^?]+\.(?:m4a|mp3|ogg|opus|wav|webm|flac)(?:\?|$)/u;
|
|
8
|
+
export const isAudioUrl = (url: string): boolean => AUDIO_URL.test(url);
|
|
9
|
+
|
|
10
|
+
/** J303 (Jake, 2026-11-12): "each shard can have 10 megabytes of audio. Red over 10. Green up to 6. Amber between 6 and 10". */
|
|
11
|
+
export const AUDIO_LINES: Readonly<{greenBytes: number; redBytes: number}> = Object.freeze({ greenBytes: 6_000_000, redBytes: 10_000_000 });
|
|
12
|
+
|
|
13
|
+
export type AudioLevel = 'green' | 'amber' | 'red';
|
|
14
|
+
export interface AudioReportRow {
|
|
15
|
+
readonly shard: string; readonly tier: 'phone' | 'desktop';
|
|
16
|
+
/** Recordings in the manifest, and their bytes on the wire. */
|
|
17
|
+
readonly files: number; readonly audioBytes: number;
|
|
18
|
+
/** The manifest's whole DOWNLOAD on the wire. */
|
|
19
|
+
readonly downloadBytes: number;
|
|
20
|
+
readonly level: AudioLevel;
|
|
21
|
+
}
|
|
22
|
+
/** What the report reads of a cooked client manifest. */
|
|
23
|
+
export interface AudioReportManifest {
|
|
24
|
+
readonly shard: string; readonly tier: 'phone' | 'desktop';
|
|
25
|
+
readonly files: readonly {readonly url: string; readonly bytes: number; readonly wireBytes?: number}[];
|
|
26
|
+
readonly wireBytes?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const audioLevel = (bytes: number, lines: Readonly<{greenBytes: number; redBytes: number}> = AUDIO_LINES): AudioLevel =>
|
|
30
|
+
bytes > lines.redBytes ? 'red' : bytes > lines.greenBytes ? 'amber' : 'green';
|
|
31
|
+
|
|
32
|
+
/** One row per manifest, sorted by shard then tier (phone first). Pure. */
|
|
33
|
+
export function audioReport(manifests: readonly AudioReportManifest[]): AudioReportRow[] {
|
|
34
|
+
const wire = (row: {readonly bytes: number; readonly wireBytes?: number}): number => row.wireBytes ?? row.bytes;
|
|
35
|
+
return manifests.map(manifest => {
|
|
36
|
+
const audio = manifest.files.filter(row => isAudioUrl(row.url)), audioBytes = audio.reduce((sum, row) => sum + wire(row), 0);
|
|
37
|
+
const downloadBytes = manifest.wireBytes ?? manifest.files.reduce((sum, row) => sum + wire(row), 0);
|
|
38
|
+
return {shard: manifest.shard, tier: manifest.tier, files: audio.length, audioBytes, downloadBytes, level: audioLevel(audioBytes)};
|
|
39
|
+
}).sort((a, b) => (a.shard < b.shard ? -1 : a.shard > b.shard ? 1 : 0) || (a.tier === b.tier ? 0 : a.tier === 'phone' ? -1 : 1));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const mb = (bytes: number): string => (bytes / 1e6).toFixed(2);
|
|
43
|
+
|
|
44
|
+
/** The cook's table, one line per row, with the lines it is judged by. */
|
|
45
|
+
export function audioReportTable(rows: readonly AudioReportRow[]): string {
|
|
46
|
+
const head = `cook audio (AU6, J303: green to ${mb(AUDIO_LINES.greenBytes)} MB, amber over it, red over ${mb(AUDIO_LINES.redBytes)} MB; an overrun is AMBER, never a red build or main)`;
|
|
47
|
+
const width = Math.max(5, ...rows.map(row => row.shard.length));
|
|
48
|
+
const line = (cells: readonly string[]): string => [cells[0]?.padEnd(width), cells[1]?.padEnd(7), ...cells.slice(2, 6).map(cell => cell.padStart(11)), ` ${cells[6] ?? ''}`].join(' ');
|
|
49
|
+
return [head, line(['shard', 'tier', 'files', 'audio MB', 'DOWNLOAD MB', 'share', 'line']),
|
|
50
|
+
...rows.map(row => line([row.shard, row.tier, String(row.files), mb(row.audioBytes), mb(row.downloadBytes),
|
|
51
|
+
`${row.downloadBytes === 0 ? '0' : (100 * row.audioBytes / row.downloadBytes).toFixed(0)}%`, row.level === 'green' ? 'green' : row.level.toUpperCase()]))].join('\n');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The machine line for a row over the green line, which CI annotates and main-watch reads (`parseAudioAmber` in
|
|
55
|
+
* scripts/test-amber.mjs). A row over the red line is still AMBER here (J295): `level=red` only says how far. */
|
|
56
|
+
export const audioAmberLine = (row: AudioReportRow): string =>
|
|
57
|
+
`AMBER audio shard=${row.shard} tier=${row.tier} bytes=${row.audioBytes} budget=${AUDIO_LINES.greenBytes} red=${AUDIO_LINES.redBytes} level=${row.level}`;
|
|
@@ -18,9 +18,10 @@ import {contentNamed} from './contentNamed';
|
|
|
18
18
|
import {homedir} from 'node:os';
|
|
19
19
|
import {productTarball} from './productTarball';
|
|
20
20
|
import {BrotliSizeCache} from './brotliSizeCache.mjs';
|
|
21
|
-
import {defaultBootAudio} from '@wildshard/engine/audio/bootAudio';
|
|
21
|
+
import {defaultBootAudio, ENGINE_MUSIC_STYLE, missingEngineMusic, musicDir} from '@wildshard/engine/audio/bootAudio';
|
|
22
22
|
import {withAssetTables, type AssetTables} from '@wildshard/engine/boot/tables';
|
|
23
23
|
import type {AudioData} from '@wildshard/format/audio';
|
|
24
|
+
import {audioReport, audioReportTable, isAudioUrl} from './audioReport';
|
|
24
25
|
|
|
25
26
|
const size = v.pipe(v.number(), v.safeInteger(), v.minValue(0));
|
|
26
27
|
const files = v.array(v.tuple([v.string(), size]));
|
|
@@ -30,7 +31,6 @@ const schema = v.object({common: files, client: files, grid: files,
|
|
|
30
31
|
extras: v.record(v.string(), v.tuple([v.string(), size, size, v.string()])),
|
|
31
32
|
});
|
|
32
33
|
interface Address {readonly url: string; readonly bytes: number}
|
|
33
|
-
const AUDIO_URL = /^\/assets\/(?:music|sfx)\/[^?]+\.(?:m4a|mp3|ogg|opus|wav|webm|flac)(?:\?|$)/u;
|
|
34
34
|
/** AUDIO AU1 (J299): the recordings a shard's LOAD reads, so DOWNLOAD fetches, counts and caches them: a new player's
|
|
35
35
|
* boot set (the default music style and sound-effect set, through the client's own selection) and the audio its
|
|
36
36
|
* recorded fence names. `tables` is the build's common boot table, the one the page installs. */
|
|
@@ -38,16 +38,29 @@ export function shardBootAudio(sections: ReadonlyMap<string, unknown>, tables: A
|
|
|
38
38
|
const row = sections.get('audio/audio'), data = typeof row === 'object' && row !== null && 'audio' in row ? row.audio as AudioData : undefined;
|
|
39
39
|
// A level with no music or sample rows boots with no recordings (NO_AUDIO); anything else must select, as on the page.
|
|
40
40
|
let boot: readonly string[] = [];
|
|
41
|
+
// AU18 (J304): the rows name the engine music they play; a name this build's style lacks fails the cook, never drops.
|
|
42
|
+
const music = data?.music, missing = music === undefined ? [] : withAssetTables(tables, () => missingEngineMusic(music));
|
|
43
|
+
if (missing.length > 0) throw new Error(`${shard}: its audio rows name engine music the ${ENGINE_MUSIC_STYLE} style lacks: ${missing.join(', ')}`);
|
|
41
44
|
if (data !== undefined && data.music !== undefined && data.samples !== undefined) {
|
|
42
45
|
try { boot = withAssetTables(tables, () => defaultBootAudio(data)); }
|
|
43
46
|
catch (error) { throw new Error(`${shard}: its boot audio does not select (${error instanceof Error ? error.message : String(error)})`, {cause: error}); }
|
|
44
47
|
}
|
|
45
48
|
const shipped = (url: string): boolean => Object.hasOwn(tables.bytes, url.split('?')[0] ?? url);
|
|
46
|
-
return [...new Set([...boot, ...fenceMounts.filter(url =>
|
|
49
|
+
return [...new Set([...boot, ...fenceMounts.filter(url => isAudioUrl(url)).map(url => url.split('?')[0] ?? url)])].filter(shipped);
|
|
50
|
+
}
|
|
51
|
+
/** AU18: the build log's line for a shard's derived engine music (its boot set's files under the engine style). */
|
|
52
|
+
export function engineMusicLine(shard: string, bootAudio: readonly string[], tables: AssetTables): string {
|
|
53
|
+
const dir = musicDir(ENGINE_MUSIC_STYLE), music = bootAudio.filter(url => url.startsWith(dir));
|
|
54
|
+
const bytes = music.reduce((sum, url) => sum + (tables.bytes[url] ?? 0), 0);
|
|
55
|
+
return `${shard}: engine music: ${music.length} files, ${(bytes / 1e6).toFixed(2)} MB${music.length === 0 ? '' : ` (${music.map(url => url.slice(dir.length)).join(', ')})`}`;
|
|
47
56
|
}
|
|
48
57
|
/** What a build's half of the manifests needs from the app: the page's own tables and names, which no cook owns. */
|
|
49
58
|
export interface BuildHalf {
|
|
50
59
|
readonly preparationOnly?: boolean;
|
|
60
|
+
/** AUDIO AU19: write each manifest's file list alone: no part or server pack is cooked, and a row's wire size is its
|
|
61
|
+
* raw size. The lists are the build's own (the rows don't depend on packing); a test reads them without the
|
|
62
|
+
* minutes the parts' q11 encode takes over every product. Tests only: a build never sets it. */
|
|
63
|
+
readonly filesOnly?: boolean;
|
|
51
64
|
readonly rendererRevision?: string;
|
|
52
65
|
readonly cacheName: string;
|
|
53
66
|
readonly gpuFiles: Parameters<typeof standInRefs>[0];
|
|
@@ -104,6 +117,7 @@ export async function writeSpawnManifests(outDir: string, input: unknown,
|
|
|
104
117
|
const precompressed = new BrotliSizeCache(process.env['WILDSHARD_WIRE_SIZE_CACHE'] ?? resolve(homedir(), '.cache/wildshard/gen/served-bytes/1'), 'precompressed');
|
|
105
118
|
const wireSizes = new Map<string, number>();
|
|
106
119
|
const wireBytes = (url: string, bytes: Uint8Array, hash: string): number => {
|
|
120
|
+
if (build.filesOnly === true) return bytes.length;
|
|
107
121
|
const key = `${hash}:${url}`, previous = wireSizes.get(key); if (previous !== undefined) return previous;
|
|
108
122
|
// Match the deployed/preview representation; Rapier retains its precompressed native body.
|
|
109
123
|
const length = servedAsIs(url, bytes) ? bytes.length
|
|
@@ -208,8 +222,10 @@ export async function writeSpawnManifests(outDir: string, input: unknown,
|
|
|
208
222
|
if (half.shard.preparation === 'stale') console.warn(stalePreparationLine(directory));
|
|
209
223
|
const shardRows = {phone: {entry: half.productRows('phone', 'entry'), whole: half.productRows('phone', 'whole')},
|
|
210
224
|
desktop: {entry: half.productRows('desktop', 'entry'), whole: half.productRows('desktop', 'whole')}};
|
|
211
|
-
|
|
212
|
-
|
|
225
|
+
if (build.filesOnly !== true) {
|
|
226
|
+
for (const [url, member] of await cookParts(output, half, [{tier: 'phone', rows: shardRows.phone.whole}, {tier: 'desktop', rows: shardRows.desktop.whole}], encoder)) cooked.set(url, member);
|
|
227
|
+
serverPacks[directory] = await cookShardServerPack(half.shard, output, encoder);
|
|
228
|
+
}
|
|
213
229
|
for (const table of [shardRows.phone, shardRows.desktop]) for (const row of [...table.entry, ...table.whole]) {
|
|
214
230
|
const stable = half.stableKey(row.url); if (stable !== undefined) stableKeys.set(row.url, stable);
|
|
215
231
|
}
|
|
@@ -242,6 +258,7 @@ export async function writeSpawnManifests(outDir: string, input: unknown,
|
|
|
242
258
|
}
|
|
243
259
|
// AUDIO AU1: the same recordings on every tier and flow: LOAD reads them before control on all of them.
|
|
244
260
|
const bootAudio = assetTables === undefined ? [] : shardBootAudio(sections, assetTables, half.mountRows('phone', 'entry').map(row => row.url), directory);
|
|
261
|
+
if (assetTables !== undefined && sections.has('audio/audio')) console.info(engineMusicLine(directory, bootAudio, assetTables));
|
|
245
262
|
const write = (tier: 'phone' | 'desktop', flow: 'client' | 'grid', addresses: readonly Address[] = [], mode = '000', whole = false): number => {
|
|
246
263
|
const selected = new Map<string, SpawnFile>(), add = (row: SpawnFile): void => {selected.set(row.url, row);};
|
|
247
264
|
for (const row of shardRows[tier][whole ? 'whole' : 'entry']) add(row);
|
|
@@ -296,10 +313,13 @@ export async function writeSpawnManifests(outDir: string, input: unknown,
|
|
|
296
313
|
(packsGridAt[mode] ??= {})[directory] = {phone: write('phone', 'grid', homes[directory], mode, true), desktop: write('desktop', 'grid', homes[directory], mode, true)};
|
|
297
314
|
}
|
|
298
315
|
}
|
|
316
|
+
// AU6 (J303): each shard's recordings and their share of its client DOWNLOAD, per tier; an overrun says AMBER, never fails.
|
|
317
|
+
const entries = pending.filter(row => !row.packed && row.manifest.flow === 'client').map(row => row.manifest);
|
|
318
|
+
if (entries.some(manifest => manifest.files.some(row => isAudioUrl(row.url)))) console.info(audioReportTable(audioReport(entries)));
|
|
299
319
|
if (Object.keys(preparations).length > 0) console.info(`cook preparation: ${(['current', 'stale', 'none'] as const).map(state => `${preparations[state]?.length ?? 0} ${state}`).join(', ')}`);
|
|
300
320
|
// DL5: every manifest is known, so pack their files into shared parts, then write each manifest with its own table.
|
|
301
321
|
const packed = pending.flatMap((row, index) => row.packed ? [index] : []);
|
|
302
|
-
const packedTables = await writeSpawnParts(output, packed.map(index => ({rows: pending[index]?.manifest.files ?? [], public: pending[index]?.public === true, desktop: pending[index]?.manifest.tier === 'desktop'})), url => {
|
|
322
|
+
const packedTables = build.filesOnly === true ? [] : await writeSpawnParts(output, packed.map(index => ({rows: pending[index]?.manifest.files ?? [], public: pending[index]?.public === true, desktop: pending[index]?.manifest.tier === 'desktop'})), url => {
|
|
303
323
|
const read = sources.get(url); if (read === undefined) throw new Error(`Spawn file has no source: ${url}`); return read();
|
|
304
324
|
}, url => stableKeys.get(url), encoder, cooked);
|
|
305
325
|
// DL15: each part's q11 body is written before the manifests, so every part row carries its exact wire size.
|
|
@@ -36,6 +36,9 @@ export function installedRuntimeReads(launcher:object,root:string):readonly stri
|
|
|
36
36
|
const optional=new Set(Object.keys(manifest.optionalDependencies??{}));
|
|
37
37
|
const names=new Set([...Object.keys(manifest.dependencies??{}),...optional,...Object.keys(manifest.peerDependencies??{})]);
|
|
38
38
|
for(const name of names){
|
|
39
|
+
// NP6: a type package (engine's optional `@types/three` peer) is never loaded at run time, and its own
|
|
40
|
+
// dependencies may be overridden away (`@types/three>@dimforge/rapier3d-compat`): not part of the closure.
|
|
41
|
+
if(name.startsWith('@types/'))continue;
|
|
39
42
|
const target=installed(name,directory);
|
|
40
43
|
if(target!==undefined){
|
|
41
44
|
pending.push(target.directory);
|
|
@@ -2,7 +2,7 @@ import { LastPlace, type Feet, type LastPlaceSaved, type PlaceArea, type Stand }
|
|
|
2
2
|
import type { PlayerHealth } from '../../../shared/engine/combat/health';
|
|
3
3
|
|
|
4
4
|
/** The page's death fade (ui/DeathFade: dark, then the fade back): no blow lands on the fallen until then. */
|
|
5
|
-
export const FALL_FADE = 1.
|
|
5
|
+
export const FALL_FADE = 1.35;
|
|
6
6
|
/** One player's record. A save holds a player only once they have one. */
|
|
7
7
|
export type RespawnRow = readonly [id: string, last: LastPlaceSaved, fade: number, falls: number];
|
|
8
8
|
|
|
@@ -35,6 +35,11 @@ export class RespawnBook {
|
|
|
35
35
|
falls(id: string): number { return this.seats.get(id)?.falls ?? 0; }
|
|
36
36
|
/** True while `id`'s return is still fading in. */
|
|
37
37
|
fading(id: string): boolean { return (this.seats.get(id)?.fade ?? 0) > 0; }
|
|
38
|
+
/** Respawn now (QA 11-13): `id`'s fade ends at once, so their commands move them again. Nothing else changes. */
|
|
39
|
+
skipFade(id: string): void {
|
|
40
|
+
const seat = this.seats.get(id);
|
|
41
|
+
if (seat !== undefined) seat.fade = 0;
|
|
42
|
+
}
|
|
38
43
|
/** Count a fall and start the fade its owner's health reads. */
|
|
39
44
|
fell(id: string, health: PlayerHealth): void {
|
|
40
45
|
const seat = this.seat(id);
|
package/src/server/engine/sim.ts
CHANGED
|
@@ -538,6 +538,9 @@ export class SimHost {
|
|
|
538
538
|
}
|
|
539
539
|
/** Preflight a fixed-step registration without installing a callback or consuming any simulation state. */
|
|
540
540
|
hasStep(id: string): boolean { return this.callbacks.has(id) || this.afterCallbacks.has(id); }
|
|
541
|
+
/** SERVER-PARITY HS1: every fixed-step owner, in registration order (before bodies, then after), so two hosts built from one
|
|
542
|
+
* product can be compared owner for owner. */
|
|
543
|
+
stepIds(): readonly string[] { return [...this.callbacks.keys(), ...this.afterCallbacks.keys()]; }
|
|
541
544
|
/** Scoped fixed-step work before bodies by default; afterBodies matches equipment following creature contact.
|
|
542
545
|
* Removing a registration releases its future snapshot adapter. Registration order remains snapshot order. */
|
|
543
546
|
onStep(id: string, run: (dt: number, host: SimHost) => void, adapter?: SimStateAdapter, phase: 'beforeBodies' | 'afterBodies' = 'beforeBodies'): () => void {
|
|
@@ -4,6 +4,8 @@ import { CharacterMotor } from '@wildshard/engine/physics/CharacterMotor';
|
|
|
4
4
|
import { snapshotSimHost, type SimSnapshot } from '@wildshard/engine/sim/snapshot';
|
|
5
5
|
import { prepareFrameMotors, type FrameMember } from '@wildshard/engine/physics/frame';
|
|
6
6
|
import { CHUNK_HALF } from '@wildshard/engine/core/config';
|
|
7
|
+
import { entrywayStands } from '@wildshard/engine/physics/query';
|
|
8
|
+
import { mountedPlayerOf } from '@wildshard/engine/game/riding/native';
|
|
7
9
|
import type { GridAssembly, GridCell, GridPoint } from '../../../shared/game/grid/assembly';
|
|
8
10
|
import type { ResidencyAllocator } from '../../../shared/game/grid/allocator';
|
|
9
11
|
import { GridContinuationCache, GRID_CONTINUATION_CACHE_BYTES } from '../../../shared/game/grid/continuations';
|
|
@@ -44,6 +46,18 @@ export interface PreparedGridFrame { commit: () => void; cancel: () => void }
|
|
|
44
46
|
export interface PreparedGridUnload { commit: () => void; abort: () => void }
|
|
45
47
|
interface Resident { value: GridResident; touched: number; reservations: number; retained: boolean; evicting: boolean; lease: GridSimLease | undefined }
|
|
46
48
|
|
|
49
|
+
/** GRID-CROSSING GC34, ROAD-PRELOAD RP4: a crossing hands the walker to the destination's seat with the speed and the mode (foot,
|
|
50
|
+
* board, swim) they had, so a walk across the line never stops (it started from rest: RP1's ~0.3 s stop at x -260 while the page
|
|
51
|
+
* caught it up), and an owner's seat parked in that cell never mixes the new speed with the mode it was left in. The dedicated server's
|
|
52
|
+
* handover (`CrossTarget.admit`) carries the same. */
|
|
53
|
+
export function carryMotion(from: PlayerSim, to: PlayerSim): void {
|
|
54
|
+
if (to.board.on !== from.board.on) to.setBoard(from.board.on);
|
|
55
|
+
to.board.hoverAir = from.board.hoverAir; to.board.hoverBob = from.board.hoverBob;
|
|
56
|
+
Object.assign(to.swim, from.swim); Object.assign(to.footing, from.footing); to.moveScale = from.moveScale;
|
|
57
|
+
to.velocity.copy(from.velocity); to.impulse.copy(from.impulse); to.fall.grounded = from.fall.grounded;
|
|
58
|
+
Object.assign(to.shove, from.shove); Object.assign(to.dash, from.dash); Object.assign(to.dodge, from.dodge); Object.assign(to.jump, from.jump);
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
/**
|
|
48
62
|
* Independent local physics worlds; only a world with a player in it advances, while visible neighbours remain frozen.
|
|
49
63
|
* Each player crosses on their own (P1-E3.9). `owner` is the player this session was built around, the lead of every host:
|
|
@@ -262,6 +276,8 @@ export class GridSimulation {
|
|
|
262
276
|
arrival.health.restore({ ...health, lastHurt: health.lastHurt + (destination.clock.now - source.clock.now) * 1000 });
|
|
263
277
|
transaction.commit(); traveller.releaseMotor(); arrival.attachMotor(rider.motor);
|
|
264
278
|
arrival.position.copy(rider.position); arrival.yaw = traveller.yaw;
|
|
279
|
+
if (arrival !== traveller) carryMotion(traveller, arrival);
|
|
280
|
+
if (to !== null) landOnGround(destination, arrival);
|
|
265
281
|
this.sites.set(player, to);
|
|
266
282
|
if (player !== this.owner) source.removePlayer(player);
|
|
267
283
|
if (this.occupied(from)) { if (player === this.owner) this.parkOwner(source); } else this.unparkOwner(source);
|
|
@@ -343,3 +359,22 @@ export class GridSimulation {
|
|
|
343
359
|
if (this.cleanupIssues.length > 0) throw new AggregateError(this.cleanupIssues, 'Grid simulation disposal failed');
|
|
344
360
|
}
|
|
345
361
|
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* GRID-CROSSING GC30b (QA-FEEDBACK-2026-11-13 row 11, J322 "there should never be any walls"): a walker who crosses into a cell whose
|
|
365
|
+
* entryway on that side has no ground of its own (Far Reach's sky islands: Jake walked south off the road at y 0 and fell) is set down
|
|
366
|
+
* on the first ground they can stand on, the cell's own spawn, never left hanging in the air. Its solids may be held near its lead
|
|
367
|
+
* (`NearColliders`), so they are brought up at the entryway before the probe and at the spawn after the move.
|
|
368
|
+
*/
|
|
369
|
+
export function landOnGround(host: SimHost, seat: PlayerSim): boolean {
|
|
370
|
+
const { position } = seat, near = host.physics.near;
|
|
371
|
+
// only a walker at the cell's edge, off the road: an `enter` sets down a saved pose inside the cell, where it stood before
|
|
372
|
+
if (Math.max(Math.abs(position.x), Math.abs(position.z)) < CHUNK_HALF - 10) return false;
|
|
373
|
+
near?.update(position.x, position.z);
|
|
374
|
+
if (entrywayStands(host.physics, position.x, position.z)) return false;
|
|
375
|
+
const { at, yaw } = host.level.player, mounted = mountedPlayerOf(host, seat.id);
|
|
376
|
+
// a rider and their horse go together, as a harness's `place` moves them
|
|
377
|
+
if (mounted?.mounted === true) mounted.teleport(at.x, at.z, yaw); else seat.resetPose(at, yaw);
|
|
378
|
+
near?.update(at.x, at.z);
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
@@ -4,6 +4,7 @@ import { actRoutes } from '@wildshard/engine/sim/actRoutes';
|
|
|
4
4
|
import { publishOwned, sayFightView } from '@wildshard/engine/sim/shardRows';
|
|
5
5
|
import { hasNativeInventory, nativeInventoryKeeps, creditNativeInventory } from '../../../shared/game/inventoryLaw';
|
|
6
6
|
import { harvestDrops } from '../../../shared/game/harvest';
|
|
7
|
+
import { registerInstalled } from '../shardfile/installedSides';
|
|
7
8
|
|
|
8
9
|
const finite = v.pipe(v.number(), v.finite());
|
|
9
10
|
const corpse = v.strictObject({ id: v.string(), kind: v.string(), variant: v.string(), x: finite, y: finite, z: finite });
|
|
@@ -11,6 +12,7 @@ const corpse = v.strictObject({ id: v.string(), kind: v.string(), variant: v.str
|
|
|
11
12
|
* Pending carcasses survive a world save; consumed claims are absent from it. */
|
|
12
13
|
export function installNativeHarvest(host: SimHost): void {
|
|
13
14
|
if(!hasNativeInventory(host,'pack'))return;
|
|
15
|
+
registerInstalled(host, 'harvest'); // SS3: the page's ambient life drops carcasses the server pays out
|
|
14
16
|
publishOwned(host,'harvest',(_player,out)=>{out.set('harvest.enabled',1);});
|
|
15
17
|
const pending = new Map<string, v.InferOutput<typeof corpse>>(), routes = actRoutes(host);
|
|
16
18
|
const bind = (row: v.InferOutput<typeof corpse>): void => {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SERVER-PARITY SS3b (meta docs/plans/SERVER-PARITY-PLAN.md): the server half of `quest.continuation`'s keepsakes. The page's
|
|
2
|
+
// keepsakes (client/game/compendium/keepsakes.ts) grant each progression state's rewards (Driftwood's sea glass charms: +10 max
|
|
3
|
+
// health at 5 glass) as the flags count up; a room's player held only what the page granted itself, so the server's owned book,
|
|
4
|
+
// the one its effects read, never had them. The room now pays each seated player off their own book's flags, by the same law.
|
|
5
|
+
import * as v from 'valibot';
|
|
6
|
+
import { LootProgressionSchema } from '@wildshard/format/lootBag';
|
|
7
|
+
import type { Shardfile } from '@wildshard/format/shardSchema';
|
|
8
|
+
import type { SimHost } from '@wildshard/engine/sim';
|
|
9
|
+
import { questBooks } from '@wildshard/engine/quest/players';
|
|
10
|
+
import { progressionState } from '../../../shared/game/compendium/keepsakeProgression';
|
|
11
|
+
import { isOwnedId, type Owned, type OwnedId } from '../../../shared/game/loot/Owned';
|
|
12
|
+
import { registerInstalled } from '../shardfile/installedSides';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Each step, grant every seated player (`seated`: the players whose goods are already open) the progression rewards their
|
|
16
|
+
* book's flags have earned, whenever that book moved: a flag, a restore or an imported save each move it. It never opens a
|
|
17
|
+
* seat itself, so a room's parked lead body is paid only once someone sits in it. Returns a player's release (they left: the
|
|
18
|
+
* next occupant is paid afresh), or null on a shard with no progression.
|
|
19
|
+
*/
|
|
20
|
+
export function installKeepsakeProgression(host: SimHost, source: Shardfile, seated: () => Iterable<readonly [string, Owned]>): ((player: string) => void) | null {
|
|
21
|
+
// a barter economy (Pine's) has no progression; a loot economy's is read by its own admitted schema
|
|
22
|
+
const raw = source.rows.loot.find(row => row.economy !== undefined)?.economy, declared = raw === undefined || !('progression' in raw) ? undefined : raw.progression;
|
|
23
|
+
const rows = declared === undefined ? undefined : v.parse(LootProgressionSchema, declared);
|
|
24
|
+
if (rows === undefined || rows.flags.length === 0) return null;
|
|
25
|
+
// the page's declaredLootEconomy refuses an unknown reward id; so does the room, at install
|
|
26
|
+
const states = rows.states.map(state => state.earned.map(reward => { if (!isOwnedId(reward.id)) throw new Error(`Unknown progression reward ${reward.id}`); return reward.id; }));
|
|
27
|
+
const progression: { readonly flags: readonly string[]; readonly states: readonly (readonly OwnedId[])[] } = { flags: rows.flags, states };
|
|
28
|
+
const books = questBooks(host), paid = new Map<string, number>();
|
|
29
|
+
host.onStep('owned.keepsakes', () => {
|
|
30
|
+
for (const [player, owned] of seated()) {
|
|
31
|
+
if (!host.players.has(player)) continue;
|
|
32
|
+
const book = books.of(player);
|
|
33
|
+
if (paid.get(player) === book.version) continue;
|
|
34
|
+
paid.set(player, book.version);
|
|
35
|
+
for (const id of progressionState(progression, flag => book.flags.has(flag))) owned.grant(id);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
registerInstalled(host, 'keepsakes');
|
|
39
|
+
return player => { paid.delete(player); };
|
|
40
|
+
}
|
|
@@ -12,6 +12,7 @@ import { Exchange } from '../../../shared/game/loot/exchange';
|
|
|
12
12
|
import { isCosmetic, isOwnedId, Owned } from '../../../shared/game/loot/Owned';
|
|
13
13
|
import { Purse } from '../../../shared/game/loot/Purse';
|
|
14
14
|
import { installOwnedEffects } from '../loadout/ownedEffects';
|
|
15
|
+
import { installKeepsakeProgression } from './keepsakeProgression';
|
|
15
16
|
import { OWNED_ROW, WORN_LINE } from '../../../shared/game/loot/ownedRows';
|
|
16
17
|
import { inventorySave, ownedSave, purseSave, skinSave, compendiumSave, finishPickupSave, saveSlug, CreatureRewardSchema, creatureRewardSave, type CreatureRewardState } from '../../../shared/game/saves';
|
|
17
18
|
|
|
@@ -228,8 +229,11 @@ export function installPlayerOwned(host: SimHost, shard: string, economy: unknow
|
|
|
228
229
|
}
|
|
229
230
|
return seat;
|
|
230
231
|
};
|
|
232
|
+
// SS3b: the keepsakes' progression rewards (sea glass charms) land in the same book its effects read
|
|
233
|
+
const keepsakes = source === undefined ? null : installKeepsakeProgression(host, source, () => session !== null
|
|
234
|
+
? [[questBooks(host).lead.player, session.owned] as const] : [...seats].map(([player, seat]) => [player, seat.owned] as const));
|
|
231
235
|
publishOwned(host, 'player', (player, out) => { of(player).read(out, pack); });
|
|
232
236
|
routes.wear = (player, id) => { const { owned } = of(player); if (isOwnedId(id) && isCosmetic(id) && owned.has(id)) owned.toggleWorn(id); };
|
|
233
237
|
if (shopped) routes.buy = (player, good) => { of(player).buy(good); };
|
|
234
|
-
return { of, drop: player => { effects.get(player)?.(); effects.delete(player); seats.delete(player); } };
|
|
238
|
+
return { of, drop: player => { keepsakes?.(player); effects.get(player)?.(); effects.delete(player); seats.delete(player); } };
|
|
235
239
|
}
|
|
@@ -83,6 +83,7 @@ import { installEntrySockets } from "@wildshard/engine/physics/entrySockets";
|
|
|
83
83
|
import { addPiece, type AddedPiece } from "@wildshard/engine/physics/pieces";
|
|
84
84
|
import { leadCommands } from '@wildshard/engine/sim/leadPlayer';
|
|
85
85
|
import { scriptSeats, type ScriptSeats } from './scriptSeats';
|
|
86
|
+
import { registerInstalled } from '../shardfile/installedSides';
|
|
86
87
|
|
|
87
88
|
type Physics = SimHost['physics'];
|
|
88
89
|
type PropColliderPort = NonNullable<ReturnType<ReturnType<typeof installShardfileColliders>['get']>>;
|
|
@@ -274,6 +275,9 @@ export async function prepareRuntimePlan(shard: Shardfile, assets: ReadonlyMap<s
|
|
|
274
275
|
encounters: new Map([[parseBossOwnerRow(recipe.population.owner).actor, encounter]]) },
|
|
275
276
|
});
|
|
276
277
|
if (ownsTargets) bindNativeWorldTargets(host, melee, questRuntime, targets, context.emit);
|
|
278
|
+
// SS3: the runtime plan's world holds the scenes' solids and the boss; its held melee and quest host are the page's halves.
|
|
279
|
+
// Its one-slot loadout is no catalogue kit, so it registers no `loadout`.
|
|
280
|
+
for (const key of ['collision', 'heldBoss', 'melee', 'questHost'] as const) registerInstalled(host, key);
|
|
277
281
|
if (row.columns) bindPlayerColumns(host, shard.modes?.traverse ?? []);
|
|
278
282
|
keeper.settle();
|
|
279
283
|
} };
|
|
@@ -5,6 +5,7 @@ import type { Collider } from '@dimforge/rapier3d-simd';
|
|
|
5
5
|
import { withOwner } from '@wildshard/engine/app/ownership';
|
|
6
6
|
import { solidReach } from '@wildshard/engine/physics/nearColliders';
|
|
7
7
|
import type { Physics } from '@wildshard/engine/physics/Physics';
|
|
8
|
+
import { isChunkEdgeWall } from '@wildshard/engine/physics/terrain';
|
|
8
9
|
import { tagCollider, tagOf, type Material } from '@wildshard/engine/physics/surface';
|
|
9
10
|
import type { SimHost } from '@wildshard/engine/sim';
|
|
10
11
|
|
|
@@ -70,7 +71,7 @@ export function installNativeCollision(host:Pick<SimHost,'physics'|'scope'|'onSt
|
|
|
70
71
|
options:{readonly resolution:number;readonly omit?:readonly Material[];
|
|
71
72
|
readonly provenance?:{readonly field:string;readonly step:string;readonly fallback:Material}}):ReadonlyMap<string,object|string> {
|
|
72
73
|
const owners=new Map<string,object|string>(),policy=options.provenance,omit=new Set(options.omit);
|
|
73
|
-
const omitted=(solid:NativeCollisionSolid):boolean=>solid.material!==undefined&&omit.has(solid.material);
|
|
74
|
+
const omitted=(solid:NativeCollisionSolid):boolean=>solid.material!==undefined&&omit.has(solid.material)||omit.has('edge')&&solid.shape===1&&solid.half!==undefined&&(solid.material===undefined||solid.material==='edge')&&isChunkEdgeWall(solid.at,solid.half,solid.rot[3]);
|
|
74
75
|
if(policy!==undefined){
|
|
75
76
|
if(!/^[a-z][a-zA-Z0-9]{0,63}$/u.test(policy.field))throw new Error('Invalid native owner field');
|
|
76
77
|
bake.solids.forEach(solid=>{const id=solid.ownerId;if(omitted(solid)||id===undefined||owners.has(id))return;
|
|
@@ -7,6 +7,7 @@ import {installRuntimeState,pageStateOf} from '../../../shared/game/shardfile/ru
|
|
|
7
7
|
import type {ObservedRecords} from '../../../shared/game/quest/questObservation';
|
|
8
8
|
import {featOutcome,witnessSavedFeats} from '../../../shared/game/quest/featCounters';
|
|
9
9
|
import {nativeQuestInputs,type NativeQuestInputs} from './nativeInputs';
|
|
10
|
+
import {registerInstalled} from '../shardfile/installedSides';
|
|
10
11
|
|
|
11
12
|
interface BossRecord { defeated:boolean;rewardTaken:boolean;kills:number }
|
|
12
13
|
/** The actual declared boss field and the existing elite continuation, borrowed
|
|
@@ -86,6 +87,7 @@ export async function prepareChapterRecords(product:Pick<ShardProduct,'json'|'sh
|
|
|
86
87
|
live();return v.parse(elites,eliteOwner.snapshot()).records;
|
|
87
88
|
}},outcomes:{kill:(kind,variant)=>{featOutcome(counterRows,counterPorts,'kill',kind,variant);},
|
|
88
89
|
feat:(event,total)=>{featOutcome(counterRows,counterPorts,'event',event,undefined,total);}}};
|
|
90
|
+
registerInstalled(host,'saves'); // SS3b: the boss record and feat counts of quests/persistence.json, in the room's continuation
|
|
89
91
|
host.onStep(ids.step,()=>{/* Encounters own all writes; this adapter adds no tick work. */}, {
|
|
90
92
|
snapshot:()=>JSON.stringify({version:1,bosses:read(),counts:readCounts()}),restore:value=>{
|
|
91
93
|
if(typeof value!=='string')throw new Error('Chapter boss continuation requires its JSON wire');
|
|
@@ -28,6 +28,7 @@ import { questObservation, type ObservedRecords } from '../../../shared/game/que
|
|
|
28
28
|
import type { QuestStepEffect } from '../../../shared/game/quest/steps';
|
|
29
29
|
import type { ShardProduct } from '../../../shared/game/shardfile/shardProduct';
|
|
30
30
|
import { mountedPlayerOf } from '../riding/native';
|
|
31
|
+
import { registerInstalled } from '../shardfile/installedSides';
|
|
31
32
|
|
|
32
33
|
/** The file that says a shard's story runs on its chapters. */
|
|
33
34
|
export const CHAPTER_CONTENT = 'quests/content.json';
|
|
@@ -188,5 +189,8 @@ export async function installServerChapters(host: SimHost, product: ShardProduct
|
|
|
188
189
|
}
|
|
189
190
|
});
|
|
190
191
|
host.scope.onDispose(() => { for (const seat of seats.values()) seat.off(); seats.clear(); });
|
|
192
|
+
// SS3b: `state.adventure`'s server half: the same quests/persistence.json rows, each player's feat counts and bond kept as
|
|
193
|
+
// their own book's flags (saved with the room), where the page keeps one device's records
|
|
194
|
+
if (counters !== undefined || saved.bond !== undefined) registerInstalled(host, 'saves');
|
|
191
195
|
return true;
|
|
192
196
|
}
|
|
@@ -41,8 +41,9 @@ function pieceColliders(host: SimHost): ReadonlyMap<string, Collider> {
|
|
|
41
41
|
return found;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/** Keep the building doors of a shard that has them. False when it has none. `opened`: what a page's save left open, for a world's first boot.
|
|
45
|
-
|
|
44
|
+
/** Keep the building doors of a shard that has them. False when it has none. `opened`: what a page's save left open, for a world's first boot.
|
|
45
|
+
* `restored`: a world restored from its save, whose leaves already stand where the save put them. */
|
|
46
|
+
export async function installServerDoors(host: SimHost, product: ShardProduct | undefined, opened: ReadonlySet<string> = new Set(), restored = false): Promise<boolean> {
|
|
46
47
|
if (product === undefined || !product.hasFile(PIECES) || !product.hasFile(FOREST)) return false;
|
|
47
48
|
const [piecesInput, forestInput, compositionInput] = await Promise.all([product.json<unknown>(PIECES), product.json<unknown>(FOREST), product.hasFile(COMPOSITION) ? product.json<unknown>(COMPOSITION) : null]);
|
|
48
49
|
const look = v.parse(Forest, forestInput).buildings?.life.door, composition = compositionInput === null ? undefined : v.parse(Composition, compositionInput).door;
|
|
@@ -52,11 +53,14 @@ export async function installServerDoors(host: SimHost, product: ShardProduct |
|
|
|
52
53
|
for (const row of rows) {
|
|
53
54
|
const collider = colliders.get(row.id), matrix = row.follows?.matrix;
|
|
54
55
|
if (row.category !== 'buildings' || row.follows?.rotation !== true || matrix === undefined || collider === undefined || rows.some(other => other.id === row.id.replace(/-bar$/u, '') && other.id !== row.id)) continue;
|
|
55
|
-
const hinge = { x: matrix[12] ?? 0, y: matrix[13] ?? 0, z: matrix[14] ?? 0 }, rotation = collider.rotation(), at = collider.translation();
|
|
56
|
-
const local = turned(conjugate(rotation), { x: at.x - hinge.x, y: at.y - hinge.y, z: at.z - hinge.z });
|
|
57
56
|
const door = buildingDoor(row.id), flag = buildingDoorFlag(row.id);
|
|
58
57
|
if (opened.has(row.id)) host.flags.set(flag);
|
|
59
58
|
door.open = host.flags.has(flag); door.t = door.open ? 1 : 0;
|
|
59
|
+
// A fresh world's leaf stands shut, as baked. A restored one stands where its save put it (open, if its flag is), so its
|
|
60
|
+
// shut pose is that one turned back.
|
|
61
|
+
const hinge = { x: matrix[12] ?? 0, y: matrix[13] ?? 0, z: matrix[14] ?? 0 }, standing = collider.rotation(), at = collider.translation();
|
|
62
|
+
const rotation = restored ? times(standing, yawOf(-buildingDoorYaw(door.t, look.angle))) : standing;
|
|
63
|
+
const local = turned(conjugate(standing), { x: at.x - hinge.x, y: at.y - hinge.y, z: at.z - hinge.z });
|
|
60
64
|
leaves.push({ door, flag, collider, hinge, rotation, local, bars: bars.filter(gate => gate.target.piece === row.id).map(gate => gate as { readonly opensWhen: Parameters<typeof test>[1] }) });
|
|
61
65
|
}
|
|
62
66
|
if (leaves.length === 0) return false;
|
|
@@ -66,7 +70,9 @@ export async function installServerDoors(host: SimHost, product: ShardProduct |
|
|
|
66
70
|
leaf.collider.setRotation(q); leaf.collider.setTranslation({ x: leaf.hinge.x + at.x, y: leaf.hinge.y + at.y, z: leaf.hinge.z + at.z });
|
|
67
71
|
};
|
|
68
72
|
for (const leaf of leaves) {
|
|
69
|
-
|
|
73
|
+
// A restored leaf is left where it stands: posing it again moves it by a rounding error and re-files it in the broad
|
|
74
|
+
// phase, so the resumed world's physics would no longer match the world that never stopped (HS1).
|
|
75
|
+
if (!restored) pose(leaf);
|
|
70
76
|
routes.claims.set(leaf.door.id, player => {
|
|
71
77
|
const body = host.players.get(player);
|
|
72
78
|
if (body === undefined || Math.hypot(body.position.x - leaf.hinge.x, body.position.z - leaf.hinge.z) > DOOR_REACH + Math.hypot(leaf.local.x, leaf.local.z)) return;
|
|
@@ -57,4 +57,8 @@ export function installRoomRespawn(host: SimHost, places: readonly PlaceArea[]):
|
|
|
57
57
|
lastUnstuck.set(id, tick);
|
|
58
58
|
place(player);
|
|
59
59
|
};
|
|
60
|
+
// QA 11-13 (Jake: "It needs a button, a Respawn now button"): the death card's button. The fall already placed the player;
|
|
61
|
+
// this only ends their own fade early, so their commands move them again. It moves nobody and gives no cover: the fade is
|
|
62
|
+
// the fallen player's only shield, and they are the only one who can end it.
|
|
63
|
+
actRoutes(host).respawnNow = id => { if (host.players.has(id)) book.skipFade(id); };
|
|
60
64
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SERVER-PARITY SS3: the per-host record of which SS2 server halves an installer built. The game's installers register here
|
|
2
|
+
// (a game module can't import the host layer); src/server/host/installers.ts names each key's owners and checks a product.
|
|
3
|
+
import type { SimHost } from '@wildshard/engine/sim';
|
|
4
|
+
|
|
5
|
+
/** Every server key shard-format's SS2 side table (`featureSides`) names for a `both` or `server` kind. */
|
|
6
|
+
export type ServerInstallerKey = 'arenaRoom' | 'collision' | 'fallFloor' | 'grapple' | 'harvest' | 'heldArms' | 'heldBoss' | 'heldRanged' | 'keepsakes'
|
|
7
|
+
| 'loadout' | 'melee' | 'movers' | 'places' | 'portalRide' | 'poseViews' | 'questComposition' | 'questHost' | 'ropeDecks' | 'saves' | 'slots'
|
|
8
|
+
| 'stealth' | 'windElite';
|
|
9
|
+
|
|
10
|
+
const installed = new WeakMap<SimHost, Set<ServerInstallerKey>>();
|
|
11
|
+
|
|
12
|
+
/** An installer built `key`'s server half on `host`. Install and restore both register; the record lives as long as the host. */
|
|
13
|
+
export function registerInstalled(host: SimHost, key: ServerInstallerKey): void {
|
|
14
|
+
const keys = installed.get(host);
|
|
15
|
+
if (keys === undefined) installed.set(host, new Set([key])); else keys.add(key);
|
|
16
|
+
}
|
|
17
|
+
/** The keys whose installers ran on `host`. */
|
|
18
|
+
export function installedKeys(host: SimHost): ReadonlySet<ServerInstallerKey> { return installed.get(host) ?? new Set(); }
|
|
@@ -64,6 +64,7 @@ import { nativeDecisionAuthority } from './borrowedDecisions';
|
|
|
64
64
|
import { installNativeGroupRows } from './groupRuntime';
|
|
65
65
|
import { need, readAssemblyInput, type AssemblyPrepared, type NativeAssemblyContext } from './nativeAssemblyInput';
|
|
66
66
|
import { installBodyScripts, installCombatMotion } from './nativeRuntimeLoans';
|
|
67
|
+
import { registerInstalled } from './installedSides';
|
|
67
68
|
|
|
68
69
|
/** What one install's hosts hand each other, in the plan's order. A later host reads what an earlier one left. */
|
|
69
70
|
export interface AssemblyRun<C extends NativeAssemblyContext> {
|
|
@@ -93,7 +94,7 @@ async function prepareQuest<C extends NativeAssemblyContext>(row: Extract<Native
|
|
|
93
94
|
const props = row.props === undefined ? undefined : await read<unknown>(row.props);
|
|
94
95
|
const trades = row.barter === true ? parseBarterEconomy(need(shard.rows.loot[0], 'Missing barter row').economy).exchange : undefined;
|
|
95
96
|
const secret = content === undefined ? undefined : await readNativeQuestSecret(product);
|
|
96
|
-
return run => { run.quest = installNativeQuestComposition(run.host, { source: shard, table, rows, spots: row.readSpots === true ? readNativeQuestSpots(spots) : spots, counters: native,
|
|
97
|
+
return run => { registerInstalled(run.host, 'questComposition'); run.quest = installNativeQuestComposition(run.host, { source: shard, table, rows, spots: row.readSpots === true ? readNativeQuestSpots(spots) : spots, counters: native,
|
|
97
98
|
...(content === undefined ? {} : { steps: content.steps, deaths: content.deaths, readings: content.readings, lead: content.lead }),
|
|
98
99
|
...(contracts === undefined ? {} : { contracts: ownContractCatalogue(contracts, run.host.scope) }), ...(trades === undefined ? {} : { trades }), ...(director === undefined ? {} : { director }),
|
|
99
100
|
...(props === undefined ? {} : { props }), ...(secret === undefined ? {} : { secret }), ...(row.restoring === true ? { restoring: run.context.restoring } : {}) }); };
|
|
@@ -154,7 +155,7 @@ export async function prepareAssemblyFeature<C extends NativeAssemblyContext>(ro
|
|
|
154
155
|
}
|
|
155
156
|
case 'boss.arena': {
|
|
156
157
|
const input = await readAssemblyInput<unknown>(product, { file: row.file }), spec = arenaSpecies(await readAssemblyInput<unknown>(product, { file: 'server/arena-species.json' }));
|
|
157
|
-
return run => { if (run.context.room === true) installArenaEntry(run.host, input, row, { spec, grantItem: at.ports.grantItem(run.context), snapshot: run.context.snapshot }); };
|
|
158
|
+
return run => { if (run.context.room === true) { installArenaEntry(run.host, input, row, { spec, grantItem: at.ports.grantItem(run.context), snapshot: run.context.snapshot }); registerInstalled(run.host, 'arenaRoom'); } };
|
|
158
159
|
}
|
|
159
160
|
case 'held.arms': {
|
|
160
161
|
const arms = await prepareHeldArms(product, { ...row, weather: await readAssemblyInput<unknown>(product, row.weather) }), stealth = prepareNativeStealth(product);
|
|
@@ -163,7 +164,9 @@ export async function prepareAssemblyFeature<C extends NativeAssemblyContext>(ro
|
|
|
163
164
|
contacts: (host, from, direction, distance, hit) => patrolOf(host)?.target(from, direction, distance, hit) ?? hit });
|
|
164
165
|
// SS4: the sneak shot the page doubles, decided here from each player's own Hidden state. Installed after the arms so
|
|
165
166
|
// exportSeats keeps its indexes; a shot therefore reads the state one tick old, where the page reads the same frame's.
|
|
166
|
-
|
|
167
|
+
// SS3: the held arms own the room's equip swap, the server half of the page's catalogue kit
|
|
168
|
+
registerInstalled(run.host, 'heldArms'); registerInstalled(run.host, 'loadout');
|
|
169
|
+
if (stealth !== null) { stealth(run.host, { tick, groups: run.groups }); registerInstalled(run.host, 'stealth'); } } };
|
|
167
170
|
}
|
|
168
171
|
case 'encounter.patrol': {
|
|
169
172
|
if (at.ports.room !== true) return () => undefined;
|
|
@@ -175,12 +178,14 @@ export async function prepareAssemblyFeature<C extends NativeAssemblyContext>(ro
|
|
|
175
178
|
let captain: NativeCaptain | null = null, windElite: NativeWindElite | null = null;
|
|
176
179
|
const finish = patrol.begin(run.host, { eliteDamage: (host, actor, request) => captain?.scale(actor, request.point) ?? run.arena?.eliteDamage(host, actor, request) ?? 1, beforePatrol: (host, dt) => { slots?.advance(host, dt); captain?.advance(dt); windElite?.advance(dt); }, afterPatrol: (host, dt) => { run.arena?.advance(host, dt); } });
|
|
177
180
|
run.patrol = () => {
|
|
178
|
-
finish();
|
|
181
|
+
finish();
|
|
182
|
+
if (slots !== null) { slots.install(run.host, need(run.bindings, 'Slots need their bindings'), run.context.restoring); registerInstalled(run.host, 'slots'); registerInstalled(run.host, 'poseViews'); }
|
|
179
183
|
if (ride !== null && elites !== undefined) { captain = ride(run.host, decisions => nativeEliteCore(run.host, elites.conditions, decisions, dayOf(run), need(run.wild, 'A captain needs his environment')), `${row.step}.captain`); if (captain.lair.record !== undefined) need(run.eliteCore, 'A captain needs the world\'s lairs').share(captain.lair.id, captain.lair.record); }
|
|
180
184
|
if (fly !== null && elites !== undefined) {
|
|
181
185
|
const env = need(run.wild, 'A wind elite needs its environment'), world = need(run.eliteCore, 'A wind elite needs the world\'s lairs');
|
|
182
186
|
windElite = fly(run.host, need(run.bindings, 'A wind elite needs its bindings'), () => nativeEliteCore(run.host, elites.conditions, ReturnProgram.native(run.host, bootOf(at).admission), dayOf(run), env), `${row.step}.wind`, () => env.wind);
|
|
183
187
|
if (windElite.lair.record !== undefined) world.share(windElite.lair.id, windElite.lair.record);
|
|
188
|
+
registerInstalled(run.host, 'windElite');
|
|
184
189
|
}
|
|
185
190
|
};
|
|
186
191
|
};
|
|
@@ -192,6 +197,7 @@ export async function prepareAssemblyFeature<C extends NativeAssemblyContext>(ro
|
|
|
192
197
|
const { host, context } = run; run.arena = arena;
|
|
193
198
|
arena.observeWeather(host, need(run.weather, 'An open arena needs its weather')); arena.cover(host); need(run.patrol, 'An open arena needs its patrol')();
|
|
194
199
|
arena.install(host, { presentation: need(at.ports.arena, 'An open arena needs its presentation'), commands: at.ports.heldTick(context).commands, ledger: at.ports.ledger(context), restoring: context.restoring, grantItem: at.ports.grantItem(context) });
|
|
200
|
+
registerInstalled(host, 'poseViews');
|
|
195
201
|
};
|
|
196
202
|
}
|
|
197
203
|
case 'grapple': {
|
|
@@ -201,6 +207,7 @@ export async function prepareAssemblyFeature<C extends NativeAssemblyContext>(ro
|
|
|
201
207
|
return run => {
|
|
202
208
|
const { context } = run, guard = context.restoring ? [] : run.host.physics.world.colliders.getAll().filter(collider => tagOf(collider)?.owner === row.guard).map(collider => collider.handle);
|
|
203
209
|
installGrapple(run.host, at.ports.grappleTick(context), profile, mode, hooks, guard, row.rise === true);
|
|
210
|
+
registerInstalled(run.host, 'grapple');
|
|
204
211
|
};
|
|
205
212
|
}
|
|
206
213
|
case 'riding.taming': {
|
|
@@ -216,13 +223,14 @@ export async function prepareAssemblyFeature<C extends NativeAssemblyContext>(ro
|
|
|
216
223
|
case 'commands': return run => { run.input = at.ports.bindCommands(run.context, run.host); };
|
|
217
224
|
case 'collision': {
|
|
218
225
|
const collision = need(plan.collision, 'Native collision needs its settings'); need(plan.bake, 'Native collision needs its bake');
|
|
219
|
-
//
|
|
220
|
-
|
|
226
|
+
// GC36 (J322, no walls): an older bake still holds its page's chunk-edge walls (`edge`); no world stands them, as a cell held near
|
|
227
|
+
// its player never did (`nativeBake.ts`).
|
|
228
|
+
return run => { registerInstalled(run.host, 'collision'); if (row.skipOnRestore !== true || !run.context.restoring) installNativeCollision(run.host, at.bake, { ...collision, omit: [...(collision as { omit?: readonly string[] }).omit ?? [], 'edge'] } as Parameters<typeof installNativeCollision>[2]); };
|
|
221
229
|
}
|
|
222
|
-
case 'collision.pieces': { const pieces = await readAssemblyInput<unknown>(product, row.rows); return run => { if (!run.context.restoring) addBakedPieces(run.host.physics, pieces); }; }
|
|
230
|
+
case 'collision.pieces': { const pieces = await readAssemblyInput<unknown>(product, row.rows); return run => { registerInstalled(run.host, 'collision'); if (!run.context.restoring) addBakedPieces(run.host.physics, pieces); }; }
|
|
223
231
|
case 'portal.ride': {
|
|
224
232
|
const ride = await readAssemblyInput<PortalRideRows>(product, row.rows);
|
|
225
|
-
return run => { installHostPortalRide(run.host, row.step, shard, ride, at.ports.ledger(run.context).fact); };
|
|
233
|
+
return run => { installHostPortalRide(run.host, row.step, shard, ride, at.ports.ledger(run.context).fact); registerInstalled(run.host, 'portalRide'); };
|
|
226
234
|
}
|
|
227
235
|
case 'day.keyed-sky': { const spec = keyedSkyDaySpec(product.section('look/keyed-sky')); return run => { run.day = run.host.useDayClock(new DayCycle(spec)); }; }
|
|
228
236
|
case 'day.toon': {
|
|
@@ -248,12 +256,13 @@ export async function prepareAssemblyFeature<C extends NativeAssemblyContext>(ro
|
|
|
248
256
|
if (row.kind === 'bolt') installNativeItems(run.host, combat, { kind: 'bolt', policy, profile });
|
|
249
257
|
else if (row.kind === 'cycle') installNativeItems(run.host, combat, { kind: 'cycle', policy, profile });
|
|
250
258
|
else installNativeItems(run.host, combat, { kind: 'bow', policy, profile });
|
|
259
|
+
registerInstalled(run.host, 'heldRanged');
|
|
251
260
|
};
|
|
252
261
|
}
|
|
253
|
-
case 'item.swept': { const policy = await readAssemblyInput(product, row.policy); return run => { installNativeItems(run.host, combatOf(run), { kind: 'swept', items: shard.items.rows, policy }); }; }
|
|
262
|
+
case 'item.swept': { const policy = await readAssemblyInput(product, row.policy); return run => { installNativeItems(run.host, combatOf(run), { kind: 'swept', items: shard.items.rows, policy }); registerInstalled(run.host, 'heldArms'); registerInstalled(run.host, 'loadout'); }; }
|
|
254
263
|
case 'loadout': {
|
|
255
264
|
const policy = need(shard.items.loadout.native, 'Missing native loadout'), input = need(policy.input, 'Missing native equipment input policy');
|
|
256
|
-
return run => { const combat = combatOf(run); bindNativeLoadout(run.host, policy, { flags: run.host.flags, frame: combat,
|
|
265
|
+
return run => { const combat = combatOf(run); registerInstalled(run.host, 'loadout'); bindNativeLoadout(run.host, policy, { flags: run.host.flags, frame: combat,
|
|
257
266
|
locked: () => run.boss?.locked() === true || run.quest?.riding() === true || run.quest?.talking() === true,
|
|
258
267
|
others: { frame: player => otherCombatFrame(combat, player.id), locked: () => run.boss?.locked() === true },
|
|
259
268
|
step: { id: input.step, phase: input.phase, pick: (player, first) => {
|
|
@@ -20,10 +20,7 @@ import type { ShardProduct } from '../../../shared/game/shardfile/shardProduct';
|
|
|
20
20
|
/** What a server host hands one install. The tick protocol belongs to the SDK: `ports` adapts it. */
|
|
21
21
|
export interface NativeAssemblyContext { readonly combat?: NativeCombatFrame; readonly restoring: boolean; readonly snapshot?: Readonly<Omit<SimSnapshot, 'physics'>>;
|
|
22
22
|
/** A net room's world: it also runs the fights a page or a tape keeps to itself. */
|
|
23
|
-
readonly room?: boolean
|
|
24
|
-
/** GC15: a grid cell that opens onto its worker's road (`WORLD_CROSSING=worker`): the edge is the platform's, so the shard's
|
|
25
|
-
* own page walls in its baked collision don't stand there, as for a cell held near its player. */
|
|
26
|
-
readonly road?: boolean }
|
|
23
|
+
readonly room?: boolean }
|
|
27
24
|
/** The SDK's tick-protocol loans. No module URL or shard code crosses this boundary. */
|
|
28
25
|
export interface NativeAssemblyPorts<C extends NativeAssemblyContext> {
|
|
29
26
|
readonly rapier: Rapier;
|