@wildshard/engine 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/lint/engine-sides.json +5 -0
- package/package.json +5 -2
- package/scripts/app-build/gen.ts +11 -0
- package/scripts/cell-mem-bench.mjs +2 -0
- package/scripts/chaos-proxy-core.mjs +14 -1
- package/scripts/chaos-proxy-proof.mjs +22 -0
- package/scripts/check-devserver.mjs +1 -1
- package/scripts/failmode-cases.d.mts +8 -0
- package/scripts/failmode-cases.mjs +97 -0
- package/scripts/failmode-proof.mjs +532 -0
- package/scripts/grid-crossing-nightly.mjs +5 -4
- package/scripts/grid-crossing-report.mjs +5 -2
- package/scripts/grid-crossing-tour.mjs +36 -12
- package/scripts/grid-crossing-walk-proof.mjs +4 -2
- package/scripts/hover-speed-probe.mjs +136 -0
- package/scripts/land.mjs +2 -1
- package/scripts/loading-flow/benchmax.mjs +34 -11
- package/scripts/loading-flow/deskbench.mjs +276 -0
- package/scripts/loading-flow/stalls.d.mts +17 -3
- package/scripts/loading-flow/stalls.mjs +82 -3
- package/scripts/net-lag-proof.mjs +3 -2
- package/scripts/nightly-model.ts +9 -6
- package/scripts/offline-proof.mjs +7 -1
- package/scripts/online-rig.mjs +9 -7
- package/scripts/parity/boot-smoke.mjs +13 -2
- package/scripts/pin-format.ts +5 -2
- package/scripts/pins-reuse.d.mts +1 -0
- package/scripts/pins-reuse.mjs +22 -0
- package/scripts/release-cook.mjs +109 -0
- package/scripts/scratch-dir.mjs +95 -0
- package/scripts/scratch-sweep.mjs +182 -0
- package/scripts/tsconfig.json +2 -12
- package/scripts/vps/harden-prometheus.sh +3 -0
- package/scripts/vps/rebuild.sh +35 -9
- package/scripts/vps/wildshard-apply.mjs +5 -1
- package/scripts/vps/wildshard-config +117 -1
- package/scripts/worktree-reap.mjs +54 -8
- package/scripts/worktree.mjs +19 -5
- package/src/client/engine/anim/rigParser.ts +2 -2
- package/src/client/engine/boot/contentRead.ts +54 -5
- package/src/client/engine/boot/gpuFiles.ts +3 -3
- package/src/client/engine/boot/leaveAfterPaint.ts +4 -1
- package/src/client/engine/core/Game.ts +63 -19
- package/src/client/engine/core/gpuOnly.ts +10 -0
- package/src/client/engine/core/renderBudget.ts +134 -0
- package/src/client/engine/core/shadowLayer.ts +18 -0
- package/src/client/engine/explore/pick.ts +13 -1
- package/src/client/engine/net/predictor.ts +12 -4
- package/src/client/engine/net/redial.ts +40 -5
- package/src/client/engine/player/TouchControls.ts +3 -2
- package/src/client/engine/render/dataLook.ts +70 -7
- package/src/client/engine/render/families/pbr.ts +2 -0
- package/src/client/engine/render/families/registry.ts +11 -2
- package/src/client/engine/render/families/sceneSurface.ts +118 -0
- package/src/client/engine/render/look.ts +7 -1
- package/src/client/engine/render/precompile.ts +4 -2
- package/src/client/engine/render/tiers.ts +4 -1
- package/src/client/engine/telemetry/browserErrors.ts +3 -1
- package/src/client/engine/ui/ErrorModal.ts +1 -1
- package/src/client/engine/ui/Loading.ts +14 -2
- package/src/client/engine/ui/errorScreen.ts +51 -9
- package/src/client/engine/ui/hoverBoost.ts +31 -4
- package/src/client/engine/ui/styles/touch.css +6 -0
- package/src/client/engine/world/declaredProps.ts +5 -1
- package/src/client/engine/world/skyRig.ts +4 -1
- package/src/client/engine/world/terrainTileView.ts +64 -23
- package/src/client/game/boot/spawnDownload.ts +44 -6
- package/src/client/game/devScene/hook.ts +149 -12
- package/src/client/game/devScene/liveLook.ts +21 -0
- package/src/client/game/grid/live.ts +47 -10
- package/src/client/game/grid/liveSession.ts +25 -6
- package/src/client/game/grid/pageEntry.ts +12 -1
- package/src/client/game/grid/productInputs.ts +22 -11
- package/src/client/game/grid/session.ts +15 -4
- package/src/client/game/grid/shardfileFar.ts +13 -2
- package/src/client/game/session/finish.ts +4 -1
- package/src/client/game/shardfile/client.ts +24 -7
- package/src/client/game/shardfile/clientPropMaterials.ts +4 -1
- package/src/client/game/shardfile/clientSource.ts +7 -3
- package/src/client/game/shardfile/clientViews.ts +36 -8
- package/src/client/game/shardfile/clientWorker.ts +4 -4
- package/src/client/game/shardfile/constructionCheckpoint.ts +2 -2
- package/src/client/game/shardfile/groundMerge.ts +59 -5
- package/src/client/game/shardfile/hybrid.ts +2 -0
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/slabLibrary.ts +115 -49
- package/src/client/game/shardfile/tileContent.ts +1 -1
- package/src/client/game/shardfile/tileDriver.ts +38 -11
- package/src/client/game/shardfile/wirePage.ts +7 -3
- package/src/client/game/shardfile/worldScenes.ts +17 -10
- package/src/client/host/online/doctor.ts +20 -7
- package/src/client/host/online/doctorView.ts +2 -0
- package/src/client/host/online/linkScreens.ts +95 -11
- package/src/client/host/online/reconnectStrip.ts +3 -2
- package/src/client/host/online/release.ts +87 -16
- package/src/client/host/online/releaseScreens.ts +108 -0
- package/src/client/host/online/shell.ts +24 -5
- package/src/client/host/online/voice.ts +45 -1
- package/src/client/host/online/voiceUi.ts +24 -6
- package/src/client/host/standalone/shell.ts +37 -1
- package/src/server/engine/sim/playerSim.ts +1 -1
- package/src/server/game/grid/simulation.ts +12 -6
- package/src/server/game/quest/eliteDrops.ts +7 -3
- package/src/server/game/riding/nativeTaming.ts +13 -2
- package/src/server/host/dedicated/cellHost.ts +21 -2
- package/src/server/host/dedicated/cellProtocol.ts +2 -0
- package/src/server/host/dedicated/cellWorker.ts +1 -1
- package/src/server/host/dedicated/dedicatedRoom.ts +38 -8
- package/src/server/host/dedicated/roadRoom.ts +3 -0
- package/src/server/host/dedicated/serverMetrics.ts +9 -0
- package/src/server/host/dedicated/workerTable.ts +31 -24
- package/src/server/host/standalone/gridServer.ts +1 -1
- package/src/server/host/standalone/serverHost.ts +56 -10
- package/src/server/host/standalone/serverProduct.ts +9 -7
- package/src/server/host/standalone/serverRuntime.ts +1 -1
- package/src/shared/engine/boot/loadingWaits.ts +10 -2
- package/src/shared/engine/core/config.ts +3 -0
- package/src/shared/engine/core/framePacing.ts +12 -1
- package/src/shared/engine/physics/terrainTiles.ts +20 -4
- package/src/shared/engine/player/hoverSpeed.ts +3 -3
- package/src/shared/engine/strings.ts +12 -1
- package/src/shared/game/devColliders.ts +60 -0
- package/src/shared/game/devGameplay.ts +41 -0
- package/src/shared/game/grid/rules.ts +12 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pageScope } from '../../../shared/engine/app/resources';
|
|
2
|
+
import { framesAvailable } from '../../../shared/engine/app/scopeEnvironment';
|
|
2
3
|
|
|
3
4
|
/** iOS Simulator, 2026-11-09: WebKit stops painting a page as soon as a navigation starts in the same turn, so the load
|
|
4
5
|
* failure screen's RELOAD showed no cover at all. Every reload the player asked for navigates one painted frame after the
|
|
@@ -11,6 +12,8 @@ export function leaveAfterPaint(go: () => void): void {
|
|
|
11
12
|
if (pageScope.disposed || pageScope.disposing) { go(); return; }
|
|
12
13
|
let gone = false;
|
|
13
14
|
const once = (): void => { if (gone) return; gone = true; go(); };
|
|
14
|
-
|
|
15
|
+
// FM3's proof (version-skew Reload, 2026-11-15): the online shell's graph runs this with no browser frame environment
|
|
16
|
+
// installed, and the bare frame throws, so Reload sat at RELOADING under 'Something broke'. No frames: the timer alone goes.
|
|
17
|
+
if (framesAvailable()) pageScope.raf(() => { pageScope.timeout(0, once); });
|
|
15
18
|
pageScope.timeout(LEAVE_FRAME_MS, once);
|
|
16
19
|
}
|
|
@@ -53,6 +53,7 @@ import { yieldTask } from '../../../shared/engine/core/workSlice';
|
|
|
53
53
|
import { buildHeld, heldDrawDeferred, noteFrameDrawn } from '../../../shared/engine/core/framePacing';
|
|
54
54
|
import { isDev, onDev } from './devMode';
|
|
55
55
|
import { activeDevPixels, drawingPixelRatio } from './devPixels';
|
|
56
|
+
import { RenderBudget, budgetCeiling } from './renderBudget';
|
|
56
57
|
import { graphicsMode, lowPowerOn, noteFastFrames, PIXELS_EVENT } from './graphicsMode';
|
|
57
58
|
import { flagOn, frameCapFor, noteShipped, presetLabel, setFrameReadout, type ShippedLook } from './graphicsQuality';
|
|
58
59
|
import { classifyFrames } from '../boot/lowPower';
|
|
@@ -179,6 +180,11 @@ const ARRIVAL_RADIUS = 125;
|
|
|
179
180
|
/** one engine colour chain, built (Game.buildComposer): its effects, in order, and by name */
|
|
180
181
|
interface BuiltChain { clean: boolean; order: Effect[]; fx: Omit<EngineEffects, 'order'> }
|
|
181
182
|
|
|
183
|
+
/** GC6: candidates a live display transform gets before it links on its next draw */
|
|
184
|
+
export const POST_PASS_ATTEMPTS = 4;
|
|
185
|
+
/** GC6: the longest an entered frame waits on live display transform preparation */
|
|
186
|
+
export const POST_PREPARATION_WAIT_MS = 12_000;
|
|
187
|
+
|
|
182
188
|
/** An entered frame's preparation trace (`Game.entryPreparation`): its destination root, owner, running phase, measured
|
|
183
189
|
* work counts and scalar timings. A named type, so consumers of the emitted declarations see it (a private field's type
|
|
184
190
|
* is not emitted). */
|
|
@@ -526,10 +532,10 @@ export class Game {
|
|
|
526
532
|
if (tracedBoot) recordGpuCheckpoint(this.renderer, 'renderer:created');
|
|
527
533
|
// QA row 25 / MG2: a Developer's screen × density pick (core/devPixels.ts), else a phone's Low graphics
|
|
528
534
|
// (core/graphicsMode.ts), stands in for the tier's cap; either applies live
|
|
529
|
-
this.renderer.setPixelRatio(
|
|
535
|
+
this.renderer.setPixelRatio(this.wantedRatio());
|
|
530
536
|
// the new ratio waits for the frame that draws (RT3: never in the task that decided it, whose cleared canvas nothing
|
|
531
537
|
// would replace; under a menu or the title the world stays as it was until play draws again)
|
|
532
|
-
const repixel = (): void => { const ratio =
|
|
538
|
+
const repixel = (): void => { const ratio = this.wantedRatio(); this.pickedRatio = ratio === this.renderer.getPixelRatio() ? null : ratio; this.applyQuality(); };
|
|
533
539
|
this.engineScope.listen(document, PIXELS_EVENT, repixel);
|
|
534
540
|
// MG8 prototype: the player has control, so the boot's shadow draws are done: a no-shadows mode clears the maps once more
|
|
535
541
|
this.engineScope.listen(document, 'ws:control-ready', () => { this.qualityClearedMaps = new WeakSet(); });
|
|
@@ -551,6 +557,7 @@ export class Game {
|
|
|
551
557
|
// change tells the page (Settings, the first-play card) and lands in the next drawn frame
|
|
552
558
|
this.engineScope.listen(document, 'visibilitychange', () => {
|
|
553
559
|
if (document.visibilityState !== 'visible') return;
|
|
560
|
+
this.budget?.reset(); // NB5: the frames from before the page went away are not this page's pace
|
|
554
561
|
const stamps: number[] = [];
|
|
555
562
|
const tick = (now: number): void => {
|
|
556
563
|
if (this.engineScope.disposed || document.visibilityState !== 'visible') return;
|
|
@@ -1096,18 +1103,24 @@ export class Game {
|
|
|
1096
1103
|
const geometry = postTriangle(), mesh = new THREE.Mesh(geometry, pass.fullscreenMaterial), scene = new THREE.Scene();
|
|
1097
1104
|
const target = pass.renderToScreen ? null : composer.inputBuffer;
|
|
1098
1105
|
try {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1106
|
+
// GC6 (QA 11-14 row 6): a pass that left the chain, or whose shader keeps changing under each candidate, never
|
|
1107
|
+
// published: the loop ran for ever and every entered frame awaiting it stayed unready. Past a few candidates it
|
|
1108
|
+
// links on its next draw (the boot path).
|
|
1109
|
+
let published = false, attempts = 0;
|
|
1110
|
+
while (current() && composer.passes.includes(pass) && !published) {
|
|
1111
|
+
if (attempts++ >= POST_PASS_ATTEMPTS) { pass.recompile(); break; }
|
|
1112
|
+
published = await prepareEffectPass(pass, async material => {
|
|
1113
|
+
mesh.material = material;
|
|
1114
|
+
await runPrecompile(this.renderer, this.camera, [{ label: engineString('s_178612197e2b'), root: mesh, target: scene, rt: target }], 1,
|
|
1115
|
+
undefined, undefined, current, false, () => waitForDrawnFrame(this.engineScope, () => this.frameCount, current));
|
|
1116
|
+
}, material => {
|
|
1117
|
+
mesh.material = material;
|
|
1118
|
+
const prior = this.renderer.getRenderTarget(), face = this.renderer.getActiveCubeFace(), mip = this.renderer.getActiveMipmapLevel();
|
|
1119
|
+
this.renderer.setRenderTarget(target);
|
|
1120
|
+
try { this.renderer.compile(mesh, this.camera, scene); }
|
|
1121
|
+
finally { this.renderer.setRenderTarget(prior, face, mip); }
|
|
1122
|
+
}, current);
|
|
1123
|
+
}
|
|
1111
1124
|
} finally { geometry.dispose(); }
|
|
1112
1125
|
};
|
|
1113
1126
|
const work = prepare();
|
|
@@ -1169,10 +1182,18 @@ export class Game {
|
|
|
1169
1182
|
// and first draws. An early composer lends only the compiler above; doing
|
|
1170
1183
|
// the crossing warm-up here would add parked/offscreen frame variants.
|
|
1171
1184
|
if (this.frameCount === 0) { trace.completed = true; return; }
|
|
1185
|
+
// GC6 (QA 11-14 row 6): a display transform's preparation that never settles (a lost link, a dead owner's frame
|
|
1186
|
+
// wait) held Nalati's on-road entry at afterPlay for ever: in the cell, no control. Past POST_PREPARATION_WAIT_MS
|
|
1187
|
+
// the entry goes on and that pass links on its first draw (D196: a stall reveals with what had linked).
|
|
1188
|
+
const postStarted = diagnosticNow();
|
|
1172
1189
|
for (;;) {
|
|
1173
|
-
const pending = this.postPreparation;
|
|
1174
|
-
|
|
1190
|
+
const pending = this.postPreparation, left = POST_PREPARATION_WAIT_MS - (diagnosticNow() - postStarted);
|
|
1191
|
+
let timer: ReturnType<Scope['timeout']> | undefined;
|
|
1192
|
+
const timedOut = left <= 0 || await Promise.race([pending.then(() => false),
|
|
1193
|
+
new Promise<boolean>(resolve => { timer = this.engineScope.timeout(left, () => { resolve(true); }); })])
|
|
1194
|
+
.finally(() => { if (timer !== undefined) this.engineScope.cancelTimer(timer); });
|
|
1175
1195
|
if (!current()) throw new Error('Shader warm-up owner left');
|
|
1196
|
+
if (timedOut) { trace.stalled = 'post-preparation'; console.warn(`[entry] ${owner.name}: display transform preparation still running after ${String(POST_PREPARATION_WAIT_MS)} ms; entering without it`); break; }
|
|
1176
1197
|
if (this.postPreparation === pending) break;
|
|
1177
1198
|
}
|
|
1178
1199
|
enter('shaders-and-composer');
|
|
@@ -1687,8 +1708,26 @@ export class Game {
|
|
|
1687
1708
|
// MG8: Settings ▸ Graphics ▸ Pixel density replaces the boot-time render scale on a phone (Jake ~23:45: one pixel control)
|
|
1688
1709
|
private readonly phoneGraphics: boolean = TIER === 'phone';
|
|
1689
1710
|
resize(): void { this.fitSize(); this.kickLoop(); }
|
|
1711
|
+
/** NB5 (renderBudget.ts): the desktop's pixel budget and dynamic resolution, on the tier's own scale only: never a phone
|
|
1712
|
+
* (MG8's Pixel density; Jake 2026-10-20, no dynamic resolution on the phone), a Developer's pixel pick or a player's saved
|
|
1713
|
+
* render scale (Settings ▸ Graphics, gfxPrefs.dpr) */
|
|
1714
|
+
private budget: RenderBudget | null = null;
|
|
1715
|
+
private budgetOn(): boolean { return !this.phoneGraphics && activeDevPixels() === null && gfxPrefs.dpr === 'auto' && this.slowPacing === null; }
|
|
1716
|
+
/** NB5: the next drawn frame follows vsyncs skipped on purpose (a build hold): its interval is not the frame's cost */
|
|
1717
|
+
private budgetSkip = false;
|
|
1718
|
+
/** The drawing buffer's pixel ratio the page wants now: the budget's on the desktop's own scale, else drawingPixelRatio. */
|
|
1719
|
+
private wantedRatio(): number {
|
|
1720
|
+
const base = drawingPixelRatio(window.devicePixelRatio, TIER_CONFIG.dpr, this.phoneGraphics);
|
|
1721
|
+
if (!this.budgetOn()) { this.budget = null; return base; }
|
|
1722
|
+
const ceiling = budgetCeiling(window.innerWidth, viewportHeight(), window.devicePixelRatio, base);
|
|
1723
|
+
if (this.budget === null) this.budget = new RenderBudget(ceiling);
|
|
1724
|
+
else if (this.budget.ceiling !== ceiling) this.budget.resize(ceiling);
|
|
1725
|
+
return this.budget.ratio;
|
|
1726
|
+
}
|
|
1690
1727
|
private fitSize(): void {
|
|
1691
1728
|
const w = window.innerWidth, h = viewportHeight();
|
|
1729
|
+
// a new window size moves the budget's ceiling (a smaller ratio lands now: this resize redraws anyway)
|
|
1730
|
+
if (this.budget !== null) { const ratio = this.wantedRatio(); if (ratio !== this.renderer.getPixelRatio()) this.renderer.setPixelRatio(ratio); }
|
|
1692
1731
|
this.camera.aspect = w / h;
|
|
1693
1732
|
this.camera.updateProjectionMatrix();
|
|
1694
1733
|
this.renderer.setSize(w, h);
|
|
@@ -1725,13 +1764,14 @@ export class Game {
|
|
|
1725
1764
|
// worker messages and input; like a capped vsync, a skipped one does nothing. A capture draws at the tier's own
|
|
1726
1765
|
// scale on its own clock: no spacing, and any lowered scale restored
|
|
1727
1766
|
const capture = this.app.clock.mode === 'capture';
|
|
1728
|
-
if (capture) this.slowPacing?.restore();
|
|
1767
|
+
if (capture) { this.slowPacing?.restore(); this.budget?.restore(); }
|
|
1729
1768
|
const pacing = capture ? null : this.slowPacing;
|
|
1730
1769
|
if (pacedSkip(pacing, lastRun, this.pacedStart, forceFrame, buildHeld())) return;
|
|
1731
1770
|
// G782: held at a cell's wall with build slices running, skip vsyncs up to the 30 fps held floor (framePacing.ts);
|
|
1732
1771
|
// like a capped vsync, a skipped one does nothing, so the drawn frame's dt is the whole interval
|
|
1733
|
-
if (!forceFrame && heldDrawDeferred()) return;
|
|
1772
|
+
if (!forceFrame && heldDrawDeferred()) { this.budgetSkip = true; return; }
|
|
1734
1773
|
const cap = frameCapFps();
|
|
1774
|
+
if (cap > 0) this.budget?.restore(); // NB5: a cap sets its own pace; the tier's own scale under it
|
|
1735
1775
|
if (cap > 0 && !forceFrame) {
|
|
1736
1776
|
const anchor = frameCapAnchor(lastDrawn, now ?? lastRun, cap);
|
|
1737
1777
|
if (anchor === null) return;
|
|
@@ -1771,7 +1811,8 @@ export class Game {
|
|
|
1771
1811
|
// QA row 25: a Developer pixel pick (core/devPixels.ts) holds against the software pacing's scale while it is set
|
|
1772
1812
|
const paced = this.stepOnly ? null : this.slowPacing?.takeRatio() ?? null, picked = this.stepOnly ? null : this.pickedRatio;
|
|
1773
1813
|
if (picked !== null) this.pickedRatio = null;
|
|
1774
|
-
const
|
|
1814
|
+
const budgeted = this.stepOnly || picked !== null || paced !== null ? null : this.budget?.takeRatio() ?? null;
|
|
1815
|
+
const ratio = picked ?? (paced !== null && activeDevPixels() === null ? paced : null) ?? (this.budgetOn() ? budgeted : null);
|
|
1775
1816
|
if (ratio !== null) { this.renderer.setPixelRatio(ratio); this.fitSize(); }
|
|
1776
1817
|
sky.update(realDt);
|
|
1777
1818
|
// planet + sun disc travel with the camera so they stay "infinitely" far
|
|
@@ -1806,6 +1847,9 @@ export class Game {
|
|
|
1806
1847
|
noteFrameDrawn(done, now, cap, cap > 0 && Number.isFinite(lastDrawn) ? lastDrawn : undefined); // Builds share the cap recovery deadline; actual rAF still measures display cadence.
|
|
1807
1848
|
this.app.cpu.end();
|
|
1808
1849
|
if (pacing !== null) this.measurePacedFrame(lastRun);
|
|
1850
|
+
// NB5: dynamic resolution reads the drawn frame's interval (uncapped play only: a cap or a capture sets its own pace)
|
|
1851
|
+
else if (this.budget !== null && !capture && cap === 0 && !forceFrame && !this.app.clock.paused && !this.budgetSkip) this.budget.measured(liveDt * 1000);
|
|
1852
|
+
this.budgetSkip = false;
|
|
1809
1853
|
this.workMs[this.frameI] = work;
|
|
1810
1854
|
this.frameRafTime = now ?? null;
|
|
1811
1855
|
this.frameCount++;
|
|
@@ -48,6 +48,16 @@ function releaseCpuCopy(this: BufferAttribute): void {
|
|
|
48
48
|
this.array = this.array.slice(0, 0);
|
|
49
49
|
Object.defineProperty(this, 'needsUpdate', { configurable: true, get: () => false, set: (value: boolean) => { if (value) lateWrite(this); } });
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* SHARD-SOURCE AP18 (dev only: `wildshard watch`'s ground swap): upload a whole new copy of a GPU-only attribute into its
|
|
53
|
+
* buffer. The array is the same length as the first upload's, so the buffer is rewritten in place (no second buffer); its
|
|
54
|
+
* CPU copy goes again once uploaded.
|
|
55
|
+
*/
|
|
56
|
+
export function refillGpuOnly(attribute: BufferAttribute, array: Float32Array): void {
|
|
57
|
+
if (array.length !== attribute.count * attribute.itemSize) throw new Error(`gpu-only: a refill of ${array.length} values for ${attribute.count * attribute.itemSize}`);
|
|
58
|
+
Reflect.deleteProperty(attribute, 'needsUpdate');
|
|
59
|
+
attribute.array = array; attribute.needsUpdate = true;
|
|
60
|
+
}
|
|
51
61
|
function lateWrite(attribute: BufferAttribute): void {
|
|
52
62
|
const where = releasedAs.get(attribute) ?? 'gpu-only';
|
|
53
63
|
if (lateWriters.has(where)) return;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NINE-DRAGON-BENCHMAX NB5, widened (meta QA-FEEDBACK-2026-11-14 rows 2, 3 and 5; Jake, desktop Chrome on his Mac:
|
|
3
|
+
* "nine dragon is fucked on desktop", "nalati is shist too 30 fps", "driftwood all over the place 40-70 FPS"). The J343 bar
|
|
4
|
+
* is 60 fps on desktop. The desktop's drawing buffer, in two parts:
|
|
5
|
+
*
|
|
6
|
+
* - a pixel budget: the buffer never holds more than DESKTOP_PIXEL_BUDGET pixels, whatever the window. The tier's 1.5 cap
|
|
7
|
+
* alone let a big window grow without end (a 2560x1440 window at 1.5 is 8.3 Mpx; Jake's 1496x717 at 1.5 is 2.4 Mpx, under
|
|
8
|
+
* the budget, so his ceiling stays 1.5);
|
|
9
|
+
* - dynamic resolution: the render scale steps down fast and back up slowly from the drawn frame's own interval, between
|
|
10
|
+
* a floor (one buffer pixel per CSS pixel where the ceiling allows it) and that ceiling. A frame that misses 60 fps
|
|
11
|
+
* tries one step down; if the next frames are no faster the frame is not bound by its pixels (the main thread, a busy
|
|
12
|
+
* machine), so the step is taken back and held off for a while: a softer frame that buys nothing is never kept.
|
|
13
|
+
*
|
|
14
|
+
* Desktop only, and only the tier's own scale: the phone keeps its one Pixel density control (MG8) and "Render scale stays
|
|
15
|
+
* 2x on the phone (no dynamic resolution)" (Jake, 2026-10-20). A Developer's pixel pick, a player's saved render scale, a
|
|
16
|
+
* capture, a frame cap or a software rasterizer's pacing each leave the scale alone. Pure: it is driven by measured
|
|
17
|
+
* intervals alone, so the tests drive it with numbers.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** The desktop drawing buffer's most pixels (fable-phoneperf's cleanroom budget is 3.5 to 4.5 Mpx on a desktop). */
|
|
21
|
+
export const DESKTOP_PIXEL_BUDGET = 4_200_000;
|
|
22
|
+
/** A window's frames over this median interval (ms) miss 60 fps: step down. */
|
|
23
|
+
export const OVER_MS: number = 1000 / 58;
|
|
24
|
+
/** A window's frames under this median interval (ms) have headroom for a step up (~80 fps). */
|
|
25
|
+
export const UNDER_MS = 12.5;
|
|
26
|
+
/** Drawn frames per decision. */
|
|
27
|
+
export const BUDGET_WINDOW = 30;
|
|
28
|
+
/** Calm windows in a row before one step up. */
|
|
29
|
+
export const RAISE_WINDOWS = 6;
|
|
30
|
+
/** A step down must make the frame at least this much faster (share of its interval) to be kept. */
|
|
31
|
+
export const STEP_PAYS = 0.06;
|
|
32
|
+
/** After a step that did not pay, no step down for this many windows; each unpaid step in a row doubles it, to at most
|
|
33
|
+
* MAX_HOLD_WINDOWS (a frame bound by its main thread is not re-tried, and re-softened, every few seconds). */
|
|
34
|
+
export const UNPAID_HOLD_WINDOWS = 20;
|
|
35
|
+
export const MAX_HOLD_WINDOWS = 160;
|
|
36
|
+
/** Pixel ratios snap to eighths (each change reallocates the composer's targets). */
|
|
37
|
+
const SNAP = 8;
|
|
38
|
+
|
|
39
|
+
/** The buffer's pixel ratio ceiling for a window: the tier's cap, the screen's own density, and the pixel budget. */
|
|
40
|
+
export function budgetCeiling(cssWidth: number, cssHeight: number, device: number, tierCap: number, budget: number = DESKTOP_PIXEL_BUDGET): number {
|
|
41
|
+
const cap = Math.min(device, tierCap), css = Math.max(1, cssWidth * cssHeight);
|
|
42
|
+
const fits = Math.sqrt(budget / css);
|
|
43
|
+
// snapped as a whole, so the ceiling is always one of budgetSteps' own eighths (a 1.1 screen draws at 1, never 1.125)
|
|
44
|
+
return Math.max(1 / SNAP, Math.floor(Math.min(cap, fits) * SNAP) / SNAP);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The lowest ratio dynamic resolution takes: one buffer pixel per CSS pixel, or 3/4 of a ceiling already under that. */
|
|
48
|
+
export function budgetFloor(ceiling: number): number {
|
|
49
|
+
return ceiling > 1 ? 1 : Math.max(1 / SNAP, Math.floor(ceiling * 0.75 * SNAP) / SNAP);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The steps between floor and ceiling, ascending, an eighth apart (both ends included). */
|
|
53
|
+
export function budgetSteps(floor: number, ceiling: number): number[] {
|
|
54
|
+
const steps: number[] = [];
|
|
55
|
+
for (let r = ceiling; r > floor + 1e-9; r -= 1 / SNAP) steps.push(Math.round(r * SNAP) / SNAP);
|
|
56
|
+
steps.push(floor);
|
|
57
|
+
return [...new Set(steps)].sort((a, b) => a - b);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const median = (values: readonly number[]): number => [...values].sort((a, b) => a - b)[Math.floor(values.length / 2)] ?? 0;
|
|
61
|
+
|
|
62
|
+
/** One page's render budget. */
|
|
63
|
+
export class RenderBudget {
|
|
64
|
+
private steps: number[];
|
|
65
|
+
private at: number;
|
|
66
|
+
private readonly intervals: number[] = [];
|
|
67
|
+
private calm = 0;
|
|
68
|
+
private hold = 0;
|
|
69
|
+
private nextHold = UNPAID_HOLD_WINDOWS;
|
|
70
|
+
/** the step down on trial: the median it was taken against and the step it came from */
|
|
71
|
+
private trial: { before: number; from: number } | null = null;
|
|
72
|
+
private pending: number | null = null;
|
|
73
|
+
|
|
74
|
+
constructor(ceiling: number) { this.steps = budgetSteps(budgetFloor(ceiling), ceiling); this.at = this.steps.length - 1; }
|
|
75
|
+
|
|
76
|
+
/** The ratio frames draw at now. */
|
|
77
|
+
get ratio(): number { return this.steps[this.at] ?? 1; }
|
|
78
|
+
/** The ceiling (the window's budget). */
|
|
79
|
+
get ceiling(): number { return this.steps.at(-1) ?? 1; }
|
|
80
|
+
|
|
81
|
+
/** A new window size or screen: a new ceiling. Returns the ratio to draw at (the current one, or the new ceiling if lower). */
|
|
82
|
+
resize(ceiling: number): number {
|
|
83
|
+
const was = this.ratio;
|
|
84
|
+
this.steps = budgetSteps(budgetFloor(ceiling), ceiling);
|
|
85
|
+
const keep = this.steps.findIndex((r) => r >= was - 1e-9);
|
|
86
|
+
this.at = keep === -1 ? this.steps.length - 1 : keep;
|
|
87
|
+
this.reset();
|
|
88
|
+
return this.ratio;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Back to the ceiling (a capture draws at the tier's own scale), from the next drawn frame. */
|
|
92
|
+
restore(): void { this.reset(); this.move(this.steps.length - 1); }
|
|
93
|
+
|
|
94
|
+
/** Forget the measurements (a resize, a capture, a page coming back): the next window starts afresh. */
|
|
95
|
+
reset(): void { this.intervals.length = 0; this.calm = 0; this.trial = null; }
|
|
96
|
+
|
|
97
|
+
/** The ratio to set right before the next frame draws, once (RT3: a resize clears the canvas, so it lands in the frame that draws). */
|
|
98
|
+
takeRatio(): number | null { const next = this.pending; this.pending = null; return next; }
|
|
99
|
+
|
|
100
|
+
/** A drawn frame's interval (ms, from the last drawn frame). Returns the new ratio when it changes, else null. */
|
|
101
|
+
measured(intervalMs: number): number | null {
|
|
102
|
+
if (!Number.isFinite(intervalMs) || intervalMs <= 0) return null;
|
|
103
|
+
this.intervals.push(intervalMs);
|
|
104
|
+
if (this.intervals.length < BUDGET_WINDOW) return null;
|
|
105
|
+
const m = median(this.intervals);
|
|
106
|
+
this.intervals.length = 0;
|
|
107
|
+
if (this.hold > 0) this.hold--;
|
|
108
|
+
const trial = this.trial;
|
|
109
|
+
if (trial !== null) {
|
|
110
|
+
this.trial = null;
|
|
111
|
+
// the step down didn't pay: not bound by pixels at this view; take it back and hold off
|
|
112
|
+
if (m > trial.before * (1 - STEP_PAYS)) {
|
|
113
|
+
this.hold = this.nextHold; this.nextHold = Math.min(MAX_HOLD_WINDOWS, this.nextHold * 2); this.calm = 0;
|
|
114
|
+
return this.move(trial.from);
|
|
115
|
+
}
|
|
116
|
+
this.nextHold = UNPAID_HOLD_WINDOWS;
|
|
117
|
+
}
|
|
118
|
+
if (m > OVER_MS) {
|
|
119
|
+
this.calm = 0;
|
|
120
|
+
if (this.hold > 0 || this.at === 0) return null;
|
|
121
|
+
this.trial = { before: m, from: this.at };
|
|
122
|
+
return this.move(this.at - 1);
|
|
123
|
+
}
|
|
124
|
+
this.calm = m < UNDER_MS ? this.calm + 1 : 0;
|
|
125
|
+
if (this.calm >= RAISE_WINDOWS && this.at < this.steps.length - 1) { this.calm = 0; return this.move(this.at + 1); }
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private move(to: number): number | null {
|
|
130
|
+
if (to === this.at) return null;
|
|
131
|
+
this.at = to; this.pending = this.ratio; this.intervals.length = 0;
|
|
132
|
+
return this.ratio;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Layers, Object3D } from 'three';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The layer of shadow-only casters: meshes drawn into the sun's shadow map and nowhere else (Cabin.ts's static depth
|
|
3
5
|
* proxies, animalShadow.ts's one-draw animal casters). three.js tests a caster's layers against the VIEW camera in the
|
|
@@ -6,3 +8,19 @@
|
|
|
6
8
|
* and only then. PINE-HOLLOW-REMASTER PH-P1 / P2.
|
|
7
9
|
*/
|
|
8
10
|
export const SHADOW_LAYER = 9;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* SHARD-SOURCE ss4d: the `userData` mark on a mesh that sits on SHADOW_LAYER only because a merge draws it for the view
|
|
14
|
+
* (`groundMerge.ts` `mergeView`, AP8's merged props). It is still a real surface: a tap in the World Explorer picks it
|
|
15
|
+
* (`explore/pick.ts`), where a true shadow-only caster (a cabin's depth proxy) stays unpickable.
|
|
16
|
+
*/
|
|
17
|
+
export const MERGED_VIEW = 'mergedView';
|
|
18
|
+
/** The name of a merge's own view mesh (AP8): it stands in for its members, so a pick reads the member, never it. */
|
|
19
|
+
export const MERGED_COPY = 'props.merged';
|
|
20
|
+
|
|
21
|
+
/** Whether a raycast hit on `object` is a drawn surface for a raycaster on `view`'s layers: on one of them, or a merged
|
|
22
|
+
* member its merge draws. */
|
|
23
|
+
export function drawnSurface(object: Object3D, view: Layers): boolean {
|
|
24
|
+
if (object.name === MERGED_COPY) return false;
|
|
25
|
+
return object.layers.test(view) || object.userData[MERGED_VIEW] === true;
|
|
26
|
+
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* pickups do) is a few pixels wide, and the finger lands on the roof beside it.
|
|
22
22
|
*/
|
|
23
23
|
import * as THREE from 'three';
|
|
24
|
+
import { drawnSurface, SHADOW_LAYER } from '../core/shadowLayer';
|
|
24
25
|
|
|
25
26
|
/** something a tap can hit: an object (or a batch mesh) and how it maps to a catalog entry + a box */
|
|
26
27
|
export interface SelectTarget {
|
|
@@ -55,6 +56,17 @@ const volume = (b: THREE.Box3): number => { b.getSize(_size); return _size.x * _
|
|
|
55
56
|
export const MIN_PICK = 0.75;
|
|
56
57
|
const tiny = (b: THREE.Box3): boolean => { b.getSize(_size); return Math.max(_size.x, _size.y, _size.z) <= MIN_PICK; };
|
|
57
58
|
|
|
59
|
+
/**
|
|
60
|
+
* The nearest drawn surface of `object` under the ray. SHARD-SOURCE ss4d: a merged prop (AP8) draws through its merge and
|
|
61
|
+
* keeps its own mesh on SHADOW_LAYER, which a raycaster on the view layer skips: the ray tests that layer too for the
|
|
62
|
+
* one call, and keeps only the hits on drawn surfaces (a shadow-only depth proxy is not one).
|
|
63
|
+
*/
|
|
64
|
+
function drawnHit(ray: THREE.Raycaster, object: THREE.Object3D): THREE.Intersection | undefined {
|
|
65
|
+
const view = new THREE.Layers(); view.mask = ray.layers.mask;
|
|
66
|
+
ray.layers.enable(SHADOW_LAYER);
|
|
67
|
+
try { return ray.intersectObject(object, true).find((hit) => drawnSurface(hit.object, view)); } finally { ray.layers.mask = view.mask; }
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
/** the target under the ray, or null (nothing hit, or a surface no target claims) */
|
|
59
71
|
export function pickTarget(ray: THREE.Raycaster, targets: readonly SelectTarget[]): Picked | null {
|
|
60
72
|
const byObject = new Map<THREE.Object3D, SelectTarget[]>();
|
|
@@ -65,7 +77,7 @@ export function pickTarget(ray: THREE.Raycaster, targets: readonly SelectTarget[
|
|
|
65
77
|
let near: { mesh: THREE.Object3D; point: THREE.Vector3; d: number } | null = null;
|
|
66
78
|
for (const object of byObject.keys()) {
|
|
67
79
|
if (!shown(object)) continue;
|
|
68
|
-
const hit = ray
|
|
80
|
+
const hit = drawnHit(ray, object);
|
|
69
81
|
if (hit && (!near || hit.distance < near.d)) near = { mesh: hit.object, point: hit.point.clone(), d: hit.distance };
|
|
70
82
|
}
|
|
71
83
|
// a small copy the ray passes through before the surface it hits (E345: the minimum pick size)
|
|
@@ -97,6 +97,8 @@ function ownerTable(columns: readonly NetColumn<never>[]): OwnerTable {
|
|
|
97
97
|
export class Predictor {
|
|
98
98
|
/** Corrections taken, and steps replayed for them: what a proof page reports. */
|
|
99
99
|
corrections = 0; replays = 0;
|
|
100
|
+
/** Server-owned transitions, kept separate from a failed local prediction in proof output. */
|
|
101
|
+
readonly authoritative = { leadEnds: 0, resets: 0 };
|
|
100
102
|
/** What each correction disagreed on, and the widest gap at the acknowledged step. */
|
|
101
103
|
readonly missed = { position: 0, grounded: 0, board: 0, swim: 0, ride: 0, gap: 0 };
|
|
102
104
|
readonly misses: number[][] = [];
|
|
@@ -160,7 +162,8 @@ export class Predictor {
|
|
|
160
162
|
if ((acked !== null && seqAfter(acked, lastSeq)) || (this.body.ride === null) !== (ridden === null)) return false;
|
|
161
163
|
const led = this.flag(table.led, owner) === 1, resets = this.value(table.resets, owner);
|
|
162
164
|
const boarded = (ridden !== null) !== this.aboard; // getting on or off is the server's word, not a wrong guess
|
|
163
|
-
const
|
|
165
|
+
const leadEnded = this.led && !led, reset = this.resets !== null && this.resets !== resets;
|
|
166
|
+
const forced = led || this.led || boarded || reset;
|
|
164
167
|
this.led = led; this.resets = resets; this.aboard = ridden !== null;
|
|
165
168
|
if (!forced && acked === lastSeq) return false;
|
|
166
169
|
const { body, seqs, states, count, head } = this, offset = count === 0 ? -1 : (lastSeq - (seqs[head] ?? 0)) & 0xffff;
|
|
@@ -182,12 +185,17 @@ export class Predictor {
|
|
|
182
185
|
this.save(run);
|
|
183
186
|
}
|
|
184
187
|
s.yaw = yaw; // the view is this client's own: the server sends it back later than the thumb has moved
|
|
185
|
-
|
|
188
|
+
// The end of a server-led move and a server teleport must take the authoritative pose, but neither says the
|
|
189
|
+
// page predicted a command incorrectly. Counting them as corrections made Far Reach's boost report a false B2 miss.
|
|
190
|
+
if (leadEnded) this.authoritative.leadEnds++;
|
|
191
|
+
if (reset) this.authoritative.resets++;
|
|
192
|
+
const corrected = !forced && !led && !boarded;
|
|
193
|
+
if (corrected) this.corrections++;
|
|
186
194
|
const offsetX = x - feet.x, offsetY = y - feet.y, offsetZ = z - feet.z, far = offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ > PREDICTION_SNAP * PREDICTION_SNAP;
|
|
187
195
|
body.renderOffset.set(far ? 0 : offsetX, far ? 0 : offsetY, far ? 0 : offsetZ);
|
|
188
196
|
this.glide = glidePace(body.renderOffset.length());
|
|
189
|
-
if(
|
|
190
|
-
return
|
|
197
|
+
if(corrected)this.corrected?.({tick:tick??s.tick,mode:ride!==null?'ride':s.board.on?'board':s.swim.on?'swim':'foot',offset:Math.hypot(offsetX,offsetY,offsetZ),snapped:far});
|
|
198
|
+
return corrected;
|
|
191
199
|
}
|
|
192
200
|
|
|
193
201
|
/** A session's first frame: this body stands where the server says, with nothing to compare it to. */
|
|
@@ -11,7 +11,11 @@ export type LinkState = 'live' | 'reconnecting' | 'resuming' | 'lost' | 'full' |
|
|
|
11
11
|
* page was out of view, `offline` is a device that says it has no network (FM4b mode 2). It rides `onState`'s reason for `reconnecting` and `resuming`. */
|
|
12
12
|
export type LinkCause = 'silent' | 'closed' | 'restart' | 'hidden' | 'updating' | 'offline';
|
|
13
13
|
/** Where the dial is, for a screen that shows it: dials so far, the wait to the next (null while one is out), and how long it's been down. */
|
|
14
|
-
export interface LinkProgress { readonly dials: number; readonly nextDialMs: number | null; readonly downMs: number }
|
|
14
|
+
export interface LinkProgress { readonly dials: number; readonly nextDialMs: number | null; readonly downMs: number; readonly away?: LinkAway }
|
|
15
|
+
/** FM4b modes 4 and 45: the page was away for `ms` and came back to a quiet or closed link. `hidden` is time out of view the page
|
|
16
|
+
* measured (visibilitychange); `asleep` is a gap in the page's own clock ticks while it wasn't known hidden (a sleep, a frozen tab).
|
|
17
|
+
* It says nothing about the world's hold on the seat (J114): only what this page measured. */
|
|
18
|
+
export interface LinkAway { readonly ms: number; readonly how: 'hidden' | 'asleep' }
|
|
15
19
|
|
|
16
20
|
/** No frame for this long: say so. The predictor's ring is full by then, so the player holds still. */
|
|
17
21
|
const STRIP_MS = 1000;
|
|
@@ -24,6 +28,8 @@ const GIVE_UP_MS = 120_000;
|
|
|
24
28
|
/** The waits between dials, then the last for ever, each ±20%. */
|
|
25
29
|
const DIAL_WAITS_MS = [250, 500, 1000, 2000, 4000], DIAL_JITTER = 0.2;
|
|
26
30
|
const WATCH_MS = 100;
|
|
31
|
+
/** FM4b modes 4 and 45: away this long (out of view, or no clock tick at all) and back to a quiet link is the Welcome back card. */
|
|
32
|
+
const AWAY_MS = 30_000;
|
|
27
33
|
/** Words from a server that a redial would only hear again. */
|
|
28
34
|
const FINAL = new Set(['reload', 'refused', 'replaced']);
|
|
29
35
|
/** J178: the world is full, and a seat frees when someone leaves: this long between tries, for as long as the player waits. */
|
|
@@ -81,8 +87,12 @@ export class Redial {
|
|
|
81
87
|
private cause: LinkCause = 'closed';
|
|
82
88
|
/** When the device last said it went offline while the link was down; null while it has a network. */
|
|
83
89
|
private offlineAt: number | null = null;
|
|
90
|
+
/** The watch's last tick: a gap after it is time the page did nothing at all (FM4b mode 45). */
|
|
91
|
+
private tickAt: number;
|
|
92
|
+
private awayFor: LinkAway | null = null;
|
|
84
93
|
constructor(options: RedialOptions) {
|
|
85
94
|
this.options = options; this.transport = options.transport; this.now = options.now ?? diagnosticNow; this.random = options.random ?? jitterFrom(this.now()); this.online = options.online ?? browserOnline;
|
|
95
|
+
this.tickAt = this.now();
|
|
86
96
|
this.offFrame = options.client.onFrame(() => { this.heard(); });
|
|
87
97
|
this.offClose = this.watchClose(options.transport);
|
|
88
98
|
this.scope.interval(WATCH_MS, () => { this.watch(); });
|
|
@@ -96,11 +106,14 @@ export class Redial {
|
|
|
96
106
|
/** The dial's progress now. */
|
|
97
107
|
get progress(): LinkProgress {
|
|
98
108
|
const now = this.now(), down = this.phase !== 'up';
|
|
99
|
-
|
|
109
|
+
const away = this.awayFor === null ? {} : { away: this.awayFor };
|
|
110
|
+
return { dials: this.dials, nextDialMs: this.phase === 'down' && this.dialled === null ? Math.max(0, this.dialAt - now) : null, downMs: down ? Math.max(0, now - this.lostAt) : 0, ...away };
|
|
100
111
|
}
|
|
101
|
-
/** The page came back into view (an iPhone returning to Safari): a link that went quiet while hidden redials at once.
|
|
102
|
-
|
|
112
|
+
/** The page came back into view (an iPhone returning to Safari): a link that went quiet while hidden redials at once.
|
|
113
|
+
* `hiddenMs` is how long the page measured itself out of view (FM4b mode 4). */
|
|
114
|
+
check(hiddenMs = 0): void {
|
|
103
115
|
const now = this.now();
|
|
116
|
+
this.woke(now, hiddenMs);
|
|
104
117
|
if (this.phase === 'up' && this.heardAt !== null && now - this.heardAt >= STRIP_MS) { this.because('hidden'); this.lose(now); }
|
|
105
118
|
// a link that went silent while the page was away was the page's absence: say welcome back
|
|
106
119
|
if (this.phase === 'down') { if (this.cause === 'silent') this.because('hidden'); this.dialAt = now; }
|
|
@@ -118,11 +131,12 @@ export class Redial {
|
|
|
118
131
|
private heard(): void {
|
|
119
132
|
const now = this.now(), wasDown = this.phase === 'down';
|
|
120
133
|
this.heardAt = now;
|
|
121
|
-
if (wasDown) { this.phase = 'up'; this.dialled = null; this.dials = 0; this.waitingForSeat = false; this.offlineAt = null; }
|
|
134
|
+
if (wasDown) { this.phase = 'up'; this.dialled = null; this.dials = 0; this.waitingForSeat = false; this.offlineAt = null; this.awayFor = null; }
|
|
122
135
|
this.show('live');
|
|
123
136
|
}
|
|
124
137
|
private watch(): void {
|
|
125
138
|
const now = this.now();
|
|
139
|
+
this.woke(now, 0);
|
|
126
140
|
if (this.phase === 'up') {
|
|
127
141
|
if (this.heardAt === null) return;
|
|
128
142
|
const silent = now - this.heardAt;
|
|
@@ -180,6 +194,27 @@ export class Redial {
|
|
|
180
194
|
if (this.phase === 'up') { if (this.cause !== 'updating') this.because(reason === 'restart' ? 'restart' : this.online() ? 'closed' : 'offline'); this.lose(now, false); }
|
|
181
195
|
else if (this.phase === 'down') { if (reason === 'restart') this.because('restart'); this.failedDial(now); }
|
|
182
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* FM4b modes 4 and 45: the page was away (out of view for `hiddenMs`, or no clock tick for 30 s) and comes back to a link that is
|
|
199
|
+
* quiet or down. The time away is not dialling time: a link lost while away counts its give-up clock from the return, and one
|
|
200
|
+
* already down moves its clock on by the gap no dial could go out in, so a phone back after 4 minutes dials for 2 minutes more
|
|
201
|
+
* and never opens on Couldn't reconnect. A healthy return (frames heard within the last second) changes nothing.
|
|
202
|
+
*/
|
|
203
|
+
private woke(now: number, hiddenMs: number): void {
|
|
204
|
+
const gap = now - this.tickAt;
|
|
205
|
+
this.tickAt = now;
|
|
206
|
+
if (gap < AWAY_MS && hiddenMs < AWAY_MS) return;
|
|
207
|
+
const how = hiddenMs >= AWAY_MS || this.awayFor?.how === 'hidden' ? 'hidden' : 'asleep', ms = Math.max(gap, hiddenMs, this.awayFor?.ms ?? 0);
|
|
208
|
+
if (this.phase === 'up') {
|
|
209
|
+
if (this.heardAt === null || now - this.heardAt < STRIP_MS) return;
|
|
210
|
+
this.awayFor = { ms, how }; this.because('hidden'); this.heardAt = now; this.lose(now);
|
|
211
|
+
} else if (this.phase === 'down' && !this.waitingForSeat) {
|
|
212
|
+
// the suspended gap moves the give-up clock on; hidden time with ticks running was dialled through, so it counts
|
|
213
|
+
if (gap >= AWAY_MS) { this.lostAt += gap; if (this.offlineAt !== null) this.offlineAt += gap; }
|
|
214
|
+
this.awayFor = { ms, how }; this.dialAt = now;
|
|
215
|
+
if (this.cause === 'silent' || this.cause === 'closed') this.because('hidden');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
183
218
|
/** The link is gone or no use: from now it is dialled, and a player's 35 s count from the last frame. */
|
|
184
219
|
private lose(now: number, close = true): void {
|
|
185
220
|
this.phase = 'down'; this.lostAt = this.heardAt ?? now; this.dialled = null; this.dialAt = now + (DIAL_WAITS_MS[0] ?? 0) * (1 + (this.random() * 2 - 1) * DIAL_JITTER);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mountUi } from '../ui/ownership';
|
|
2
|
-
import { mountBoostLook } from '../ui/hoverBoost';
|
|
2
|
+
import { mountBoostLook, mountBoostTag } from '../ui/hoverBoost';
|
|
3
3
|
import { app } from '../app/runtime';
|
|
4
4
|
import { capturePointer, listenDom, listenPage } from '../input/dom';
|
|
5
5
|
import type { Action, TouchStack, TouchVerbSpec } from '../input/InputService';
|
|
@@ -155,7 +155,8 @@ export class TouchControls {
|
|
|
155
155
|
this.weapons = weapons;
|
|
156
156
|
this.lock = lock;
|
|
157
157
|
this.active = force || IS_TOUCH;
|
|
158
|
-
|
|
158
|
+
// QA 11-15 row 9: a keyboard page has no HOVER tab, so BOOST stands on the left edge by itself while boost is on
|
|
159
|
+
if (!this.active) { mountBoostTag(document.getElementById('hud') ?? document.body, player, app.events, this.scope); return; }
|
|
159
160
|
const hud = document.getElementById('hud') ?? document.body;
|
|
160
161
|
hud.classList.add('touch');
|
|
161
162
|
const root = document.createElement('div');
|