@wildshard/engine 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/budgets/shard-size-baseline.json +10 -4
- package/index.html +6 -4
- package/lint/engine-sides.json +21 -0
- package/lint/host-callback-syntax.mjs +2 -1
- package/lint/host-callbacks.mjs +3 -3
- package/lint/host-files.mjs +5 -4
- package/lint/no-base64.mjs +3 -1
- package/lint/ratchet.json +0 -68
- package/lint/ratchet.mjs +1 -4
- package/lint/shard-imports.mjs +6 -7
- package/lint/shard-source.d.mts +9 -0
- package/lint/shard-source.mjs +91 -0
- package/lint/shardfile-boundaries.mjs +10 -8
- package/lint/sim-closure.mjs +6 -3
- package/lint/wildshard-plugin.d.ts +4 -0
- package/lint/wildshard-plugin.js +22 -23
- package/package.json +25 -16
- package/scripts/agent-sync.mjs +27 -8
- package/scripts/app-build/appCook.ts +8 -2
- package/scripts/app-build/catalogue.ts +10 -7
- package/scripts/app-build/gen.ts +22 -2
- package/scripts/app-build/isolation.d.mts +10 -0
- package/scripts/app-build/isolation.mjs +47 -0
- package/scripts/app-build/outputProducts.d.mts +3 -0
- package/scripts/app-build/outputProducts.mjs +35 -0
- package/scripts/app-build/previousDeploy.d.mts +2 -0
- package/scripts/app-build/previousDeploy.mjs +10 -1
- package/scripts/app-build/serviceWorker.ts +10 -3
- package/scripts/app-build/splitOutput.mjs +4 -2
- package/scripts/app-build/standaloneOutput.d.mts +1 -1
- package/scripts/app-build/standaloneOutput.mjs +5 -3
- package/scripts/app-build/titlePreloads.d.mts +8 -0
- package/scripts/app-build/titlePreloads.mjs +69 -0
- package/scripts/app-build/worldMapAtlas.ts +10 -6
- package/scripts/app-build-pipeline.mjs +34 -3
- package/scripts/built-product.mjs +1 -1
- package/scripts/cell-mem-bench.mjs +81 -23
- package/scripts/check-custom-sections-zero.mjs +1 -1
- package/scripts/check-devserver.mjs +3 -1
- package/scripts/check-models.mjs +2 -0
- package/scripts/check-paths.allow.json +0 -115
- package/scripts/check-paths.mjs +2 -2
- package/scripts/check-platform-ratchets.mjs +2 -3
- package/scripts/chromium-keychain-check.mjs +4 -2
- package/scripts/chromium-keychain.d.mts +1 -1
- package/scripts/chromium-keychain.mjs +3 -1
- package/scripts/ci-static.sh +1 -1
- package/scripts/committed-fast-checks.mjs +0 -2
- package/scripts/content-sw-proof.mjs +2 -1
- package/scripts/cook-worker.mjs +9 -3
- package/scripts/cook.mjs +20 -3
- package/scripts/devices.d.mts +4 -0
- package/scripts/devices.mjs +39 -0
- package/scripts/devserver-client.d.mts +4 -2
- package/scripts/devserver-client.mjs +25 -8
- package/scripts/docs-inputs-proof.mjs +6 -6
- package/scripts/doctor-proof.mjs +1 -1
- package/scripts/e2e-faults.mjs +159 -0
- package/scripts/e7-voice-staging-proof.mjs +1 -1
- package/scripts/gate-related-tests.mjs +1 -1
- package/scripts/git-source-view.mjs +1 -1
- package/scripts/goldens/capture.mjs +17 -5
- package/scripts/grid-crossing-nightly.mjs +59 -0
- package/scripts/grid-crossing-qa.mjs +44 -0
- package/scripts/grid-crossing-ratchet.d.mts +6 -0
- package/scripts/grid-crossing-ratchet.mjs +52 -0
- package/scripts/grid-crossing-report.mjs +122 -0
- package/scripts/grid-crossing-stages.mjs +47 -0
- package/scripts/grid-crossing-tour.mjs +277 -0
- package/scripts/grid-crossing-walk-proof.mjs +136 -18
- package/scripts/host-ruler/roots.mjs +2 -2
- package/scripts/host-ruler.d.mts +91 -0
- package/scripts/host-ruler.mjs +565 -0
- package/scripts/live-prepush.py +3 -5
- package/scripts/loading-flow/benchmax.mjs +3 -1
- package/scripts/look-loop/test_look_loop.py +1 -38
- package/scripts/memory-proof.mjs +213 -0
- package/scripts/mmo-bots.mjs +8 -2
- package/scripts/net-lag-proof.mjs +219 -0
- package/scripts/night-market-kit-budget.mjs +2 -2
- package/scripts/offline-proof-rules.d.mts +5 -3
- package/scripts/offline-proof-rules.mjs +34 -7
- package/scripts/offline-proof.mjs +88 -18
- package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
- package/scripts/page-release/content.d.mts +9 -1
- package/scripts/page-release/content.mjs +131 -17
- package/scripts/page-release/flow.mjs +36 -10
- package/scripts/page-release/stamp-content.mjs +24 -0
- package/scripts/page-release.mjs +28 -6
- package/scripts/page-size.mjs +2 -1
- package/scripts/pin-packs.ts +1 -1
- package/scripts/pins.ts +4 -4
- package/scripts/precommit-checks.mjs +1 -7
- package/scripts/precommit-jobs.mjs +0 -1
- package/scripts/precommit-source.py +1 -9
- package/scripts/program-discovery.mjs +1 -1
- package/scripts/ring-cook.mjs +2 -1
- package/scripts/ring-step.ts +1 -1
- package/scripts/script-scenario-metrics.mjs +1 -1
- package/scripts/shard-output-content.d.mts +1 -1
- package/scripts/shard-output-content.mjs +2 -2
- package/scripts/shard-outputs.mjs +1 -1
- package/scripts/shard-public.mjs +1 -1
- package/scripts/shard-wire-meter.mjs +24 -9
- package/scripts/side-parity.mjs +4 -2
- package/scripts/standalone-smoke.mjs +8 -3
- package/scripts/tier-textures-proof.mjs +101 -0
- package/scripts/tier-textures.mjs +78 -0
- package/scripts/tile-bake-report.mjs +1 -1
- package/scripts/tile-bakes.mjs +1 -1
- package/scripts/title-assets.generated.json +2 -0
- package/scripts/tsconfig.json +1 -2
- package/scripts/vendor/basisu/LICENSE +201 -0
- package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
- package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
- package/scripts/vitest-push-guards.config.ts +1 -1
- package/scripts/vps/harden-apply.sh +4 -1
- package/scripts/vps/harden-prometheus.sh +176 -0
- package/scripts/vps/harden.sh +16 -0
- package/scripts/vps/rebuild.sh +18 -0
- package/scripts/vps/wildshard-config +84 -24
- package/scripts/worker-client-play.mjs +7 -2
- package/scripts/worker-client-proof.mjs +1 -1
- package/scripts/worker-client-slug.mjs +44 -0
- package/scripts/worktree-reap.mjs +5 -5
- package/src/.oxlintrc.json +3 -182
- package/src/client/app/entry.ts +47 -12
- package/src/client/engine/boot/bootCache.ts +2 -2
- package/src/client/engine/boot/bootTrace.ts +12 -4
- package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
- package/src/client/engine/boot/clearDownloads.ts +5 -2
- package/src/client/engine/boot/contentRead.ts +11 -0
- package/src/client/engine/boot/gpuFiles.ts +4 -2
- package/src/client/engine/boot/lastEnd.ts +99 -12
- package/src/client/engine/boot/parsedPages.ts +127 -58
- package/src/client/engine/boot/texturePack.ts +2 -2
- package/src/client/engine/build.d.ts +2 -0
- package/src/client/engine/core/Game.ts +18 -0
- package/src/client/engine/core/bootstrap.ts +4 -1
- package/src/client/engine/debug/probe.ts +18 -1
- package/src/client/engine/fx/LightPool.ts +41 -1
- package/src/client/engine/net/netPlayer.ts +19 -2
- package/src/client/engine/net/otherPlayers.ts +55 -8
- package/src/client/engine/net/predictor.ts +33 -9
- package/src/client/engine/net/redial.ts +29 -6
- package/src/client/engine/pwa/cacheNames.ts +58 -1
- package/src/client/engine/pwa/sw.js +53 -14
- package/src/client/engine/render/dataLook.ts +152 -40
- package/src/client/engine/render/families/detail.ts +89 -0
- package/src/client/engine/render/families/pbr.ts +7 -1
- package/src/client/engine/render/look.ts +6 -0
- package/src/client/engine/render/lookLight.ts +103 -11
- package/src/client/engine/render/lookRender.ts +105 -0
- package/src/client/engine/render/precompile.ts +20 -14
- package/src/client/engine/saves/indexed.ts +2 -2
- package/src/client/engine/telemetry/browserErrors.ts +28 -4
- package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
- package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
- package/src/client/engine/ui/debugOptions.ts +1 -1
- package/src/client/engine/ui/lookLightOption.ts +10 -6
- package/src/client/engine/ui/namePrompt.ts +7 -0
- package/src/client/game/boot/audio.generated.ts +114 -216
- package/src/client/game/boot/bytes.generated.ts +118 -238
- package/src/client/game/boot/placedSpawn.ts +35 -0
- package/src/client/game/boot/spawnDownload.ts +25 -6
- package/src/client/game/boot/versions.generated.ts +7 -7
- package/src/client/game/devScene/hook.ts +291 -0
- package/src/client/game/grid/area.ts +38 -0
- package/src/client/game/grid/cellLoading.ts +12 -2
- package/src/client/game/grid/live.ts +134 -12
- package/src/client/game/grid/liveSession.ts +47 -5
- package/src/client/game/grid/mapAtlas.ts +18 -4
- package/src/client/game/grid/menu.ts +4 -0
- package/src/client/game/grid/minimapBlend.ts +15 -5
- package/src/client/game/grid/neighbourPanels.ts +10 -1
- package/src/client/game/grid/oneWayIn.ts +5 -1
- package/src/client/game/grid/placedCards.ts +55 -0
- package/src/client/game/grid/placedCells.ts +233 -0
- package/src/client/game/grid/placedContent.ts +85 -0
- package/src/client/game/grid/prefetch.ts +9 -1
- package/src/client/game/grid/productInputs.ts +3 -1
- package/src/client/game/grid/productLeases.ts +4 -1
- package/src/client/game/grid/products.ts +8 -4
- package/src/client/game/grid/regionalRuntime.ts +6 -0
- package/src/client/game/grid/regionalWorld.ts +15 -2
- package/src/client/game/grid/roadCull.ts +44 -14
- package/src/client/game/grid/roadLook.ts +24 -15
- package/src/client/game/grid/roadLookPlatform.ts +4 -2
- package/src/client/game/grid/roadResources.ts +24 -0
- package/src/client/game/grid/roadSign.worker.ts +4 -3
- package/src/client/game/grid/roadSignPaint.ts +16 -5
- package/src/client/game/grid/roadSignPreparation.ts +4 -3
- package/src/client/game/grid/roadSignScale.ts +8 -0
- package/src/client/game/grid/roadTileBacking.ts +13 -3
- package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
- package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
- package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
- package/src/client/game/grid/roadTileWriter.ts +2 -1
- package/src/client/game/grid/screenReports.ts +39 -0
- package/src/client/game/grid/session.ts +29 -4
- package/src/client/game/grid/shardfileFar.ts +9 -3
- package/src/client/game/grid/softWallLook.ts +25 -8
- package/src/client/game/mainMenu.ts +6 -2
- package/src/client/game/plugin/context.ts +2 -1
- package/src/client/game/plugin/followedMovers.ts +7 -1
- package/src/client/game/quest/figures.ts +2 -0
- package/src/client/game/session/finish.ts +11 -1
- package/src/client/game/shard/titleList.ts +6 -2
- package/src/client/game/shardfile/assetCache.ts +4 -4
- package/src/client/game/shardfile/client.ts +4 -1
- package/src/client/game/shardfile/clientAssets.ts +9 -5
- package/src/client/game/shardfile/clientLibrary.ts +1 -1
- package/src/client/game/shardfile/clientWater.ts +51 -9
- package/src/client/game/shardfile/clientWorker.ts +21 -8
- package/src/client/game/shardfile/look.ts +8 -3
- package/src/client/game/shardfile/product.ts +34 -7
- package/src/client/game/shardfile/productChecks.ts +2 -2
- package/src/client/game/shardfile/productCost.ts +2 -2
- package/src/client/game/shardfile/readAsset.ts +2 -2
- package/src/client/game/shardfile/reflectingWater.ts +73 -0
- package/src/client/game/shardfile/seatGrace.ts +9 -0
- package/src/client/game/shardfile/skinPlayback.ts +1 -1
- package/src/client/game/systems/npc/figureRows.ts +9 -0
- package/src/client/game/titleDeck.ts +4 -3
- package/src/client/host/online/doctor.ts +2 -0
- package/src/client/host/online/linkScreens.ts +30 -4
- package/src/client/host/online/shell.ts +14 -0
- package/src/client/host/standalone/shell.ts +4 -0
- package/src/cook/game/astc6Encode.ts +55 -0
- package/src/cook/game/astc6Wasm.ts +176 -0
- package/src/cook/game/cookJob.ts +30 -6
- package/src/cook/game/cookWorker.ts +38 -11
- package/src/cook/game/entryTotals.ts +51 -24
- package/src/cook/game/shardCook.ts +67 -9
- package/src/cook/game/spawnParts.ts +33 -8
- package/src/cook/game/tierTextures.ts +349 -0
- package/src/e2e/smoke/game.ts +19 -14
- package/src/e2e/smoke/page-globals.d.ts +9 -8
- package/src/e2e/smoke/template2.spec.ts +8 -7
- package/src/server/engine/ai/bossContenders.ts +27 -3
- package/src/server/engine/ai/phases.ts +1 -1
- package/src/server/engine/entities/creatureRefill.ts +9 -2
- package/src/server/engine/net/ledgerBook.ts +2 -0
- package/src/server/engine/net/room.ts +15 -0
- package/src/server/engine/sim/respawn.ts +8 -0
- package/src/server/game/boss/arenaRoomEntry.ts +5 -1
- package/src/server/game/boss/arenaRoomNative.ts +2 -0
- package/src/server/game/boss/native.ts +2 -1
- package/src/server/game/boss/nativeWake.ts +9 -5
- package/src/server/game/boss/openArenaNative.ts +2 -2
- package/src/server/game/boss/openArenaRoom.ts +3 -1
- package/src/server/game/grid/room.ts +44 -3
- package/src/server/game/grid/simulation.ts +23 -0
- package/src/server/game/population/mixedRoster.ts +11 -3
- package/src/server/game/population/nativeBake.ts +8 -3
- package/src/server/game/population/nativeReturns.ts +6 -3
- package/src/server/game/population/roster.ts +5 -3
- package/src/server/game/quest/eliteDrops.ts +15 -4
- package/src/server/game/quest/nativeChapter.ts +1 -1
- package/src/server/game/quest/nativeComposition.ts +5 -1
- package/src/server/game/riding/nativeTaming.ts +10 -6
- package/src/server/game/riding/wildRefill.ts +3 -2
- package/src/server/game/shardfile/bossRow.ts +4 -2
- package/src/server/game/shardfile/homeKeeper.ts +4 -2
- package/src/server/host/bake/headlessWorker.ts +1 -1
- package/src/server/host/dedicated/cellHost.ts +98 -16
- package/src/server/host/dedicated/cellProtocol.ts +16 -1
- package/src/server/host/dedicated/cellWorker.ts +8 -5
- package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
- package/src/server/host/dedicated/gridCells.ts +15 -6
- package/src/server/host/dedicated/loopLag.ts +21 -0
- package/src/server/host/dedicated/main.ts +13 -5
- package/src/server/host/dedicated/packReader.ts +3 -3
- package/src/server/host/dedicated/placementFile.ts +4 -19
- package/src/server/host/dedicated/roadRoom.ts +34 -4
- package/src/server/host/dedicated/serverMetrics.ts +126 -0
- package/src/server/host/dedicated/socketPump.ts +21 -4
- package/src/server/host/dedicated/socketTransport.ts +2 -1
- package/src/server/host/dedicated/workerTable.ts +15 -4
- package/src/server/host/dedicated/world.ts +95 -8
- package/src/server/host/headless.ts +1 -1
- package/src/server/host/headlessRuntime.ts +1 -1
- package/src/server/host/standalone/roadWorld.ts +15 -3
- package/src/server/host/standalone/serverHost.ts +4 -1
- package/src/server/host/standalone/serverProduct.ts +41 -11
- package/src/shared/engine/ai/BossBrain.ts +8 -0
- package/src/shared/engine/net/deviceWord.ts +138 -0
- package/src/shared/engine/net/socketFrames.ts +7 -4
- package/src/shared/game/boss/wake.ts +6 -0
- package/src/shared/game/devColliders.ts +47 -0
- package/src/shared/game/eliteSystem.ts +8 -0
- package/src/shared/game/grid/allocator.ts +3 -0
- package/src/shared/game/grid/catalogueSlot.ts +7 -0
- package/src/shared/game/grid/placementRows.ts +36 -0
- package/src/shared/game/plugin/bossRecord.ts +3 -2
- package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
- package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
- package/src/shared/game/shardfile/packReads.ts +28 -3
- package/src/shared/game/shardfile/serverPack.ts +9 -0
- package/src/shared/game/systems/looks/trampleField.ts +2 -0
- package/src/shared/host/formatJsonSchema.ts +2 -2
- package/src/tsconfig.json +1 -27
- package/lint/host-reviews.json +0 -14
- package/lint/listed-view-code.json +0 -13
- package/lint/platform-pending-users.json +0 -2520
- package/lint/platform-pending-users.md +0 -18
- package/scripts/cell-mem/metrics-preload.mjs +0 -65
- package/scripts/check-closed-components.d.mts +0 -7
- package/scripts/check-closed-components.mjs +0 -87
- package/scripts/g571-hosts.d.mts +0 -3
- package/scripts/g571-hosts.mjs +0 -54
- package/scripts/host-ruler/register-migrate.mjs +0 -242
- package/scripts/listed-view-code.d.mts +0 -7
- package/scripts/listed-view-code.mjs +0 -93
- package/scripts/look-loop/fit-lut.py +0 -142
- package/scripts/look-loop/palette-delta.py +0 -183
- package/scripts/look-loop/regions/driftwood-isle.json +0 -25
- package/scripts/look-loop/regions/far-reach.json +0 -225
- package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
- package/scripts/look-loop/regions/pine-hollow.json +0 -22
- package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
- package/scripts/platform-chargebacks.d.mts +0 -9
- package/scripts/platform-chargebacks.mjs +0 -135
- package/scripts/shard-component-spans.d.mts +0 -15
- package/scripts/shard-component-spans.mjs +0 -18
- package/scripts/shard-components.d.mts +0 -16
- package/scripts/shard-components.mjs +0 -363
- package/scripts/shard-platform-hosts.d.mts +0 -2
- package/scripts/shard-platform-hosts.mjs +0 -93
- package/scripts/shard-platform-sections.d.mts +0 -2
- package/scripts/shard-platform-sections.mjs +0 -9
- package/scripts/shard-platform.d.mts +0 -76
- package/scripts/shard-platform.mjs +0 -1072
- package/src/.oxfmtrc.json +0 -48
- package/src/scripts/ask-new.sh +0 -29
- package/src/scripts/asks.mjs +0 -142
- package/src/scripts/herdr-prompt.sh +0 -34
- package/src/scripts/herdr-question-open.sh +0 -67
- package/src/scripts/md-wrap.mjs +0 -229
- /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
- /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
- /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
|
@@ -1,29 +1,89 @@
|
|
|
1
|
-
/** Private worker transfer format:
|
|
1
|
+
/** Private worker transfer format: binary tokens decoded in bounded steps, never a cloned
|
|
2
2
|
* descriptor tree. Admission still runs on the completely reconstructed tree. */
|
|
3
|
-
/** Native fatal UTF-8/JSON semantics, then
|
|
3
|
+
/** Native fatal UTF-8/JSON semantics, then the live parser's binary token transfer. */
|
|
4
4
|
export function parseJsonPages(bytes: Uint8Array): Uint8Array {
|
|
5
5
|
const value: unknown = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
|
|
6
6
|
return encodeParsedPages(value);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/* PZ23 (WILDSHARD-GAME-8G): binary tokens, so a number crosses as a float64 and the page thread makes no string for it
|
|
10
|
+
* (the JSON token pages before made a token array and two strings a number: ~400 bytes of garbage, ~211 MB in the
|
|
11
|
+
* first minute on Driftwood). Little-endian, after one version byte:
|
|
12
|
+
* OBJECT u32 count · ARRAY u32 count · NUMBER f64 · NULL · FALSE · TRUE
|
|
13
|
+
* UTF8 u8 last, u32 bytes, UTF-8 · UTF16 u8 last, u32 units, UTF-16 units (a string that is not well formed: a lone
|
|
14
|
+
* surrogate survives JSON.parse, never UTF-8). A string goes in parts of at most PART code units.
|
|
15
|
+
* REF u32 index: a short string sent before (at most SHORT code units: keys, names, kinds), the index-th such string in
|
|
16
|
+
* send order, so a repeated key costs the page thread no view and no decode. */
|
|
17
|
+
const VERSION = 0x57, OBJECT = 1, ARRAY = 2, UTF8 = 3, UTF16 = 4, NUMBER = 5, NULL = 6, FALSE = 7, TRUE = 8, REF = 9;
|
|
18
|
+
const SHORT = 64;
|
|
19
|
+
/** A string part's code units, and a decode step's bounds: at most STEP_TOKENS tokens or STEP_BYTES transfer bytes. */
|
|
20
|
+
const PART = 4096, STEP_TOKENS = 32, STEP_BYTES = 16_384;
|
|
11
21
|
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
class Writer {
|
|
23
|
+
bytes = new Uint8Array(65_536);
|
|
24
|
+
view = new DataView(this.bytes.buffer);
|
|
25
|
+
at = 0;
|
|
26
|
+
private readonly encoder = new TextEncoder();
|
|
27
|
+
private readonly short = new Map<string, number>();
|
|
28
|
+
room(n: number): void {
|
|
29
|
+
if (this.at + n <= this.bytes.length) return;
|
|
30
|
+
let size = this.bytes.length * 2;
|
|
31
|
+
while (size < this.at + n) size *= 2;
|
|
32
|
+
const next = new Uint8Array(size); next.set(this.bytes.subarray(0, this.at));
|
|
33
|
+
this.bytes = next; this.view = new DataView(next.buffer);
|
|
34
|
+
}
|
|
35
|
+
tag(tag: number): void { this.room(1); this.bytes[this.at++] = tag; }
|
|
36
|
+
count(tag: number, n: number): void { this.room(5); this.bytes[this.at] = tag; this.view.setUint32(this.at + 1, n, true); this.at += 5; }
|
|
37
|
+
number(value: number): void { this.room(9); this.bytes[this.at] = NUMBER; this.view.setFloat64(this.at + 1, value, true); this.at += 9; }
|
|
38
|
+
string(value: string): void {
|
|
39
|
+
if (value.length <= SHORT) {
|
|
40
|
+
const index = this.short.get(value);
|
|
41
|
+
if (index !== undefined) { this.count(REF, index); return; }
|
|
42
|
+
this.short.set(value, this.short.size);
|
|
43
|
+
}
|
|
44
|
+
// in a Unicode-mode class a whole pair is one code point, so only a lone surrogate matches
|
|
45
|
+
const utf8 = !/[\uD800-\uDFFF]/u.test(value);
|
|
46
|
+
if (value.length === 0) { this.part(UTF8, 1, 0); return; }
|
|
47
|
+
for (let from = 0; from < value.length;) {
|
|
48
|
+
let to = Math.min(value.length, from + PART);
|
|
49
|
+
// never split a surrogate pair across UTF-8 parts
|
|
50
|
+
if (utf8 && to < value.length && (value.codePointAt(to - 1) ?? 0) > 0xffff) to--;
|
|
51
|
+
const last = to >= value.length ? 1 : 0;
|
|
52
|
+
if (utf8) {
|
|
53
|
+
this.room(6 + (to - from) * 3);
|
|
54
|
+
const { written } = this.encoder.encodeInto(value.slice(from, to), this.bytes.subarray(this.at + 6));
|
|
55
|
+
this.part(UTF8, last, written); this.at += written;
|
|
56
|
+
} else {
|
|
57
|
+
this.room(6 + (to - from) * 2);
|
|
58
|
+
this.part(UTF16, last, to - from);
|
|
59
|
+
// oxlint-disable-next-line unicorn/prefer-code-point -- UTF-16 units, not code points: a lone surrogate crosses as it is
|
|
60
|
+
for (let i = from; i < to; i++, this.at += 2) this.view.setUint16(this.at, value.charCodeAt(i), true);
|
|
61
|
+
}
|
|
62
|
+
from = to;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** A string part's head; its body follows at `at`. */
|
|
66
|
+
private part(tag: number, last: number, length: number): void {
|
|
67
|
+
this.room(6); this.bytes[this.at] = tag; this.bytes[this.at + 1] = last; this.view.setUint32(this.at + 2, length, true); this.at += 6;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Called only on the worker's native JSON.parse result. */
|
|
72
|
+
export function encodeParsedPages(input: unknown): Uint8Array {
|
|
73
|
+
const out = new Writer(), pending: unknown[] = [input];
|
|
74
|
+
out.tag(VERSION);
|
|
14
75
|
while (pending.length > 0) {
|
|
15
76
|
const value = pending.pop();
|
|
16
|
-
if (typeof value === 'string')
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
else if (value === null || typeof value === 'boolean') yield ['v', value];
|
|
77
|
+
if (typeof value === 'string') out.string(value);
|
|
78
|
+
else if (typeof value === 'number') out.number(value);
|
|
79
|
+
else if (value === null) out.tag(NULL);
|
|
80
|
+
else if (typeof value === 'boolean') out.tag(value ? TRUE : FALSE);
|
|
21
81
|
else if (Array.isArray(value)) {
|
|
22
|
-
|
|
82
|
+
out.count(ARRAY, value.length);
|
|
23
83
|
for (let at = value.length - 1; at >= 0; at--) pending.push(value[at]);
|
|
24
84
|
} else if (typeof value === 'object') {
|
|
25
85
|
const entries = Object.entries(value);
|
|
26
|
-
|
|
86
|
+
out.count(OBJECT, entries.length);
|
|
27
87
|
for (let at = entries.length - 1; at >= 0; at--) {
|
|
28
88
|
const entry = entries[at];
|
|
29
89
|
if (entry === undefined) throw new Error('Missing parsed entry');
|
|
@@ -31,38 +91,21 @@ function* tokens(input: unknown): Generator<Token> {
|
|
|
31
91
|
}
|
|
32
92
|
} else throw new TypeError('Invalid parsed value');
|
|
33
93
|
}
|
|
94
|
+
return out.bytes.slice(0, out.at);
|
|
34
95
|
}
|
|
35
96
|
|
|
36
|
-
|
|
37
|
-
export function encodeParsedPages(value: unknown): Uint8Array {
|
|
38
|
-
const encoder = new TextEncoder(), pages: Uint8Array[] = [];
|
|
39
|
-
let page: string[] = [], characters = 0, bytes = 0;
|
|
40
|
-
const flush = (): void => {
|
|
41
|
-
if (page.length === 0) return;
|
|
42
|
-
const encoded = encoder.encode(`[${page.join(',')}]`);
|
|
43
|
-
pages.push(encoded); bytes += 4 + encoded.length; page = []; characters = 0;
|
|
44
|
-
};
|
|
45
|
-
for (const token of tokens(value)) {
|
|
46
|
-
const text = JSON.stringify(token);
|
|
47
|
-
if (page.length >= 32 || characters + text.length > 4096) flush();
|
|
48
|
-
page.push(text); characters += text.length + 1;
|
|
49
|
-
}
|
|
50
|
-
flush();
|
|
51
|
-
const output = new Uint8Array(bytes), view = new DataView(output.buffer);
|
|
52
|
-
let at = 0;
|
|
53
|
-
for (const part of pages) { view.setUint32(at, part.length, true); output.set(part, at + 4); at += 4 + part.length; }
|
|
54
|
-
return output;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
type Frame = {readonly value: unknown[]; remaining: number}
|
|
97
|
+
type Frame = {readonly value: unknown[]; remaining: number; next: number}
|
|
58
98
|
| {readonly value: Record<string, unknown>; remaining: number; key: string | undefined};
|
|
59
99
|
|
|
60
|
-
/** Yield
|
|
100
|
+
/** Yield before every bounded decode step (at most 32 tokens or 16 KiB of transfer) and once at the end.
|
|
61
101
|
* Nothing caller-visible is published until the entire transfer is checked. */
|
|
62
102
|
export async function decodeParsedPages(bytes: Uint8Array, pause: () => Promise<void>): Promise<unknown> {
|
|
63
|
-
|
|
103
|
+
// ignoreBOM: each part is decoded alone, and a string may start with U+FEFF
|
|
104
|
+
const frames: Frame[] = [], decoder = new TextDecoder('utf-8', {fatal: true, ignoreBOM: true});
|
|
105
|
+
let slots = 0;
|
|
64
106
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
65
107
|
let root: unknown, hasRoot = false, string: string | undefined;
|
|
108
|
+
const short: string[] = [];
|
|
66
109
|
const put = (value: unknown): void => {
|
|
67
110
|
const frame = frames.at(-1);
|
|
68
111
|
if (frame === undefined) {
|
|
@@ -76,35 +119,61 @@ export async function decodeParsedPages(bytes: Uint8Array, pause: () => Promise<
|
|
|
76
119
|
if (Object.hasOwn(frame.value, frame.key)) throw new Error('Duplicate parsed key');
|
|
77
120
|
Object.defineProperty(frame.value, frame.key, {value, writable: true, enumerable: true, configurable: true});
|
|
78
121
|
frame.key = undefined; frame.remaining--;
|
|
79
|
-
} else { frame.value.
|
|
122
|
+
} else { frame.value[frame.next++] = value; frame.remaining--; }
|
|
80
123
|
};
|
|
81
124
|
const complete = (): void => { while (frames.at(-1)?.remaining === 0) frames.pop(); };
|
|
82
|
-
|
|
125
|
+
const need = (at: number, n: number): void => { if (n > bytes.length - at) throw new Error('Incomplete parsed token'); };
|
|
126
|
+
if (bytes.length === 0 || bytes[0] !== VERSION) throw new Error('Invalid parsed transfer');
|
|
127
|
+
for (let at = 1; at < bytes.length;) {
|
|
83
128
|
await pause();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (
|
|
129
|
+
const stepEnd = at + STEP_BYTES;
|
|
130
|
+
for (let tokens = 0; tokens < STEP_TOKENS && at < bytes.length && at < stepEnd; tokens++) {
|
|
131
|
+
const tag = bytes[at++];
|
|
132
|
+
if (tag === UTF8 || tag === UTF16) {
|
|
133
|
+
need(at, 5);
|
|
134
|
+
const last = bytes[at], length = view.getUint32(at + 1, true); at += 5;
|
|
135
|
+
if ((last !== 0 && last !== 1) || length > (tag === UTF8 ? PART * 3 : PART)) throw new Error('Invalid parsed string');
|
|
136
|
+
const size = tag === UTF8 ? length : length * 2;
|
|
137
|
+
need(at, size);
|
|
138
|
+
let part = '';
|
|
139
|
+
if (tag === UTF8) part = decoder.decode(bytes.subarray(at, at + size));
|
|
140
|
+
// oxlint-disable-next-line unicorn/prefer-code-point -- UTF-16 units, not code points: a lone surrogate crosses as it is
|
|
141
|
+
else for (let i = 0; i < length; i++) part += String.fromCharCode(view.getUint16(at + i * 2, true));
|
|
142
|
+
at += size;
|
|
143
|
+
string = string === undefined ? part : string + part;
|
|
144
|
+
if (last === 1) { if (string.length <= SHORT) short.push(string); put(string); string = undefined; complete(); }
|
|
95
145
|
continue;
|
|
96
146
|
}
|
|
97
|
-
if (string !== undefined
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
147
|
+
if (string !== undefined) throw new Error('Incomplete parsed string');
|
|
148
|
+
if (tag === REF) {
|
|
149
|
+
need(at, 4);
|
|
150
|
+
const value = short[view.getUint32(at, true)]; at += 4;
|
|
151
|
+
if (value === undefined) throw new Error('Invalid parsed reference');
|
|
152
|
+
put(value); complete(); continue;
|
|
153
|
+
}
|
|
154
|
+
if (tag === OBJECT || tag === ARRAY) {
|
|
155
|
+
need(at, 4);
|
|
156
|
+
const count = view.getUint32(at, true); at += 4;
|
|
157
|
+
// every element or entry takes at least one more byte, so no count, nor all of them together, sizes past the transfer
|
|
158
|
+
slots += count;
|
|
159
|
+
if (count > bytes.length - at || slots > bytes.length) throw new Error('Invalid parsed count');
|
|
160
|
+
if (tag === ARRAY) {
|
|
161
|
+
// sized once: a pushed array regrows and leaves its old backing stores behind
|
|
162
|
+
// oxlint-disable-next-line unicorn/no-new-array -- a length: the decode fills every slot before anything is published
|
|
163
|
+
const container: unknown[] = new Array<unknown>(count); put(container);
|
|
164
|
+
if (count > 0) frames.push({value: container, remaining: count, next: 0});
|
|
102
165
|
} else {
|
|
103
166
|
const container: Record<string, unknown> = {}; put(container);
|
|
104
|
-
if (
|
|
167
|
+
if (count > 0) frames.push({value: container, remaining: count, key: undefined});
|
|
105
168
|
}
|
|
106
|
-
} else if (
|
|
107
|
-
|
|
169
|
+
} else if (tag === NUMBER) {
|
|
170
|
+
need(at, 8);
|
|
171
|
+
const value = view.getFloat64(at, true); at += 8;
|
|
172
|
+
if (Number.isNaN(value)) throw new Error('Invalid parsed number');
|
|
173
|
+
put(value);
|
|
174
|
+
} else if (tag === NULL) put(null);
|
|
175
|
+
else if (tag === FALSE) put(false);
|
|
176
|
+
else if (tag === TRUE) put(true);
|
|
108
177
|
else throw new Error('Invalid parsed token');
|
|
109
178
|
complete();
|
|
110
179
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assetCacheName } from '../pwa/cacheNames';
|
|
2
2
|
import { publishBootResponse } from './bootCache';
|
|
3
3
|
import { contentURL, isContentOrigin, pageURL } from './contentBase';
|
|
4
4
|
import type { Scope } from '../../../shared/engine/app/scope';
|
|
@@ -147,7 +147,7 @@ async function readBody(response: Response, expected: number, signal: AbortSigna
|
|
|
147
147
|
} catch (error) { void reader.cancel().catch(() => undefined); throw error; }
|
|
148
148
|
}
|
|
149
149
|
async function cachedPart(path: string): Promise<Response | undefined> {
|
|
150
|
-
try { return typeof caches === 'undefined' ? undefined : await (await caches.open(
|
|
150
|
+
try { return typeof caches === 'undefined' ? undefined : await (await caches.open(assetCacheName())).match(new URL(path, location.href).href, { ignoreVary: true }); }
|
|
151
151
|
catch { return undefined; } // Storage denial preserves the ordinary direct read.
|
|
152
152
|
}
|
|
153
153
|
const readers = new Set<TexturePackReads>();
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
/** Vite's compiled author-dev mode. Production/native builds always substitute false. */
|
|
2
2
|
declare const __DEVSERVER__: boolean;
|
|
3
|
+
/** SHARD-AUTHORING SA43: a `WILDSHARD_PREPARATION_ONLY` production build, the client `wildshard prepare` records in. */
|
|
4
|
+
declare const __PREPARATION_ONLY__: boolean;
|
|
@@ -1222,6 +1222,24 @@ export class Game {
|
|
|
1222
1222
|
}
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
|
+
/**
|
|
1226
|
+
* RP4: link the road (exterior) variants of an entered grid cell's content, as the boot's entry roots' are
|
|
1227
|
+
* (`warmDeferredEntryRoots`: nearest first, spaced by drawn frames, dropped once `owner` leaves). Past its sky layer's half
|
|
1228
|
+
* weight the road draws the cell with the page's own environment (none on a grid page), not the cell's PMREM: without
|
|
1229
|
+
* these, every program of the cell linked in one frame 2 m before its edge (Driftwood's west edge: about 17 links, 2.5 to
|
|
1230
|
+
* 4.3 s in Chromium). `roots` are not registered exterior roots (those are left out of the road's variants).
|
|
1231
|
+
*/
|
|
1232
|
+
async warmExteriorRoots(owner: Scope, roots: readonly THREE.Object3D[], current: () => boolean): Promise<void> {
|
|
1233
|
+
this.deferredEntryRoots.push({ owner, roots });
|
|
1234
|
+
if (this.frameCount === 0) return; // the boot's own in-play warm-up takes it (finish.ts)
|
|
1235
|
+
// one loop at a time: a second entry joins the queue behind the first, never a parallel warm-up in the same frames
|
|
1236
|
+
const run = this.exteriorWarm.catch(() => undefined).then(() => this.warmDeferredEntryRoots(current));
|
|
1237
|
+
this.exteriorWarm = run;
|
|
1238
|
+
await run;
|
|
1239
|
+
}
|
|
1240
|
+
/** RP4: the running road-variant warm-up (`warmExteriorRoots`), which the next one waits behind */
|
|
1241
|
+
private exteriorWarm: Promise<void> = Promise.resolve();
|
|
1242
|
+
|
|
1225
1243
|
/**
|
|
1226
1244
|
* D188 (G815): after an arrival's reveal, what it left (`rest`, gated out of live draws) is linked and first-drawn
|
|
1227
1245
|
* nearest the player first: the whole remaining program inventory under the live slice budget, then the rest's 1×1
|
|
@@ -5,6 +5,7 @@ import { app } from '../app/runtime';
|
|
|
5
5
|
import type * as THREE from 'three';
|
|
6
6
|
import { Game } from './Game';
|
|
7
7
|
import { applyLevelTier, TIER } from './tier';
|
|
8
|
+
import { noteDeviceGpu } from '../telemetry/deviceSnapshot';
|
|
8
9
|
import { readyWebGLContext } from './webglStartup';
|
|
9
10
|
import { recordBootCheckpoint } from '../boot/bootTrace';
|
|
10
11
|
import { issueBakedPrograms } from '../boot/earlyPrograms';
|
|
@@ -74,7 +75,9 @@ export async function bootstrap(step: StepRunner, level: LevelSpec, inputContext
|
|
|
74
75
|
progress.detail('Waiting for graphics to recover');
|
|
75
76
|
recordBootCheckpoint('renderer:waiting', { ...state });
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
+
const made = new Game(canvas, context, level);
|
|
79
|
+
noteDeviceGpu(context); // DEVICE-TELEMETRY DT1: the game's own context names its GPU for the device snapshot
|
|
80
|
+
return made;
|
|
78
81
|
});
|
|
79
82
|
game.app.clock.setCapture(harnessPins()?.capture ?? null);
|
|
80
83
|
issueBakedPrograms(game); // DL10 (Debug 'Early shader compile'): a queued list of the level's entry programs starts linking
|
|
@@ -123,8 +123,22 @@ export interface Fingerprint {
|
|
|
123
123
|
facade?: { multiDraw: boolean; batches: number; instances: number };
|
|
124
124
|
playMs: number; heapMB: number;
|
|
125
125
|
}
|
|
126
|
+
/** A door or gate panel the area declares: drawn, and whether its colliders stand. */
|
|
127
|
+
export interface ProbeAreaTarget { readonly panel: string; readonly visible: boolean; readonly solid: boolean }
|
|
128
|
+
/** T2E-1b: the area the player is in. On a grid page that is the current cell, not the page shell (`platform.grid`). */
|
|
129
|
+
export interface ProbeArea {
|
|
130
|
+
/** the area's shard slug */
|
|
131
|
+
readonly slug: string;
|
|
132
|
+
/** the grid cell's instance; null on a one-shard page */
|
|
133
|
+
readonly instance: string | null;
|
|
134
|
+
readonly targets: readonly ProbeAreaTarget[];
|
|
135
|
+
/** every quest flag the player holds in this area, sorted */
|
|
136
|
+
readonly flags: readonly string[];
|
|
137
|
+
}
|
|
126
138
|
export interface ProbeDeps {
|
|
127
139
|
health: () => number; quest: () => unknown;
|
|
140
|
+
/** The area the player is in; null between areas (a grid page's road). */
|
|
141
|
+
area: () => ProbeArea | null;
|
|
128
142
|
/** The retained level world used for leak counts when active frame worlds can be replaced and freed. */
|
|
129
143
|
leakPhysics?: World['physics'];
|
|
130
144
|
}
|
|
@@ -162,6 +176,8 @@ export interface EngineProbe<W extends ProbeWorld = ProbeWorld> {
|
|
|
162
176
|
hold: (animal: CombatTarget, on: boolean) => void; hits: { kind: string; amount: number }[]; kills: string[] };
|
|
163
177
|
arena: () => void;
|
|
164
178
|
state: () => GameplayState;
|
|
179
|
+
/** T2E-1b: the area the player is in, with its door targets and quest flags; null between areas. */
|
|
180
|
+
area: () => ProbeArea | null;
|
|
165
181
|
onResume: (fn: () => void) => void;
|
|
166
182
|
saves: Saves;
|
|
167
183
|
sounds: () => SoundLog;
|
|
@@ -510,6 +526,7 @@ export function installProbe<W extends ProbeWorld>(world: W, deps: ProbeDeps): E
|
|
|
510
526
|
creatures: world.animals.animals.map((a, i) => ({ id: `${a.kind}:${i}`, kind: a.kind, pos: point(a.position), hp: a.hp, brain: a.state })).sort((a, b) => a.id.localeCompare(b.id)),
|
|
511
527
|
quest: { adventure: deps.quest(), level: authoredQuestFlags(world) },
|
|
512
528
|
}),
|
|
529
|
+
area: () => deps.area(),
|
|
513
530
|
onResume: (fn) => { requireHarness(); resume = fn; }, saves,
|
|
514
531
|
sounds: () => { const log = { event: events, ambient: [...ambient].sort() }; events = {}; ambient.clear(); return log; },
|
|
515
532
|
used: () => labels.splice(0),
|
|
@@ -545,7 +562,7 @@ function scopedProbe<W extends ProbeWorld>(source: EngineProbe<W>, scope: Scope)
|
|
|
545
562
|
get app() { return read().app; },
|
|
546
563
|
fingerprint: () => read().fingerprint(), pose: (value) => read().pose(value),
|
|
547
564
|
walkLeg: (leg) => read().walkLeg(leg), arena: () => { read().arena(); },
|
|
548
|
-
state: () => read().state(), onResume: (fn) => { read().onResume(fn); },
|
|
565
|
+
state: () => read().state(), area: () => read().area(), onResume: (fn) => { read().onResume(fn); },
|
|
549
566
|
sounds: () => read().sounds(), used: () => read().used(), budgets: (poses) => read().budgets(poses),
|
|
550
567
|
leak: async () => {
|
|
551
568
|
if (live === undefined) {
|
|
@@ -57,6 +57,8 @@ export class LightPool {
|
|
|
57
57
|
private readonly yielding = new Set<THREE.PointLight>();
|
|
58
58
|
/** A borrowed light and the yielding light whose place in the scene it holds. */
|
|
59
59
|
private readonly lent = new Map<THREE.PointLight, THREE.PointLight>();
|
|
60
|
+
/** RP4: this nested pool's scene lights taken out of three's count (`adopt`), with the layer mask each gets back */
|
|
61
|
+
private readonly adopted = new Map<THREE.PointLight, number>();
|
|
60
62
|
|
|
61
63
|
private constructor(scene: THREE.Scene) {
|
|
62
64
|
this.group.name = 'light-pool';
|
|
@@ -87,7 +89,31 @@ export class LightPool {
|
|
|
87
89
|
if (page === this) throw new Error('A light pool cannot mirror into itself');
|
|
88
90
|
this.mirroredBy = page; page.sources.add(this);
|
|
89
91
|
for (const light of this.lights) light.layers.disableAll();
|
|
90
|
-
scope.onDispose(() => {
|
|
92
|
+
scope.onDispose(() => {
|
|
93
|
+
page.sources.delete(this); if (this.mirroredBy === page) this.mirroredBy = null; for (const light of this.lights) light.layers.enable(0);
|
|
94
|
+
for (const [light, mask] of this.adopted) light.layers.mask = mask;
|
|
95
|
+
this.adopted.clear();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** RP4: a mirrored pool also takes the plain point lights its content put under `root` (a region's site and signal
|
|
100
|
+
* lights, `new PointLight` in its own tree): each leaves three's light count and shows through the page's reserved
|
|
101
|
+
* lights as a pooled one does, while it and its ancestors show. Only as many as the reserve can show alongside this
|
|
102
|
+
* pool's own lights; a shadow caster, or one past that, stays counted as before, and so does one that finds the shared
|
|
103
|
+
* reserve full when it shows (another region's lights took it: `showMirrors` gives it back to three's count). Again on the same root takes only new
|
|
104
|
+
* ones. Returns how many it took. Sunscar's two counted whenever its region showed: arriving moved the page from 6 to
|
|
105
|
+
* 7 and 8 point lights and every lit program in view linked again (Chromium, 117 to 216 ms a link). */
|
|
106
|
+
adopt(root: THREE.Object3D): number {
|
|
107
|
+
const page = this.mirroredBy;
|
|
108
|
+
if (page === null) return 0;
|
|
109
|
+
let taken = 0;
|
|
110
|
+
for (const light of this.adopted.keys()) if (light.parent === null) this.adopted.delete(light); // gone with its content
|
|
111
|
+
root.traverse(object => {
|
|
112
|
+
if (!(object instanceof THREE.PointLight) || object.castShadow || object.layers.mask === 0 || this.adopted.has(object)) return;
|
|
113
|
+
if (this.lights.length + this.adopted.size >= page.reserved.length) return;
|
|
114
|
+
this.adopted.set(object, object.layers.mask); object.layers.disableAll(); taken++;
|
|
115
|
+
});
|
|
116
|
+
return taken;
|
|
91
117
|
}
|
|
92
118
|
|
|
93
119
|
/** Make `count` free dark lights now (counted, never mirrored), for content known to ask after the first render: a
|
|
@@ -166,6 +192,20 @@ export class LightPool {
|
|
|
166
192
|
// three posed the scene before this hook: the slot's world matrix is set here, from the light's
|
|
167
193
|
slot.position.setFromMatrixPosition(light.matrixWorld); slot.updateMatrixWorld();
|
|
168
194
|
}
|
|
195
|
+
for (const [light, mask] of source.adopted) {
|
|
196
|
+
if (light.intensity <= 0 || !shownUnder(light, this.group.parent)) continue;
|
|
197
|
+
const slot = this.reserved[next];
|
|
198
|
+
if (slot === undefined) {
|
|
199
|
+
// the reserve is shared by every shown region: one with no slot left is counted again, as before it was adopted
|
|
200
|
+
// (the count moves, every lit program links again, but it lights), never left dark
|
|
201
|
+
if (!this.warnedMirror) { this.warnedMirror = true; console.warn(`[LightPool] more shown region lights than the ${String(this.reserved.length)} reserved: an adopted light counts again`); }
|
|
202
|
+
light.layers.mask = mask; source.adopted.delete(light);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
next++;
|
|
206
|
+
slot.color.copy(light.color); slot.intensity = light.intensity; slot.distance = light.distance; slot.decay = light.decay;
|
|
207
|
+
slot.position.setFromMatrixPosition(light.matrixWorld); slot.updateMatrixWorld();
|
|
208
|
+
}
|
|
169
209
|
}
|
|
170
210
|
for (; next < this.reserved.length; next++) { const slot = this.reserved[next]; if (slot !== undefined) slot.intensity = 0; }
|
|
171
211
|
}
|
|
@@ -151,6 +151,16 @@ export class NetPlayer implements PlayerLink {
|
|
|
151
151
|
get heldSlot(): number { return this.held; }
|
|
152
152
|
/** The server has put this body somewhere: a frame has been heard. */
|
|
153
153
|
get joined(): boolean { return this.seen !== null; }
|
|
154
|
+
/** OFFLINE OF10 (J298, Jake 2026-11-12: "do a very limited amount of client-side emulation"): a world page that opened without
|
|
155
|
+
* its seat (OF9) plays its input on the predictor alone until the ring is full (PREDICTION_RING, about 1 s), then holds. Nothing
|
|
156
|
+
* goes on the wire: these moves are the page's own, and the seat's first frame takes the server's place, gliding to it when it
|
|
157
|
+
* is near (under PREDICTION_SNAP). A rejoin or a crossing still holds still until its first frame. */
|
|
158
|
+
private unseated = false;
|
|
159
|
+
private unseatedSeq = 0;
|
|
160
|
+
/** OF10: play unseated until the first frame (a page that has heard one is seated, and this does nothing). */
|
|
161
|
+
playUnseated(): void { if (this.seen === null) this.unseated = true; }
|
|
162
|
+
/** OF10: unseated, and the ring is spent: movement holds until the seat. */
|
|
163
|
+
get unseatedHeld(): boolean { return this.unseated && this.predictor.full; }
|
|
154
164
|
/** A death's authoritative pose is already reset on the server. Keep this page at the death until its overlay is dark. */
|
|
155
165
|
holdRespawn(): void { this.respawnHeld = true; }
|
|
156
166
|
/** Adopt the newest server pose under the dark, dropping commands from before the death. */
|
|
@@ -158,7 +168,8 @@ export class NetPlayer implements PlayerLink {
|
|
|
158
168
|
|
|
159
169
|
/** A fixed step. False, with nothing sent, before the first frame or when a full ring says the server stopped answering. */
|
|
160
170
|
step(input: PlayerWireInput): boolean {
|
|
161
|
-
if (this.respawnHeld || this.
|
|
171
|
+
if (this.respawnHeld || this.predictor.full) return false;
|
|
172
|
+
if (this.seen === null) return this.unseated && this.deviceMode !== 'paused' && this.stepUnseated(input);
|
|
162
173
|
if (!this.claimInputTick(0)) return false;
|
|
163
174
|
const armed = this.armed(input);
|
|
164
175
|
return this.sendCommand(armed, true, this.hooked(armed));
|
|
@@ -188,6 +199,12 @@ export class NetPlayer implements PlayerLink {
|
|
|
188
199
|
for (let at = 1; at < MAX_FIXED_STEPS && !this.predictor.full && this.claimInputTick(MAX_FIXED_STEPS); at++) this.sendCommand(input, false);
|
|
189
200
|
this.client.flush();
|
|
190
201
|
}
|
|
202
|
+
/** OF10: one step of the page's own, unsent, with a seq of its own; world actions wait for the link (the hold cards). */
|
|
203
|
+
private stepUnseated(input: PlayerWireInput): boolean {
|
|
204
|
+
const seq = this.unseatedSeq = (this.unseatedSeq % 0xffff) + 1;
|
|
205
|
+
this.world.poseFor(seq, false);
|
|
206
|
+
return this.predictor.step(quantiseCommand({ ...input, seq, viewTick: 0 }));
|
|
207
|
+
}
|
|
191
208
|
private claimInputTick(reserve: number): boolean {
|
|
192
209
|
if (this.deviceMode === 'frame') return true;
|
|
193
210
|
if (this.deviceMode === 'paused') return false;
|
|
@@ -234,7 +251,7 @@ export class NetPlayer implements PlayerLink {
|
|
|
234
251
|
this.world.frame(frame.tick, frame.lastSeq);
|
|
235
252
|
for (const event of this.heard.splice(0)) if (event.kind === 'mount') seat?.enter(event.mount); else seat?.leave();
|
|
236
253
|
const ridden = seat === null ? null : frame.ride;
|
|
237
|
-
if (first) { this.predictor.adopt(frame.lastSeq, frame.owner, frame.tick, ridden); return; }
|
|
254
|
+
if (first) { const glide = this.unseated; this.unseated = false; this.predictor.adopt(frame.lastSeq, frame.owner, frame.tick, ridden, glide); return; }
|
|
238
255
|
this.predictor.reconcile(frame.lastSeq, frame.owner, frame.tick, ridden);
|
|
239
256
|
const swung = PLAYER_CLASS.owner[LAST_SWING]?.value(frame.owner[LAST_SWING] ?? 0), held = PLAYER_CLASS.owner[HELD]?.value(frame.owner[HELD] ?? 0);
|
|
240
257
|
this.attacks.frame(frame.lastSeq, typeof swung === 'number' ? swung : 0);
|
|
@@ -14,7 +14,7 @@ import { RemoteStrike } from './remoteStrike';
|
|
|
14
14
|
import { NameTag, type NameTagShown } from './nameTag';
|
|
15
15
|
import { RemoteDeath, type DeathPhase } from './remoteDeath';
|
|
16
16
|
import { RemoteHurt, type HurtShown } from './remoteHurt';
|
|
17
|
-
import { HeldInHand } from './heldOnOthers';
|
|
17
|
+
import { HeldInHand, heldOnOthers } from './heldOnOthers';
|
|
18
18
|
import type { NetClient } from './client';
|
|
19
19
|
import { othersOnMap } from './othersOnMap';
|
|
20
20
|
import { talkerKey, voiceNear, type Talker } from './voiceNear';
|
|
@@ -169,8 +169,58 @@ class OtherBody {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/** Every other player's body, kept to the client's rows. */
|
|
172
|
+
/** A body leaving: the castaway's mesh and contact disc are shared by every body (userData.shared), so only its own are freed, its
|
|
173
|
+
* skeleton's bone texture with them. A sprite's geometry is three's own, shared by every sprite. Its held item, the kit's copy,
|
|
174
|
+
* is let go of first (`undress`). */
|
|
175
|
+
function freeBody(group: THREE.Object3D): void {
|
|
176
|
+
group.traverse(node => {
|
|
177
|
+
if (node instanceof THREE.SkinnedMesh) node.skeleton.dispose();
|
|
178
|
+
if (node instanceof THREE.Mesh) { const geometry = node.geometry as THREE.BufferGeometry; if (geometry.userData['shared'] !== true) geometry.dispose(); }
|
|
179
|
+
if (node instanceof THREE.Mesh || node instanceof THREE.Sprite) { for (const material of [node.material].flat() as THREE.Material[]) { if (material.userData['shared'] === true) continue; if (material instanceof THREE.SpriteMaterial) material.map?.dispose(); material.dispose(); } }
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** NET-LAG NL4: the warm body's depth under the world, out of every view; its slots tried for the kit's held items. */
|
|
184
|
+
const WARM_DEPTH = -1000, WARM_SLOTS = 16;
|
|
185
|
+
/**
|
|
186
|
+
* NET-LAG NL4 (Jake's 60 ms frames in Driftwood): the first other player to come into view linked its body's programs inside
|
|
187
|
+
* that frame, the castaway's skinned body, its contact disc, its Name and the held item in the world's light (the item's
|
|
188
|
+
* first-person program is another): 4 programs in a 200 ms frame, 20 in a 440 ms one, on desktop Chromium's Metal. One body
|
|
189
|
+
* of the same build is drawn from the start, under the world, never culled, so the boot's in-play warm-up links those
|
|
190
|
+
* programs paced and every body after it draws with programs already built (three keys a program by its material's settings,
|
|
191
|
+
* so a body's own deck materials share the warm deck's). It holds every slot of the kit lent now, and
|
|
192
|
+
* takes the new kit's items when a crossing lends one (the old copies are freed with their kit).
|
|
193
|
+
*/
|
|
194
|
+
class WarmBody {
|
|
195
|
+
readonly group = new THREE.Group();
|
|
196
|
+
private readonly hand: THREE.Object3D | null;
|
|
197
|
+
private readonly items = new THREE.Group();
|
|
198
|
+
private kit = -1;
|
|
199
|
+
constructor() {
|
|
200
|
+
this.group.name = 'other-player-warm'; this.group.position.y = WARM_DEPTH;
|
|
201
|
+
const model = castawayBody(), board = new BoardUnder();
|
|
202
|
+
board.deck.visible = true; // a rider's deck, shown here so its programs warm too
|
|
203
|
+
this.group.add(model.root, groundContact(), nameTag('warm'), board.deck);
|
|
204
|
+
this.hand = model.mounts.rightHand;
|
|
205
|
+
this.hand.add(this.items);
|
|
206
|
+
this.unculled();
|
|
207
|
+
}
|
|
208
|
+
private slot = WARM_SLOTS;
|
|
209
|
+
/** Each frame: a newly lent kit's items replace the last's, one slot a frame (each first copy clones a first-person model). */
|
|
210
|
+
frame(): void {
|
|
211
|
+
if (this.kit !== heldOnOthers.lent) { this.kit = heldOnOthers.lent; this.items.clear(); this.slot = 0; }
|
|
212
|
+
if (this.slot >= WARM_SLOTS) return;
|
|
213
|
+
const held = heldOnOthers.prop(this.slot++);
|
|
214
|
+
if (held !== null) { const item = held.prop.clone(); item.traverse(node => { node.frustumCulled = false; }); this.items.add(item); }
|
|
215
|
+
}
|
|
216
|
+
/** Drawn wherever the camera looks, so the warm-up and every frame count its programs as used. */
|
|
217
|
+
private unculled(): void { this.group.traverse(node => { node.frustumCulled = false; }); }
|
|
218
|
+
dispose(): void { this.group.removeFromParent(); this.items.clear(); freeBody(this.group); }
|
|
219
|
+
}
|
|
220
|
+
|
|
172
221
|
export class OtherPlayers {
|
|
173
222
|
private readonly bodies = new Map<number, OtherBody>();
|
|
223
|
+
private readonly warm: WarmBody | null = null;
|
|
174
224
|
private readonly client: NetClient;
|
|
175
225
|
private readonly scene: THREE.Object3D;
|
|
176
226
|
private readonly row = new Float64Array(PLAYER_CLASS.row.length);
|
|
@@ -179,6 +229,8 @@ export class OtherPlayers {
|
|
|
179
229
|
constructor(client: NetClient, scene: THREE.Object3D, scope: Scope, me: Readonly<THREE.Vector3> | null = null) {
|
|
180
230
|
this.client = client; this.scene = scene; this.me = me;
|
|
181
231
|
scope.onDispose(() => { for (const handle of this.bodies.keys()) this.drop(handle); });
|
|
232
|
+
try { const warm = new WarmBody(); scene.add(warm.group); this.warm = warm; scope.onDispose(() => { warm.dispose(); }); }
|
|
233
|
+
catch (error) { console.error('[other players] warm body', error); }
|
|
182
234
|
if (me !== null) scope.onDispose(voiceNear.lend({ distanceTo: talker => this.distanceTo(talker) }));
|
|
183
235
|
}
|
|
184
236
|
/** Metres to a talker's body, as drawn: the body with its row's id, or, from a server that names none, the nearest with its Name. */
|
|
@@ -209,6 +261,7 @@ export class OtherPlayers {
|
|
|
209
261
|
return body !== undefined;
|
|
210
262
|
}
|
|
211
263
|
frame(renderTick: number, dt: number): void {
|
|
264
|
+
this.warm?.frame();
|
|
212
265
|
const { client, bodies, row } = this, own = client.welcome?.handle ?? 0;
|
|
213
266
|
for (const handle of bodies.keys()) if (!client.entities.has(handle)) this.drop(handle);
|
|
214
267
|
for (const [handle, info] of client.entities) {
|
|
@@ -228,12 +281,6 @@ export class OtherPlayers {
|
|
|
228
281
|
const body = this.bodies.get(handle);
|
|
229
282
|
if (body === undefined) return;
|
|
230
283
|
this.bodies.delete(handle); this.scene.remove(body.group); body.undress();
|
|
231
|
-
|
|
232
|
-
// bone texture with them. A sprite's geometry is three's own, shared by every sprite.
|
|
233
|
-
body.group.traverse(node => {
|
|
234
|
-
if (node instanceof THREE.SkinnedMesh) node.skeleton.dispose();
|
|
235
|
-
if (node instanceof THREE.Mesh) { const geometry = node.geometry as THREE.BufferGeometry; if (geometry.userData['shared'] !== true) geometry.dispose(); }
|
|
236
|
-
if (node instanceof THREE.Mesh || node instanceof THREE.Sprite) { for (const material of [node.material].flat() as THREE.Material[]) { if (material.userData['shared'] === true) continue; if (material instanceof THREE.SpriteMaterial) material.map?.dispose(); material.dispose(); } }
|
|
237
|
-
});
|
|
284
|
+
freeBody(body.group);
|
|
238
285
|
}
|
|
239
286
|
}
|