@wildshard/engine 0.1.22 → 0.1.24
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 +17 -4
- package/lint/engine-sides.json +9 -0
- package/lint/sim-players.json +2 -13
- package/package.json +36 -3
- 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/app-build/titlePreloads.mjs +8 -5
- package/scripts/bake-road-surfaces.entry.ts +18 -0
- package/scripts/bake-road-surfaces.mjs +44 -0
- package/scripts/changelog.mjs +2 -1
- package/scripts/ci-pack.mjs +3 -3
- package/scripts/engine-ci-shard.mjs +11 -0
- package/scripts/fight-page-census.mjs +131 -0
- package/scripts/goldens/board.py +44 -11
- package/scripts/goldens/capture.mjs +18 -6
- package/scripts/goldens/native-residency.d.mts +2 -0
- package/scripts/goldens/native-residency.mjs +31 -4
- package/scripts/grid-road-lag.mjs +209 -0
- package/scripts/keep-copy.mjs +172 -0
- package/scripts/land.d.mts +4 -1
- package/scripts/land.mjs +121 -9
- 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 +59 -7
- package/scripts/loading-flow/stalls.d.mts +2 -0
- package/scripts/loading-flow/stalls.mjs +13 -0
- package/scripts/map-hash.mjs +1 -1
- package/scripts/mmo-bots.mjs +5 -3
- package/scripts/mmo-grid-proof.mjs +74 -0
- package/scripts/mmo-seat-proof.mjs +43 -0
- package/scripts/nightly-heads.ts +13 -13
- package/scripts/nightly-model.ts +26 -12
- package/scripts/nightly-tag.mjs +2 -4
- package/scripts/nightly.proof.ts +18 -5
- package/scripts/nightly.ts +13 -8
- package/scripts/no-astc-boot.mjs +77 -0
- package/scripts/page-release/content.mjs +19 -10
- package/scripts/page-release/flow.d.mts +3 -2
- package/scripts/page-release/flow.mjs +31 -21
- package/scripts/page-release/packs.d.mts +5 -0
- package/scripts/page-release/packs.mjs +13 -3
- package/scripts/page-release/preview.d.mts +2 -0
- package/scripts/page-release/preview.mjs +74 -0
- package/scripts/page-release.mjs +13 -5
- 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/ring3.proof.ts +71 -0
- package/scripts/ring3.ts +100 -0
- package/scripts/road-drive-proof.mjs +269 -0
- package/scripts/road-memory-probe.mjs +129 -0
- package/scripts/scratch-dir.mjs +33 -14
- package/scripts/scratch-sweep.mjs +15 -23
- package/scripts/server-release/github.mjs +59 -26
- package/scripts/server-release/items.d.mts +7 -0
- package/scripts/server-release/items.mjs +28 -0
- package/scripts/server-release/publish.mjs +24 -2
- package/scripts/server-release/sign.mjs +8 -4
- package/scripts/side-parity.mjs +1 -1
- package/scripts/test-products.json +1 -0
- package/scripts/test_prebuilt_output.py +3 -1
- package/scripts/tsconfig.json +2 -0
- package/scripts/turn-in-shots.mjs +83 -0
- package/scripts/vitest-bench-observe-proof.py +168 -0
- package/scripts/vitest-bench.py +122 -77
- package/scripts/vitest-ci-files.ts +5 -1
- package/scripts/vps/rebuild.sh +3 -1
- package/scripts/vps/wildshard-config +106 -1
- package/scripts/warm-native-chrome.mjs +9 -3
- package/scripts/worker-client-fights.mjs +9 -3
- package/scripts/worktree-reap.mjs +36 -140
- package/scripts/worktree.mjs +92 -12
- package/scripts/zone-gate-proof.mjs +93 -0
- package/src/client/engine/audio/audioLog.ts +7 -2
- package/src/client/engine/boot/diagnostics.ts +69 -1
- package/src/client/engine/boot/sw.ts +3 -1
- package/src/client/engine/core/ktx2.ts +33 -10
- package/src/client/engine/core/ktx2Zstd.ts +2 -1
- package/src/client/engine/models/place.ts +7 -5
- package/src/client/engine/pwa/sw.js +83 -10
- package/src/client/engine/render/dataLook.ts +14 -7
- package/src/client/engine/render/lookLight.ts +64 -20
- package/src/client/engine/render/precompile.ts +6 -0
- package/src/client/engine/render/tiers.ts +9 -0
- package/src/client/engine/ui/Loading.ts +6 -8
- package/src/client/engine/ui/lookLightOption.ts +1 -1
- package/src/client/engine/ui/playerReload.ts +5 -5
- package/src/client/game/audio/cueDirector.ts +2 -1
- package/src/client/game/boot/bytes.generated.ts +4 -1
- package/src/client/game/boot/versions.generated.ts +8 -5
- 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/cellClip.ts +70 -6
- package/src/client/game/grid/dataCellKit.ts +9 -1
- package/src/client/game/grid/gateCard.css +9 -0
- package/src/client/game/grid/gateCard.ts +67 -0
- package/src/client/game/grid/live.ts +17 -3
- package/src/client/game/grid/liveSession.ts +15 -5
- package/src/client/game/grid/neighbourLife.ts +10 -1
- package/src/client/game/grid/neighbourPanels.ts +29 -2
- package/src/client/game/grid/pageEntry.ts +21 -0
- package/src/client/game/grid/products.ts +21 -7
- package/src/client/game/grid/regionalWorld.ts +5 -0
- package/src/client/game/grid/roadCompressedSurfaces.ts +69 -0
- package/src/client/game/grid/roadLook.ts +5 -73
- package/src/client/game/grid/roadLookPlatform.ts +11 -6
- package/src/client/game/grid/roadSurfaceMaps.ts +80 -0
- package/src/client/game/grid/roadTilePool.ts +4 -0
- package/src/client/game/grid/session.ts +58 -16
- package/src/client/game/grid/softWallLook.ts +6 -1
- package/src/client/game/plugin/ui.ts +3 -0
- package/src/client/game/population/signals.ts +1 -1
- package/src/client/game/quest/chapterDirector.ts +1 -0
- package/src/client/game/session/play.ts +3 -0
- package/src/client/game/shardfile/clientBossTelegraph.ts +4 -3
- package/src/client/game/shardfile/clientSource.ts +5 -2
- package/src/client/game/shardfile/clientWorker.ts +25 -8
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/runtimeProduct.ts +9 -5
- package/src/client/game/shardfile/slabLibrary.ts +37 -0
- package/src/client/game/shardfile/slabRanges.ts +145 -0
- 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 +2 -2
- package/src/client/host/standalone/shell.ts +4 -1
- 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/simulation.ts +32 -8
- package/src/server/game/plugin/mover.ts +18 -14
- package/src/server/game/plugin/simulation.ts +2 -0
- package/src/server/game/shardfile/dataRespawn.ts +47 -0
- package/src/server/game/shardfile/declaredKitItems.ts +31 -7
- package/src/server/host/bake/headlessWorker.ts +3 -3
- package/src/server/host/dedicated/cellWorker.ts +4 -2
- package/src/server/host/dedicated/main.ts +7 -4
- package/src/server/host/dedicated/packReader.ts +15 -2
- package/src/server/host/dedicated/playerStore.ts +1 -1
- package/src/server/host/headlessRuntime.ts +11 -6
- package/src/server/host/standalone/cellWorld.ts +20 -6
- package/src/server/host/standalone/gridServer.ts +20 -6
- package/src/server/host/standalone/roadWorld.ts +36 -0
- package/src/server/host/standalone/serverHost.ts +2 -2
- package/src/shared/engine/entities/AnimalSim.ts +10 -0
- package/src/shared/engine/physics/gridBorders.ts +15 -1
- package/src/shared/engine/physics/transferWalls.ts +9 -4
- package/src/shared/engine/sim/snapshot.ts +5 -5
- package/src/shared/game/grid/allocator.ts +8 -1
- package/src/shared/game/grid/gateCount.ts +27 -0
- package/src/shared/game/grid/zoneWalls.ts +64 -0
- 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/game/strings.ts +2 -0
- 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/shared/host/standalone/harnessPlace.ts +4 -0
- package/src/test/engine/simState.ts +134 -0
- package/src/test/game/builtProduct.ts +6 -0
- package/src/test/game/headless/admittedProductCache.ts +61 -0
- package/src/test/game/headless/checkedReplayPipeline.ts +21 -0
- package/src/test/game/headless/nativeBounds.ts +27 -0
- package/src/test/game/headless/processUsage.ts +22 -0
- package/src/test/game/headless/productSession.ts +39 -0
- package/src/test/game/headless/ropeBodies.ts +60 -0
- package/src/test/game/headless/worker.ts +34 -0
- package/src/test/game/headlessNative.ts +114 -0
- package/src/test/game/headlessWorker.ts +43 -0
- package/src/test/tsconfig.game.json +3 -0
|
@@ -14,7 +14,7 @@ import { Worker } from 'node:worker_threads';
|
|
|
14
14
|
import { loadRapier } from '@wildshard/engine/physics/rapier';
|
|
15
15
|
import type { WorkerNews } from './cellProtocol';
|
|
16
16
|
import type { CellWorkerData } from './cellWorker';
|
|
17
|
-
import { readPackProduct, type PackReads } from './packReader';
|
|
17
|
+
import { readPackProduct, readReleaseItems, type PackReads } from './packReader';
|
|
18
18
|
import { openPlayerSaves, memoryPlayerSaves } from './playerSaves';
|
|
19
19
|
import type { ReleaseFile } from '../../../shared/host/releaseRows';
|
|
20
20
|
import { fetchReleaseFile, servingRelease, ReleaseWatch } from './releaseFile';
|
|
@@ -56,6 +56,8 @@ async function installedRelease(): Promise<ReleaseFile> {
|
|
|
56
56
|
return selected;
|
|
57
57
|
}
|
|
58
58
|
const release = await installedRelease();
|
|
59
|
+
const itemReads: PackReads = { fetched: 0, fetchedBytes: 0, cached: 0, refused: 0 };
|
|
60
|
+
const catalogue = await readReleaseItems(release.items, { origin, cache }, itemReads);
|
|
59
61
|
// C5, C11, GO3: the cells, by grid instance, fixed at startup; a player with no save lands in the first. `grid` opens every grid cell
|
|
60
62
|
// the release names, home first. A cell runs its shard's pack, and the release must name that shard.
|
|
61
63
|
const listed = process.env['WORLD_CELLS'] ?? 'driftwood-isle', cells = worldCells(listed, release.shards.map(shard => shard.slug)), shards = [...new Set(cells.map(cellShard))];
|
|
@@ -80,7 +82,7 @@ const playtest=process.env['PLAYTEST']==='1'?new PlaytestFile({directory:setting
|
|
|
80
82
|
|
|
81
83
|
/** One row of the table is one worker thread, started once (J182). */
|
|
82
84
|
function bootWorker(slugs: readonly string[]): WorkerLink {
|
|
83
|
-
const data: CellWorkerData = { slugs, build, origin, cache, placed: placedCells(), ...(hold === undefined ? {} : { holdMs: Number(hold) }), ...(empty === undefined ? {} : { emptyMs: Number(empty) }), crossing: true, ...(metrics === undefined ? {} : { metrics: true }),...(playtest===undefined?{}:{playtest:true}) };
|
|
85
|
+
const data: CellWorkerData = { slugs, build, origin, cache, catalogue, placed: placedCells(), ...(hold === undefined ? {} : { holdMs: Number(hold) }), ...(empty === undefined ? {} : { emptyMs: Number(empty) }), crossing: true, ...(metrics === undefined ? {} : { metrics: true }),...(playtest===undefined?{}:{playtest:true}) };
|
|
84
86
|
const worker = new Worker(new URL('cellWorker.mjs', import.meta.url), { workerData: data });
|
|
85
87
|
let stopped = false;
|
|
86
88
|
return { send: (order, transfer = []) => { worker.postMessage(order, transfer as never); },
|
|
@@ -141,7 +143,8 @@ async function pullBundle(script: string): Promise<void> {
|
|
|
141
143
|
const watch = new ReleaseWatch({ read: readRelease, serving: release, cells: shards, ...(poll === undefined ? {} : { everyMs: Number(poll) }), failed: error => { log({ at: 'release.failed', error: String(error) }); },
|
|
142
144
|
changed: async next => {
|
|
143
145
|
if (pullScript !== undefined) await pullBundle(pullScript);
|
|
144
|
-
|
|
146
|
+
const nextCatalogue = await readReleaseItems(next.items, { origin, cache }, reads);
|
|
147
|
+
for (const slug of shards) await readPackProduct(slug, next.engineBuild, await rapier(), { origin, cache }, reads, undefined, nextCatalogue);
|
|
145
148
|
world.beginGrace(next.engineBuild);
|
|
146
149
|
} });
|
|
147
150
|
// SA33: a cell the API placed opens on this running server within a look, on a worker of its own, with no grace and no restart. Its shard's
|
|
@@ -154,7 +157,7 @@ placements = placementAt === undefined || placementKey === undefined || listed.t
|
|
|
154
157
|
const ready: string[] = [];
|
|
155
158
|
for (const row of rows) {
|
|
156
159
|
// SA34a: the pack first, so the door's placed list (and so every worker's frame numbers) holds only cells it opens.
|
|
157
|
-
try { await readPackProduct(row.slug, build, await rapier(), { origin, cache }, reads, row.hash); placeCell(row); ready.push(row.instance); }
|
|
160
|
+
try { await readPackProduct(row.slug, build, await rapier(), { origin, cache }, reads, row.hash, catalogue); placeCell(row); ready.push(row.instance); }
|
|
158
161
|
catch (error) { log({ at: 'placement.refused', instance: row.instance, slug: row.slug, error: String(error) }); }
|
|
159
162
|
}
|
|
160
163
|
return ready.length === 0 ? [] : world.openCells(ready);
|
|
@@ -10,6 +10,9 @@ import type { Rapier } from '@wildshard/engine/physics/rapier';
|
|
|
10
10
|
import type { HeadlessRuntimeInput } from '../headlessRuntime';
|
|
11
11
|
import type { GridCollisionStrip } from '@wildshard/engine/game/grid/gridCollision';
|
|
12
12
|
import { readGridCollisionPack, readServerProduct, type ServerRead } from '../standalone/serverProduct';
|
|
13
|
+
import type { ReleaseFile } from '../../../shared/host/releaseRows';
|
|
14
|
+
import { readPlatformItemCatalogue, type PlatformItemCatalogue } from '@wildshard/engine/game/loot/platformCatalogue';
|
|
15
|
+
import { admitLedgerRewards, type LedgerCatalogueItem } from '@wildshard/engine/game/ledger';
|
|
13
16
|
|
|
14
17
|
/** What a reader counts, so a boot can say where its bytes came from. */
|
|
15
18
|
export interface PackReads { fetched: number; fetchedBytes: number; cached: number; refused: number }
|
|
@@ -63,6 +66,16 @@ export function readPackGrid(build: string, options: PackReaderOptions, reads: P
|
|
|
63
66
|
return readGridCollisionPack(new URL('shards/', options.origin.endsWith('/') ? options.origin : `${options.origin}/`).href, build, packRead(options, reads));
|
|
64
67
|
}
|
|
65
68
|
/** One shard's server inputs, through its build's book, or for a placed slug the book lacks, the cook's index of `hash` (SA47). */
|
|
66
|
-
export function readPackProduct(slug: string, build: string, rapier: Rapier, options: PackReaderOptions, reads: PackReads, hash?: string): Promise<HeadlessRuntimeInput> {
|
|
67
|
-
|
|
69
|
+
export async function readPackProduct(slug: string, build: string, rapier: Rapier, options: PackReaderOptions, reads: PackReads, hash?: string, catalogue: readonly LedgerCatalogueItem[] = []): Promise<HeadlessRuntimeInput> {
|
|
70
|
+
const input = await readServerProduct(new URL(`shards/${slug}/`, options.origin.endsWith('/') ? options.origin : `${options.origin}/`).href, () => build, packRead(options, reads), rapier, undefined, hash);
|
|
71
|
+
admitLedgerRewards(input.shard.ledger, catalogue);
|
|
72
|
+
return { ...input, catalogue };
|
|
73
|
+
}
|
|
74
|
+
/** Q37: the signed release selects these bytes; an old release has no catalogue grants. */
|
|
75
|
+
export async function readReleaseItems(reference: ReleaseFile['items'], options: PackReaderOptions, reads: PackReads): Promise<PlatformItemCatalogue['items']> {
|
|
76
|
+
if (reference === undefined) return [];
|
|
77
|
+
const root = options.origin.endsWith('/') ? options.origin : `${options.origin}/`;
|
|
78
|
+
const body = await packRead(options, reads)(new URL(reference.path, root), reference.path, reference.sha256);
|
|
79
|
+
if (body.byteLength !== reference.bytes) throw new Error('Item catalogue byte count mismatch');
|
|
80
|
+
return readPlatformItemCatalogue(JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(body))).items;
|
|
68
81
|
}
|
|
@@ -50,7 +50,7 @@ export class PlayerStore {
|
|
|
50
50
|
}
|
|
51
51
|
/** This player's fact ledger on this shard. */
|
|
52
52
|
facts(input: HeadlessRuntimeInput, instance: string): RuntimeFacts {
|
|
53
|
-
this.ledger ??= createQuestLedger(this.saves, input.shard, instance);
|
|
53
|
+
this.ledger ??= createQuestLedger(this.saves, input.shard, instance, input.catalogue);
|
|
54
54
|
return this.ledger;
|
|
55
55
|
}
|
|
56
56
|
/** Every document held, as its text. */
|
|
@@ -16,7 +16,6 @@ import { HEADLESS_ARENA } from '@wildshard/engine/game/boss/headlessArenaViews';
|
|
|
16
16
|
import type { NativeSweptMeleeInput } from '@wildshard/engine/game/plugin/nativeSwept';
|
|
17
17
|
import { installPortableMath } from '@wildshard/engine/core/portableMath';
|
|
18
18
|
import { createSimHost, type SimHost, type SimHostPorts, type SimLevel, type SimTickCommand } from '@wildshard/engine/sim';
|
|
19
|
-
import { leadPlayer } from '@wildshard/engine/sim/leadPlayer';
|
|
20
19
|
import { shardRows } from '@wildshard/engine/sim/shardRows';
|
|
21
20
|
import type { NetCommand } from '@wildshard/wire/netCommand';
|
|
22
21
|
import type { NetTickAct } from '@wildshard/engine/net/acts';
|
|
@@ -38,12 +37,16 @@ import type { ShardProduct } from '@wildshard/engine/game/shardfile/shardProduct
|
|
|
38
37
|
import { prepareProductRuntimePlan } from '@wildshard/engine/game/shardfile/nativePlan';
|
|
39
38
|
import { holdPageState, type RuntimeStateValue } from '@wildshard/engine/game/shardfile/runtimeState';
|
|
40
39
|
import type { NativeAssemblyPorts } from '@wildshard/engine/game/shardfile/nativeAssemblyInput';
|
|
40
|
+
import type { LedgerCatalogueItem } from '@wildshard/engine/game/ledger';
|
|
41
|
+
import { installCellHome } from '@wildshard/engine/game/grid/cellHome';
|
|
41
42
|
|
|
42
43
|
/** The same admitted bytes and native physics implementation used by the ordinary headless worker. */
|
|
43
44
|
export interface HeadlessRuntimePreparation { shard: Shardfile; assets: ReadonlyMap<string, Uint8Array>; rapier: Rapier; readonly product: ShardProduct }
|
|
44
45
|
/** Build workers carry verified native sections before any output exists.
|
|
45
46
|
* Existing native callers may instead supply or explicitly load their built product. */
|
|
46
|
-
export type HeadlessRuntimeInput = Omit<HeadlessRuntimePreparation, 'product'> & { readonly product?: ShardProduct; readonly sections?: ReadonlyMap<string, unknown
|
|
47
|
+
export type HeadlessRuntimeInput = Omit<HeadlessRuntimePreparation, 'product'> & { readonly product?: ShardProduct; readonly sections?: ReadonlyMap<string, unknown>;
|
|
48
|
+
/** Q37: the installed release's immutable trusted catalogue, never the shard's own data. */
|
|
49
|
+
readonly catalogue?: readonly LedgerCatalogueItem[] };
|
|
47
50
|
/** Current tick inputs and buffered effects; only a completed tick publishes them to the parent. */
|
|
48
51
|
/** What a page's save held, for a world's first boot: its quest flags and its declared fields, up before its fights install. */
|
|
49
52
|
export interface PageProgress { readonly flags: readonly string[]; readonly state: ReadonlyMap<string, RuntimeStateValue> }
|
|
@@ -234,7 +237,7 @@ export async function prepareNativeRuntime(provided: HeadlessRuntimeInput, room?
|
|
|
234
237
|
}
|
|
235
238
|
/** Install the selected plan into one fresh or strictly restored native host.
|
|
236
239
|
* A failed install disposes its world; installation may emit no gameplay effects. */
|
|
237
|
-
export async function createTrustedHeadlessResident(preparation: HeadlessRuntimeInput, snapshot?: string | Readonly<SimSnapshot | SimSnapshotBytes>, world?: { readonly room?: boolean; readonly near?: NearColliders; readonly page?: PageProgress }): Promise<TrustedHeadlessResident> {
|
|
240
|
+
export async function createTrustedHeadlessResident(preparation: HeadlessRuntimeInput, snapshot?: string | Readonly<SimSnapshot | SimSnapshotBytes>, world?: { readonly room?: boolean; readonly grid?: boolean; readonly near?: NearColliders; readonly page?: PageProgress }): Promise<TrustedHeadlessResident> {
|
|
238
241
|
// The roster rolls its herds while this installs, so a room opened afterwards is too late: a save from a native-Math boot
|
|
239
242
|
// would hold recipes its restore on the portable table can't reproduce.
|
|
240
243
|
installPortableMath();
|
|
@@ -247,18 +250,20 @@ export async function createTrustedHeadlessResident(preparation: HeadlessRuntime
|
|
|
247
250
|
const otherCommands = new Map<string, readonly HeadlessCommand[]>();
|
|
248
251
|
const context: HeadlessRuntimeInstallation = { combat, ...(world?.room === true ? { room: true } : {}), restoring: saved !== undefined, ...(saved === undefined ? {} : { snapshot: saved }), commands: () => commands, playerCommands: id => otherCommands.get(id) ?? [], emit: effect => { effects.push(effect); } };
|
|
249
252
|
const ports = { ...plan.ports, rapier: preparation.rapier };
|
|
253
|
+
const install = (target: SimHost): void => { plan.install(target, context); if (world?.grid === true) installCellHome(target); };
|
|
250
254
|
let installing: SimHost | undefined;
|
|
251
255
|
let host: SimHost;
|
|
252
256
|
try {
|
|
253
|
-
if (saved === undefined) { installing = createSimHost(plan.level, ports); if (world?.near !== undefined) { installing.physics.near = world.near; world.near.attach(installing.physics); } if (world?.page !== undefined) { for (const flag of world.page.flags) installing.flags.set(flag); holdPageState(installing, world.page.state); }
|
|
257
|
+
if (saved === undefined) { installing = createSimHost(plan.level, ports); if (world?.near !== undefined) { installing.physics.near = world.near; world.near.attach(installing.physics); } if (world?.page !== undefined) { for (const flag of world.page.flags) installing.flags.set(flag); holdPageState(installing, world.page.state); } install(installing); host = installing; }
|
|
254
258
|
else host = restoreSimHost(plan.level, ports, saved, fresh => {
|
|
255
|
-
installing = fresh; if (ports.heightAt !== undefined) fresh.setHeightQuery(ports.heightAt);
|
|
259
|
+
installing = fresh; if (ports.heightAt !== undefined) fresh.setHeightQuery(ports.heightAt); install(fresh);
|
|
256
260
|
});
|
|
257
261
|
if (effects.length > 0) throw new Error('Trusted runtime emitted gameplay effects during installation');
|
|
258
262
|
if (saved !== undefined && world?.near !== undefined) { host.physics.near = world.near; world.near.attach(host.physics); }
|
|
259
263
|
} catch (error) { installing?.dispose(); throw error; }
|
|
260
264
|
if (plan.economy !== undefined) installRoomLoot(host, plan.economy, context);
|
|
261
|
-
const lead =
|
|
265
|
+
const lead = host.players.get('actor.player');
|
|
266
|
+
if (lead === undefined) throw new RangeError('Unknown trusted runtime owner');
|
|
262
267
|
// ENG-18: a room catches its seats' falls itself (cellWorld's FallFloor); a resident alone catches its own, or nobody does.
|
|
263
268
|
const caught = world?.room === true ? null : residentFallNet(host, shardPlayArea(preparation.shard.manifest?.bounds, preparation.product), host.level.player.at);
|
|
264
269
|
if (caught !== null && preparation.product !== undefined) registerInstalled(host, 'fallFloor'); // SS3: the page's play area, read off its rows
|
|
@@ -7,7 +7,6 @@ import { removeChunkEdgeWalls } from '@wildshard/engine/physics/terrain';
|
|
|
7
7
|
import type { SimHost } from '@wildshard/engine/sim';
|
|
8
8
|
import type { PlayerSim } from '@wildshard/engine/sim/playerSim';
|
|
9
9
|
import { actRoutes } from '@wildshard/engine/sim/actRoutes';
|
|
10
|
-
import type { PlaceArea } from '@wildshard/engine/quest/lastPlace';
|
|
11
10
|
import { questBooks } from '@wildshard/engine/quest/players';
|
|
12
11
|
import { decodeSimSnapshot, type SimSnapshot } from '@wildshard/engine/sim/snapshot';
|
|
13
12
|
import { restoreSimHost } from '@wildshard/engine/sim/restore';
|
|
@@ -24,7 +23,10 @@ import { installPlayerOwned, type OwnedBook, type OwnedStores, type CreatureRewa
|
|
|
24
23
|
import { QUEST_OWNED } from '@wildshard/engine/game/quest/nativeComposition';
|
|
25
24
|
import { shardRows } from '@wildshard/engine/sim/shardRows';
|
|
26
25
|
import { createQuestLedger } from '@wildshard/engine/game/quest/ledger';
|
|
27
|
-
import {
|
|
26
|
+
import { admitLedgerRewards } from '@wildshard/engine/game/ledger';
|
|
27
|
+
import { installCellHome } from '@wildshard/engine/game/grid/cellHome';
|
|
28
|
+
import { serverDiscoveries, serverPlaces } from '@wildshard/engine/game/quest/serverPlaces';
|
|
29
|
+
import type { PlaceArea } from '@wildshard/engine/quest/lastPlace';
|
|
28
30
|
import { RESPAWN_NOW_ACT, STORY_ACT, UNSTUCK_ACT } from '@wildshard/engine/net/acts';
|
|
29
31
|
import { installServerChapters } from '@wildshard/engine/game/quest/serverChapters';
|
|
30
32
|
import { installServerDoors } from '@wildshard/engine/game/quest/serverDoors';
|
|
@@ -105,13 +107,14 @@ async function openDataCell(input: HeadlessRuntimeInput, snapshot: string | SimS
|
|
|
105
107
|
const kitOf = (sim: ShardfileSimulation): DeclaredKitItems | null => installDeclaredKitItems(sim.host, shard, sim.itemHooks);
|
|
106
108
|
if (snapshot === undefined) {
|
|
107
109
|
const fresh = createShardfileSim(shard, assets, ports), kit = kitOf(fresh);
|
|
110
|
+
installCellHome(fresh.host);
|
|
108
111
|
// SS3: a data shard's simulation builds its declared prop solids; a shard with none built has no server half to claim
|
|
109
112
|
if (fresh.colliders.size > 0) registerInstalled(fresh.host, 'collision');
|
|
110
113
|
return { host: fresh.host, sim: () => fresh, kit: () => kit, dispose: () => { fresh.dispose(); } };
|
|
111
114
|
}
|
|
112
115
|
const probe = createShardfileSim(shard, assets, ports), { level } = probe.host; probe.dispose();
|
|
113
116
|
const installed: { value?: ReturnType<typeof bindShardfileSim>; kit?: DeclaredKitItems | null } = {};
|
|
114
|
-
const host = restoreSimHost(level, { rapier }, typeof snapshot === 'string' ? decodeSimSnapshot(snapshot) : snapshot, restored => { installed.value = bindShardfileSim(restored, shard, assets, { ...ports, restoring: true }); installed.kit = kitOf(installed.value); if (installed.value.colliders.size > 0) registerInstalled(restored, 'collision'); });
|
|
117
|
+
const host = restoreSimHost(level, { rapier }, typeof snapshot === 'string' ? decodeSimSnapshot(snapshot) : snapshot, restored => { installed.value = bindShardfileSim(restored, shard, assets, { ...ports, restoring: true }); installed.kit = kitOf(installed.value); installCellHome(restored); if (installed.value.colliders.size > 0) registerInstalled(restored, 'collision'); });
|
|
115
118
|
return { host, sim: () => installed.value, kit: () => installed.kit ?? null, dispose: () => { (installed.value ?? { dispose: () => { host.dispose(); } }).dispose(); } };
|
|
116
119
|
}
|
|
117
120
|
|
|
@@ -135,18 +138,29 @@ function ownedOf(host: SimHost, input: HeadlessRuntimeInput, stores: OwnedStores
|
|
|
135
138
|
return installPlayerOwned(host, input.shard.identity.slug, sold ?? null, !shardRows(host).owned.has(QUEST_OWNED), stores, input.shard, profiles);
|
|
136
139
|
}
|
|
137
140
|
|
|
141
|
+
/** The radius a data cell's place takes when its manifest POI names none. */
|
|
142
|
+
const PLACE_RADIUS = 8;
|
|
143
|
+
/** Where a fallen player in a data cell comes back (TEMPLATE-E2E TC-E3, J361: "the last camp or the depot"): the product's
|
|
144
|
+
* published places, else the shard's own map POIs. A cell with neither respawns at the shard's spawn, as before. */
|
|
145
|
+
export async function dataCellPlaces(input: Pick<HeadlessRuntimeInput, 'shard' | 'product'>): Promise<readonly PlaceArea[]> {
|
|
146
|
+
const published = input.product === undefined ? [] : await serverPlaces(input.product);
|
|
147
|
+
if (published.length > 0) return published;
|
|
148
|
+
return (input.shard.manifest?.pois ?? []).filter(poi => poi.respawn !== false).map(poi => ({ id: poi.id, label: poi.name, x: poi.x, z: poi.z, r: poi.r ?? PLACE_RADIUS }));
|
|
149
|
+
}
|
|
150
|
+
|
|
138
151
|
/** Whether this output runs on the trusted headless owner. */
|
|
139
152
|
export const nativeCell = (input: HeadlessRuntimeInput): boolean => input.product !== undefined && (hasNativeAssembly(input.product) || input.product.has('sim/runtime-plan'));
|
|
140
153
|
|
|
141
154
|
/** Open `cell`'s world from `input`, at `snapshot` if there is one. */
|
|
142
155
|
export async function openCellWorld(cell: Pick<GridCell, 'instance'>, input: HeadlessRuntimeInput, snapshot: string | SimSnapshot | undefined, options: CellWorldOptions, refused?: SimSnapshot): Promise<CellWorld> {
|
|
156
|
+
admitLedgerRewards(input.shard.ledger, input.catalogue ?? []);
|
|
143
157
|
const declared = new Set(input.shard.ledger.map(row => row.fact)), placed = { id: cell.instance, shard: input.shard.identity.slug }, { facts, lone } = options;
|
|
144
|
-
const ledger = facts === undefined ? createQuestLedger(options.saves, input.shard, cell.instance) : null;
|
|
158
|
+
const ledger = facts === undefined ? createQuestLedger(options.saves, input.shard, cell.instance, input.catalogue) : null;
|
|
145
159
|
const fact: CellWorld['fact'] = (name, entity, player) => !declared.has(name) ? null : ledger === null ? facts?.(name, entity, player, input) ?? null : ledger(name, entity);
|
|
146
160
|
if (nativeCell(input)) {
|
|
147
161
|
// J68: a native assembly keeps its ground whole and its solids as data. A saved world holds none of them, so a throwaway fresh one lists them.
|
|
148
162
|
const near = options.wholeSolids !== true && input.product !== undefined && hasNativeAssembly(input.product) ? new NearColliders() : undefined;
|
|
149
|
-
const around = { room: true, ...(near === undefined ? {} : { near }) };
|
|
163
|
+
const around = { room: true, grid: true, ...(near === undefined ? {} : { near }) };
|
|
150
164
|
if (near !== undefined && snapshot !== undefined) (await bootTask('server:restore-collision-inventory', () => createTrustedHeadlessResident(input, undefined, around))).dispose();
|
|
151
165
|
// A world with no save of its own takes the page's: the flags and records its fights read as they install.
|
|
152
166
|
const seeded = snapshot === undefined && options.pageless !== true;
|
|
@@ -165,7 +179,7 @@ export async function openCellWorld(cell: Pick<GridCell, 'instance'>, input: Hea
|
|
|
165
179
|
}
|
|
166
180
|
const effects: HeadlessEffect[] = [], { host, dispose, sim, kit } = await bootTask(snapshot === undefined ? 'server:data-simulation-and-collision' : 'server:data-continuation-restore', () => openDataCell(input, snapshot, effects));
|
|
167
181
|
if (snapshot !== undefined) removeChunkEdgeWalls(host.physics); // GC36: a world saved while lone cells had walls
|
|
168
|
-
installRoomRespawn(host,
|
|
182
|
+
installRoomRespawn(host, await dataCellPlaces(input));
|
|
169
183
|
installDeclaredClimate(host, input.shard.rows);
|
|
170
184
|
bindDiscovery(host, input.product === undefined ? [] : await serverDiscoveries(input.product));
|
|
171
185
|
host.respawn.served = true; actRoutes(host).introLocks = true;
|
|
@@ -33,7 +33,7 @@ import { landedBy } from '@wildshard/engine/combat/damageBook';
|
|
|
33
33
|
import type { HeadlessRuntimeInput } from '../headlessRuntime';
|
|
34
34
|
import { actRoutes } from '@wildshard/engine/sim/actRoutes';
|
|
35
35
|
import { openCellWorld, type CellWorld, type CellWorldOptions } from './cellWorld';
|
|
36
|
-
import {
|
|
36
|
+
import { addVoidFloor, addZoneWalls, dropCellWalls, installRoadCombat, renewVoidFloor, ROAD } from './roadWorld';
|
|
37
37
|
import { netBuys, netWorldInput } from '../../../shared/host/standalone/netInput';
|
|
38
38
|
import { cellDocuments, CONTINUATION, ContinuationSlots, SITE, siteDocuments, type SavedContinuation, type SavedSite } from './continuation';
|
|
39
39
|
import { ledgerFilings } from './ledgerFilings';
|
|
@@ -171,8 +171,11 @@ export class StandaloneGrid {
|
|
|
171
171
|
return world;
|
|
172
172
|
};
|
|
173
173
|
const strips = options.lone === true ? [] : await bootTask('server:road-collision-inputs', options.strips);
|
|
174
|
-
|
|
174
|
+
// ZE11 (J352): the session's home is the cell it opens in (a Shard select pick, a gate's zone entry or its save), else its slug's
|
|
175
|
+
const homeCell = site ?? home.instance;
|
|
176
|
+
const road = bootWork('server:road-physics-and-collision', () => StandaloneGrid.road(rapier, assembly.cells, strips, site === null ? candidate?.saved.road : undefined, arrival, options.refused, homeCell));
|
|
175
177
|
const grid: GridSimulation = new GridSimulation(assembly, { highway: { host: road, dispose: () => { road.dispose(); } }, maxResidents: options.residents ?? STANDALONE_RESIDENTS,
|
|
178
|
+
enterable: instance => options.lone === true || instance === homeCell,
|
|
176
179
|
load: async (cell, cached) => {
|
|
177
180
|
const world = await open(cell, cached);
|
|
178
181
|
holdStrips(world.host, strips.flatMap(strip => strip.duplicates.filter(row => row.instance === cell.instance).map(row => row.mesh)));
|
|
@@ -193,17 +196,20 @@ export class StandaloneGrid {
|
|
|
193
196
|
return server;
|
|
194
197
|
}
|
|
195
198
|
|
|
196
|
-
private static road(rapier: Rapier, cells: readonly GridCell[], strips: readonly GridCollisionStrip[], saved: string | undefined, arrival: Readonly<GridPoint> | undefined, refused: GridServerOptions['refused']): SimHost {
|
|
199
|
+
private static road(rapier: Rapier, cells: readonly GridCell[], strips: readonly GridCollisionStrip[], saved: string | undefined, arrival: Readonly<GridPoint> | undefined, refused: GridServerOptions['refused'], home: string): SimHost {
|
|
197
200
|
if (saved !== undefined) {
|
|
198
201
|
try {
|
|
199
202
|
const restored = restoreSimHost(ROAD, { rapier }, decodeSimSnapshot(saved)), player = sessionPlayer(restored);
|
|
200
203
|
if (renewVoidFloor(restored, cells, player.position, ROAD_SKIN)) player.motor.resetAt(player.position);
|
|
204
|
+
installRoadCombat(restored);
|
|
205
|
+
dropCellWalls(restored); addZoneWalls(restored, cells, home);
|
|
201
206
|
holdStrips(restored, strips.map(strip => strip.mesh));
|
|
202
207
|
return restored;
|
|
203
208
|
} catch (error) { refused?.(error); } // a road holds no progress but where the player stood
|
|
204
209
|
}
|
|
205
210
|
const road = createSimHost(ROAD, { rapier }), [x, y, z] = readableSnapshot(saved ?? '')?.players[0]?.position ?? [], stood = arrival ?? (x === undefined || y === undefined || z === undefined ? undefined : { x, y, z });
|
|
206
|
-
|
|
211
|
+
installRoadCombat(road);
|
|
212
|
+
addZoneWalls(road, cells, home);
|
|
207
213
|
addVoidFloor(road, cells);
|
|
208
214
|
holdStrips(road, strips.map(strip => strip.mesh));
|
|
209
215
|
const player = sessionPlayer(road);
|
|
@@ -267,8 +273,14 @@ export class StandaloneGrid {
|
|
|
267
273
|
}
|
|
268
274
|
/** A Developer's `?bossGod`, on the pipeline that now lands the blow, and a lair's script, whose contact wears no fight's tag. */
|
|
269
275
|
bossGod(): void { this.host.combat.playerRules(this.host.scope, { bossGod: true }); actRoutes(this.host).god = true; }
|
|
276
|
+
/** A golden camera's spectator (`HarnessStill`): from now on every creature in the world the player stands in holds where it is. */
|
|
277
|
+
still(): void { this.stilled = true; }
|
|
278
|
+
private stilled = false;
|
|
270
279
|
open(): void { this.rooms.open(); }
|
|
271
|
-
tick(): void {
|
|
280
|
+
tick(): void {
|
|
281
|
+
if (this.stilled) for (const actor of this.host.entities.values()) actor.harnessHold = true; // each tick: a creature that streams in later holds too
|
|
282
|
+
this.rooms.tick();
|
|
283
|
+
}
|
|
272
284
|
/** Resolves true when every write so far reached the real storage, and tells `held` which of its saves that makes good. */
|
|
273
285
|
private settle(held: readonly { settled: (durable: boolean) => void }[]): Promise<boolean> {
|
|
274
286
|
this.settling = this.settling.then(() => this.options.storage.settled()).then(durable => { for (const slots of held) slots.settled(durable); return durable; });
|
|
@@ -276,10 +288,12 @@ export class StandaloneGrid {
|
|
|
276
288
|
}
|
|
277
289
|
/** Save where the session stands. The document for that place first, then the site that names it. */
|
|
278
290
|
async save(): Promise<{ readonly tick: number; readonly durable: boolean }> {
|
|
291
|
+
// a world left for the road owes its capture until evicted: a save takes it, so a reload on the road keeps it
|
|
292
|
+
const owed = this.grid.flushOwed();
|
|
279
293
|
const site = this.grid.current(), { host } = this, { tick } = host.state, wire = capture(host), ledger = this.options.book.snapshot();
|
|
280
294
|
const cell = site === null ? undefined : this.slots(site);
|
|
281
295
|
const wrote = (cell?.write({ tick, snapshot: wire, ledger }) ?? true) && this.sites.write({ tick: ++this.saved, site, ...(site === null ? { road: wire, ledger } : {}) });
|
|
282
|
-
return { tick, durable: await this.settle(cell === undefined ? [this.sites] : [cell, this.sites]) && wrote };
|
|
296
|
+
return { tick, durable: await this.settle(cell === undefined ? [this.sites] : [cell, this.sites]) && wrote && owed };
|
|
283
297
|
}
|
|
284
298
|
dispose(): void { this.rooms.dispose(); this.room.dispose(); this.grid.dispose(); }
|
|
285
299
|
}
|
|
@@ -14,6 +14,9 @@ import type { GridCollisionStrip } from '@wildshard/engine/game/grid/gridCollisi
|
|
|
14
14
|
import { HOST_PROBE } from '@wildshard/engine/game/plugin/simulation';
|
|
15
15
|
import { installVoidFloor, voidFloorBoxes } from '@wildshard/engine/game/grid/voidFloor';
|
|
16
16
|
import { FALL_FLOOR } from './fallFloor';
|
|
17
|
+
import { installEntrySockets } from '@wildshard/engine/physics/entrySockets';
|
|
18
|
+
import { ReadinessWalls } from '@wildshard/engine/physics/readinessWalls';
|
|
19
|
+
import { walledCells, zoneWallEdges } from '@wildshard/engine/game/grid/zoneWalls';
|
|
17
20
|
|
|
18
21
|
/** Ground under the whole grid, far below the road's strips, and a player's pace on them. */
|
|
19
22
|
const ROAD_HALF_SIZE = 2000, ROAD_SPEED = 8;
|
|
@@ -42,6 +45,33 @@ export function addCellWalls(road: SimHost, cells: readonly (Pick<GridCell, 'ori
|
|
|
42
45
|
}
|
|
43
46
|
});
|
|
44
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* ZONE-ENTRY ZE11 (J352): the in-page server's road walls every cell but the session's home on the page's own lines (`zoneWallEdges`:
|
|
50
|
+
* the edge line, open only at each entryway's buffer, the gate 10 m in) and floors each buffer with its entry socket, so the feet
|
|
51
|
+
* reach a gate on the server's road as they do on the page, and no further. The home has only its 2 m hold. A restored road first loses the
|
|
52
|
+
* walls an older build saved (`dropCellWalls`); its platform-tagged pieces are renewed with its void floor (`renewVoidFloor`).
|
|
53
|
+
*/
|
|
54
|
+
export function addZoneWalls(road: SimHost, cells: readonly GridCell[], home: string): void {
|
|
55
|
+
const walled = walledCells({ cells }, { instance: home });
|
|
56
|
+
withOwner(road.scope, () => {
|
|
57
|
+
installEntrySockets(road.physics, road.scope, walled.map(cell => cell.origin));
|
|
58
|
+
new ReadinessWalls(road.physics, walled.flatMap(cell => zoneWallEdges(cell, { origin: { x: 0, z: 0 } })), road.scope);
|
|
59
|
+
});
|
|
60
|
+
// the home keeps the 2 m hold (`addCellWalls`): its crossing, 6 m out, takes a walker past it; but this server keeps one world, so
|
|
61
|
+
// after a reload on the road a walker who reaches the home before it loads stops there, never walking on under its hills
|
|
62
|
+
addCellWalls(road, cells.filter(cell => cell.instance === home));
|
|
63
|
+
}
|
|
64
|
+
/** ZE11: take out the 2 m plain walls (`addCellWalls`) a road saved by an older build holds: the only cuboids of that size. */
|
|
65
|
+
export function dropCellWalls(road: SimHost): number {
|
|
66
|
+
const { world } = road.physics, found: Collider[] = [];
|
|
67
|
+
world.forEachCollider(collider => {
|
|
68
|
+
if (tagOf(collider) !== undefined) return;
|
|
69
|
+
const half = collider.halfExtents?.();
|
|
70
|
+
if (half !== undefined && half !== null && Math.abs(half.y - WALL_HEIGHT) < 1e-3 && Math.abs(Math.min(half.x, half.z) - WALL / 2) < 1e-3) found.push(collider);
|
|
71
|
+
});
|
|
72
|
+
for (const collider of found) world.removeCollider(collider, false);
|
|
73
|
+
return found.length;
|
|
74
|
+
}
|
|
45
75
|
/** GC15 (3): take down the walls round these cells (on another worker, their entryways standing): the road crosses into them now. */
|
|
46
76
|
export function openCellWalls(road: SimHost, instances: readonly string[]): void {
|
|
47
77
|
const kept = walls.get(road);
|
|
@@ -85,12 +115,18 @@ export function renewVoidFloor(road: SimHost, cells: readonly Pick<GridCell, 'ce
|
|
|
85
115
|
export function buildStrips(host: SimHost, meshes: readonly GridCollisionStrip['mesh'][]): void {
|
|
86
116
|
withOwner(host.scope, () => { for (const mesh of meshes) stripCollider(host.physics, mesh); });
|
|
87
117
|
}
|
|
118
|
+
/** The road admits no ordinary damage, including scripted environmental hits.
|
|
119
|
+
* Terminal out-of-world falls retain CombatPipeline.fall's recovery path. */
|
|
120
|
+
export function installRoadCombat(road: SimHost): void {
|
|
121
|
+
road.events.answer('damage.admit', () => null, road.scope);
|
|
122
|
+
}
|
|
88
123
|
/**
|
|
89
124
|
* GC15: a dedicated worker's road, with nobody on it yet: every strip built, the void's floor round `placed` (SA34), and walls only round `walled`, the cells it can't hand a
|
|
90
125
|
* seat to (those on another worker: GC7's one line). Its lead seat is the room's to park.
|
|
91
126
|
*/
|
|
92
127
|
export function openRoad(rapier: Rapier, walled: readonly Pick<GridCell, 'origin'>[], strips: readonly GridCollisionStrip[], placed: readonly Pick<GridCell, 'cell'>[]): SimHost {
|
|
93
128
|
const road = createSimHost(ROAD, { rapier });
|
|
129
|
+
installRoadCombat(road);
|
|
94
130
|
addCellWalls(road, walled);
|
|
95
131
|
addVoidFloor(road, placed);
|
|
96
132
|
buildStrips(road, strips.map(strip => strip.mesh));
|
|
@@ -18,7 +18,7 @@ import type { GridPoint } from '@wildshard/engine/game/grid/assembly';
|
|
|
18
18
|
import type { GridCollisionStrip } from '@wildshard/engine/game/grid/gridCollision';
|
|
19
19
|
import type { HeadlessRuntimeInput } from '../headlessRuntime';
|
|
20
20
|
import { StandaloneGrid } from './gridServer';
|
|
21
|
-
import { isHarnessFlag, isHarnessGod, isHarnessHits, isHarnessJoin, isHarnessMove, isHarnessPlace } from '../../../shared/host/standalone/harnessPlace';
|
|
21
|
+
import { isHarnessFlag, isHarnessGod, isHarnessHits, isHarnessJoin, isHarnessMove, isHarnessPlace, isHarnessStill } from '../../../shared/host/standalone/harnessPlace';
|
|
22
22
|
import { WorkerLoopback } from '../../../shared/host/standalone/workerLoopback';
|
|
23
23
|
import { isDevColliders, isDevGround, swapDevBoxes, swapDevGround } from '@wildshard/engine/game/devColliders';
|
|
24
24
|
import { isDevRestart, withDevGameplay, type DevGameplay, type DevPlace, type DevRestarted } from '@wildshard/engine/game/devGameplay';
|
|
@@ -146,7 +146,7 @@ export function runStandaloneServer(options: StandaloneServerOptions): { dispose
|
|
|
146
146
|
if (live === undefined) return;
|
|
147
147
|
if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__ && isDevColliders(event.data)) swapDevBoxes(live.host.physics, live.host.scope, devBoxes, event.data.wildshardDevColliders, event.data.boxes);
|
|
148
148
|
else if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__ && isDevGround(event.data)) swapDevGround(live.host.physics, live.host.scope, devGround, event.data.wildshardDevGround, groundPorts);
|
|
149
|
-
else if (isHarnessJoin(event.data) && port !== undefined) live.join(event.data, new WorkerLoopback(port)); else if (isHarnessFlag(event.data)) live.raise(event.data.flag); else if (isHarnessMove(event.data)) live.place(event.data, event.data.move); else if (isHarnessPlace(event.data)) live.place(event.data); else if (isHarnessHits(event.data)) live.hardHits(event.data.hits); else if (isHarnessGod(event.data)) live.bossGod();
|
|
149
|
+
else if (isHarnessJoin(event.data) && port !== undefined) live.join(event.data, new WorkerLoopback(port)); else if (isHarnessFlag(event.data)) live.raise(event.data.flag); else if (isHarnessMove(event.data)) live.place(event.data, event.data.move); else if (isHarnessPlace(event.data)) live.place(event.data); else if (isHarnessHits(event.data)) live.hardHits(event.data.hits); else if (isHarnessGod(event.data)) live.bossGod(); else if (isHarnessStill(event.data)) live.still();
|
|
150
150
|
};
|
|
151
151
|
clock = new ServerClock({ now: diagnosticNow, wait: (ms, run) => { const timer = scope.timeout(ms, run); return () => { scope.cancelTimer(timer); }; },
|
|
152
152
|
step: () => { const live = grid; if (live === undefined) return; try { live.tick(); progress(live); } catch (error) { fail(error); } } });
|
|
@@ -17,6 +17,8 @@ export interface AnimalSimSpec {
|
|
|
17
17
|
export interface AnimalMotor {
|
|
18
18
|
move: (feet: Vector3, want: { x: number; y: number; z: number }, ignoreGround: boolean) => void;
|
|
19
19
|
dispose: () => void;
|
|
20
|
+
/** Stand the capsule at `feet` without a sweep (a revived body back at its spawn, TEMPLATE-E2E TC-E2). */
|
|
21
|
+
resetAt?: (feet: Vector3) => void;
|
|
20
22
|
}
|
|
21
23
|
/** Trusted collision-pose owner. It reads only the last published joints, never advances a body or pose.
|
|
22
24
|
* The installer snapshots/restores its publication history through the host adapter alongside this actor. */
|
|
@@ -174,6 +176,14 @@ export class AnimalSim {
|
|
|
174
176
|
get flying(): boolean { return this.flight !== null; }
|
|
175
177
|
get lockable(): boolean { return this.simSpec.lockable ?? this.flying; }
|
|
176
178
|
get lockRange(): number | undefined { return this.simSpec.flight?.lockRange; }
|
|
179
|
+
/** TEMPLATE-E2E TC-E2: a dead body stands again, whole (a data spawn's `respawn`); `place` it first. */
|
|
180
|
+
revive(): void {
|
|
181
|
+
if (this.alive) return;
|
|
182
|
+
this.alive = true; this.hp = this.maxHp; this.state = 'idle'; this.deathT = -1; this.lastHitT = -Infinity;
|
|
183
|
+
this.flinch = 0; this.flinchRoll = 0; this.flinchPitch = 0; this.stunT = 0; this.pushT = 0; this.brace = 0;
|
|
184
|
+
this.speed = 0; this.desiredSpeed = 0; this.strafe = 0; this.desiredStrafe = 0; this.attackT = -1;
|
|
185
|
+
this.impulseVelocity.set(0, 0, 0);
|
|
186
|
+
}
|
|
177
187
|
place(x: number, z: number, yaw: number, y?: number): void {
|
|
178
188
|
this.position.set(x, y ?? this.simPorts.heightAt(x, z), z);
|
|
179
189
|
const flight = this.simSpec.flight;
|
|
@@ -3,6 +3,7 @@ import { withOwner } from '../app/ownership';
|
|
|
3
3
|
import { CELL_ABOVE, CELL_BELOW, CHUNK_HALF } from '../core/config';
|
|
4
4
|
import type { Physics } from './Physics';
|
|
5
5
|
import { groups, queryGroups } from './groups';
|
|
6
|
+
import { tagCollider } from './surface';
|
|
6
7
|
|
|
7
8
|
const ORIGIN = { x: 0, y: 0, z: 0 };
|
|
8
9
|
interface Point { x: number; y: number; z: number }
|
|
@@ -12,9 +13,22 @@ export function installGridBorders(physics: Physics, scope: Scope, origin: Reado
|
|
|
12
13
|
if (scope.disposed) return;
|
|
13
14
|
const { R, world } = physics;
|
|
14
15
|
const halfHeight = (CELL_ABOVE + CELL_BELOW) / 2, y = origin.y + (CELL_ABOVE - CELL_BELOW) / 2;
|
|
16
|
+
const border = groups('BORDER'), near = (a: number, b: number): boolean => Math.abs(a - b) < .001;
|
|
15
17
|
withOwner(scope, () => {
|
|
16
18
|
for (const [dx, dz, hx, hz] of [[CHUNK_HALF + 0.5, 0, 0.5, CHUNK_HALF + 1], [-CHUNK_HALF - 0.5, 0, 0.5, CHUNK_HALF + 1], [0, CHUNK_HALF + 0.5, CHUNK_HALF + 1, 0.5], [0, -CHUNK_HALF - 0.5, CHUNK_HALF + 1, 0.5]] as const) {
|
|
17
|
-
|
|
19
|
+
// A restored world already carries its walls. Match their actual shape,
|
|
20
|
+
// rather than an in-memory handle from the physics world it replaced.
|
|
21
|
+
let installed = false;
|
|
22
|
+
world.forEachCollider(collider => {
|
|
23
|
+
if (collider.collisionGroups() !== border || collider.shapeType() !== R.ShapeType.Cuboid || collider.isSensor() || collider.parent() !== null) return;
|
|
24
|
+
const at = collider.translation(), half = collider.halfExtents(), rotation = collider.rotation();
|
|
25
|
+
if (half !== null && near(at.x, origin.x + dx) && near(at.y, y) && near(at.z, origin.z + dz)
|
|
26
|
+
&& near(half.x, hx) && near(half.y, halfHeight) && near(half.z, hz)
|
|
27
|
+
&& near(Math.abs(rotation.w), 1) && near(rotation.x, 0) && near(rotation.y, 0) && near(rotation.z, 0)) {
|
|
28
|
+
installed = true; tagCollider(collider, 'edge', 'grid.home');
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if (!installed) tagCollider(world.createCollider(R.ColliderDesc.cuboid(hx, halfHeight, hz).setTranslation(origin.x + dx, y, origin.z + dz).setCollisionGroups(border)), 'edge', 'grid.home');
|
|
18
32
|
}
|
|
19
33
|
});
|
|
20
34
|
}
|
|
@@ -8,10 +8,15 @@ import { PLATFORM_COLLIDER_OWNER } from './stripColliders';
|
|
|
8
8
|
|
|
9
9
|
/** Conservative native wall/handle allowance per four-sided cell, reserved before construction. */
|
|
10
10
|
export const TRANSFER_WALL_BYTES = 65_536;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Outgoing feet pass the >10 m target threshold and walk on over the cell's own strip (23.75 m wide) while the commit
|
|
13
|
+
* lands: a fixed step or two on the page's own law, a round trip when the server says when (ZONE-ENTRY ZE2; at 10.1 m
|
|
14
|
+
* the feet stood at the line for that round trip). They never pass this solid hold line before a durable commit.
|
|
15
|
+
*/
|
|
16
|
+
export const TRANSFER_EXIT_LIMIT = 20;
|
|
17
|
+
/** Incoming feet pass the <=6 m target threshold and walk on to 1 m short of the cell boundary in the highway frame
|
|
18
|
+
* while the commit lands (ZE2: at 5.9 m they stood at the line for the server's round trip). */
|
|
19
|
+
export const TRANSFER_ENTER_LIMIT = 1;
|
|
15
20
|
/** Cell centres in this physics frame; entry walls enclose highway destinations, exit walls enclose the active region. */
|
|
16
21
|
export interface TransferWallCell { readonly x: number; readonly z: number }
|
|
17
22
|
|
|
@@ -4,7 +4,6 @@ import { byteArray } from './snapshotPhysics';
|
|
|
4
4
|
import type { QuestBookSaved } from '../quest/players';
|
|
5
5
|
import type { SimHost, SimLevel, SimSlots, SimValue } from '../../../server/engine/sim';
|
|
6
6
|
import { SIM_API_VERSION } from './apiVersion';
|
|
7
|
-
import { leadPlayer } from './leadPlayer';
|
|
8
7
|
import type { PlayerSim } from '../../../server/engine/sim/playerSim';
|
|
9
8
|
import { SHOVE_TIME } from '../player/shove';
|
|
10
9
|
import type { DrivenMode } from '../player/modes';
|
|
@@ -160,7 +159,7 @@ function encode(value: unknown, host: SimHost, parents = new Set<object>()): Eve
|
|
|
160
159
|
if (value === null || typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string') return { kind: 'value', value };
|
|
161
160
|
if (typeof value !== 'object') throw new TypeError('Snapshot payload contains a callback or unsupported value');
|
|
162
161
|
for (const player of host.players.values()) {
|
|
163
|
-
if (value === player || player.isExternalObject(value)) return
|
|
162
|
+
if (value === player || player.isExternalObject(value)) return { kind: 'player', id: player.id };
|
|
164
163
|
if (value === player.position) return { kind: 'position', id: player.id };
|
|
165
164
|
if (value === player.health) return { kind: 'actor', id: player.id };
|
|
166
165
|
}
|
|
@@ -181,7 +180,7 @@ function decode(value: EventValue, host: SimHost): unknown {
|
|
|
181
180
|
switch (value.kind) {
|
|
182
181
|
case 'value': return value.value;
|
|
183
182
|
case 'undefined': return undefined;
|
|
184
|
-
case 'player': { const player =
|
|
183
|
+
case 'player': { const player = host.players.get(value.id ?? 'actor.player'); if (player === undefined) throw new RangeError(`Unknown snapshot player: ${value.id ?? ''}`); return player; }
|
|
185
184
|
case 'number': return value.value === 'nan' ? Number.NaN : value.value === 'infinity' ? Infinity : -Infinity;
|
|
186
185
|
case 'vector': {
|
|
187
186
|
if (value.value.length !== 3 || !value.value.every(Number.isFinite)) throw new RangeError('Invalid event vector');
|
|
@@ -406,9 +405,10 @@ export function restoreInstalledHost(host: SimHost, ports: { rapier: Rapier }, s
|
|
|
406
405
|
let replacement: Physics | null = null;
|
|
407
406
|
try {
|
|
408
407
|
install?.(host);
|
|
409
|
-
//
|
|
408
|
+
// Restores boot an owned actor.player host. Registry order cannot change that legacy identity.
|
|
409
|
+
// The installers ran for that owner; everyone else rejoins before their state lands.
|
|
410
410
|
for (const entry of saved.players.slice(1)) if (!host.players.has(entry.id)) host.addPlayer(entry.id);
|
|
411
|
-
if (saved.players[0]?.id !==
|
|
411
|
+
if (saved.players[0]?.id !== 'actor.player' || !sameIds(saved.players.map((entry) => entry.id), host.players.keys()) || !sameIds(saved.entities.map((entry) => entry.id), host.entities.keys())
|
|
412
412
|
|| !sameIds(saved.strikes.map((entry) => entry.id), host.strikes.keys()) || !sameIds(saved.adapters.map((entry) => entry.id), [...host.adapters].filter(([id, adapter]) => adapter.joined !== true || saved.adapters.some(entry => entry.id === id)).map(([id]) => id))
|
|
413
413
|
|| !sameIds(saved.quests.map((entry) => entry.id), host.quests.map((quest) => quest.def.id))
|
|
414
414
|
|| saved.players.some(invalidPlayer) || saved.boardColliders?.length === 0) throw new RangeError('Snapshot instance registrations do not match');
|
|
@@ -100,16 +100,23 @@ export class ResidencyAllocator {
|
|
|
100
100
|
private evictableCredit = 0;
|
|
101
101
|
|
|
102
102
|
private readonly playing: number;
|
|
103
|
+
/** GC13: the most two worlds may hold at once while one is built beside another (`canPrepareAlongside`'s caller) */
|
|
104
|
+
private readonly loading: number;
|
|
103
105
|
private generation = 0;
|
|
104
106
|
private evicting = false;
|
|
105
|
-
constructor(options: { playing?: number; memory?: MemoryAdmission } = {}) {
|
|
107
|
+
constructor(options: { playing?: number; loading?: number; memory?: MemoryAdmission } = {}) {
|
|
106
108
|
this.memory = options.memory ?? new MemoryAdmission();
|
|
107
109
|
this.playing = options.playing ?? CONTENT_CAPS.playing;
|
|
110
|
+
this.loading = options.loading ?? Math.max(CONTENT_CAPS.loading, this.playing);
|
|
108
111
|
if (!Number.isFinite(this.playing) || this.playing <= 0) throw new RangeError('Invalid residency envelope');
|
|
112
|
+
if (!Number.isFinite(this.loading) || this.loading < this.playing) throw new RangeError('Invalid residency loading envelope');
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
/** The playing envelope this allocator admits against (the tier's, else §3.2's). */
|
|
112
116
|
envelope(): number { return this.playing; }
|
|
117
|
+
/** GC13: the transient envelope a world built beside the kept one may reach (§3.2's loading cap; a phone's is its playing
|
|
118
|
+
* envelope, so the world left is released before the next is built). */
|
|
119
|
+
loadingEnvelope(): number { return this.loading; }
|
|
113
120
|
|
|
114
121
|
/** Admit a claim, or share one already held under the same id; null when it cannot fit even after eviction. */
|
|
115
122
|
reserve(claim: ResidencyClaim): ResidencyLease | null { return this.reserveClaim(claim, 0); }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZONE-ENTRY ZE8 (J352, Jake 2026-11-15: "it's gonna count down 5, 4, 3, 2, 1. If you back away, if you move away from it, it's
|
|
3
|
+
* gonna disappear. It's gonna reset the counter to 5"): the gate card's count. Feet in a walled cell's buffer start it at 5; it
|
|
4
|
+
* steps once a second; at 0 it fires that cell's zone entry, once. Feet out of the buffer hide it and reset it; back in starts
|
|
5
|
+
* at 5 again. No button: standing there is the yes. Pure, so the page and a test drive it the same way.
|
|
6
|
+
*/
|
|
7
|
+
/** The count a buffer starts at, in whole seconds. */
|
|
8
|
+
export const GATE_COUNT = 5;
|
|
9
|
+
|
|
10
|
+
/** What the card shows: the cell counted for and the number on it, or nothing. `fire` is set on the one step the count hits 0. */
|
|
11
|
+
export interface GateCountState { readonly cell: string | null; readonly count: number; readonly fire: string | null }
|
|
12
|
+
|
|
13
|
+
export class GateCount {
|
|
14
|
+
private cell: string | null = null;
|
|
15
|
+
private since = 0;
|
|
16
|
+
private fired = false;
|
|
17
|
+
|
|
18
|
+
/** One step: the buffer the feet stand in (a cell instance, or null) at `now` (ms). */
|
|
19
|
+
step(buffer: string | null, now: number): GateCountState {
|
|
20
|
+
if (buffer !== this.cell) { this.cell = buffer; this.since = now; this.fired = false; }
|
|
21
|
+
if (buffer === null) return { cell: null, count: GATE_COUNT, fire: null };
|
|
22
|
+
const count = Math.max(0, GATE_COUNT - Math.floor((now - this.since) / 1000));
|
|
23
|
+
const fire = count === 0 && !this.fired ? buffer : null;
|
|
24
|
+
if (fire !== null) this.fired = true;
|
|
25
|
+
return { cell: buffer, count, fire };
|
|
26
|
+
}
|
|
27
|
+
}
|