@wildshard/engine 0.1.18 → 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.
Files changed (293) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/budgets/shard-size-baseline.json +10 -4
  3. package/index.html +6 -4
  4. package/lint/engine-sides.json +14 -0
  5. package/lint/ratchet.json +0 -68
  6. package/lint/ratchet.mjs +1 -4
  7. package/package.json +17 -15
  8. package/scripts/agent-sync.mjs +27 -8
  9. package/scripts/app-build/appCook.ts +8 -2
  10. package/scripts/app-build/catalogue.ts +10 -7
  11. package/scripts/app-build/gen.ts +22 -2
  12. package/scripts/app-build/isolation.d.mts +10 -0
  13. package/scripts/app-build/isolation.mjs +47 -0
  14. package/scripts/app-build/outputProducts.mjs +4 -0
  15. package/scripts/app-build/previousDeploy.d.mts +2 -0
  16. package/scripts/app-build/previousDeploy.mjs +10 -1
  17. package/scripts/app-build/serviceWorker.ts +10 -3
  18. package/scripts/app-build/splitOutput.mjs +4 -2
  19. package/scripts/app-build/standaloneOutput.d.mts +1 -1
  20. package/scripts/app-build/standaloneOutput.mjs +5 -3
  21. package/scripts/app-build/titlePreloads.d.mts +8 -0
  22. package/scripts/app-build/titlePreloads.mjs +69 -0
  23. package/scripts/app-build/worldMapAtlas.ts +10 -6
  24. package/scripts/app-build-pipeline.mjs +31 -3
  25. package/scripts/built-product.mjs +1 -1
  26. package/scripts/cell-mem-bench.mjs +81 -23
  27. package/scripts/check-custom-sections-zero.mjs +1 -1
  28. package/scripts/check-devserver.mjs +2 -0
  29. package/scripts/check-models.mjs +2 -0
  30. package/scripts/check-paths.allow.json +0 -115
  31. package/scripts/check-paths.mjs +2 -2
  32. package/scripts/check-platform-ratchets.mjs +2 -3
  33. package/scripts/chromium-keychain.d.mts +1 -1
  34. package/scripts/ci-static.sh +1 -1
  35. package/scripts/committed-fast-checks.mjs +0 -2
  36. package/scripts/content-sw-proof.mjs +2 -1
  37. package/scripts/cook-worker.mjs +9 -3
  38. package/scripts/cook.mjs +18 -5
  39. package/scripts/docs-inputs-proof.mjs +6 -6
  40. package/scripts/e7-voice-staging-proof.mjs +1 -1
  41. package/scripts/gate-related-tests.mjs +1 -1
  42. package/scripts/git-source-view.mjs +1 -1
  43. package/scripts/goldens/capture.mjs +17 -5
  44. package/scripts/grid-crossing-nightly.mjs +59 -0
  45. package/scripts/grid-crossing-qa.mjs +44 -0
  46. package/scripts/grid-crossing-ratchet.d.mts +6 -0
  47. package/scripts/grid-crossing-ratchet.mjs +52 -0
  48. package/scripts/grid-crossing-report.mjs +122 -0
  49. package/scripts/grid-crossing-stages.mjs +47 -0
  50. package/scripts/grid-crossing-tour.mjs +277 -0
  51. package/scripts/grid-crossing-walk-proof.mjs +124 -17
  52. package/scripts/host-ruler/roots.mjs +2 -2
  53. package/scripts/host-ruler.d.mts +91 -0
  54. package/scripts/host-ruler.mjs +565 -0
  55. package/scripts/live-prepush.py +3 -5
  56. package/scripts/loading-flow/benchmax.mjs +3 -1
  57. package/scripts/look-loop/test_look_loop.py +1 -38
  58. package/scripts/memory-proof.mjs +61 -6
  59. package/scripts/mmo-bots.mjs +8 -2
  60. package/scripts/net-lag-proof.mjs +219 -0
  61. package/scripts/night-market-kit-budget.mjs +2 -2
  62. package/scripts/offline-proof-rules.d.mts +2 -2
  63. package/scripts/offline-proof-rules.mjs +15 -4
  64. package/scripts/offline-proof.mjs +74 -13
  65. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  66. package/scripts/page-release/content.d.mts +9 -1
  67. package/scripts/page-release/content.mjs +131 -17
  68. package/scripts/page-release/flow.mjs +36 -10
  69. package/scripts/page-release/stamp-content.mjs +24 -0
  70. package/scripts/page-release.mjs +28 -6
  71. package/scripts/page-size.mjs +2 -1
  72. package/scripts/pin-packs.ts +1 -1
  73. package/scripts/pins.ts +4 -4
  74. package/scripts/precommit-checks.mjs +1 -7
  75. package/scripts/precommit-jobs.mjs +0 -1
  76. package/scripts/precommit-source.py +1 -9
  77. package/scripts/program-discovery.mjs +1 -1
  78. package/scripts/ring-cook.mjs +2 -1
  79. package/scripts/ring-step.ts +1 -1
  80. package/scripts/script-scenario-metrics.mjs +1 -1
  81. package/scripts/shard-output-content.d.mts +1 -1
  82. package/scripts/shard-output-content.mjs +2 -2
  83. package/scripts/shard-outputs.mjs +1 -1
  84. package/scripts/shard-public.mjs +1 -1
  85. package/scripts/shard-wire-meter.mjs +24 -9
  86. package/scripts/side-parity.mjs +4 -2
  87. package/scripts/standalone-smoke.mjs +8 -3
  88. package/scripts/tier-textures.mjs +22 -4
  89. package/scripts/tile-bake-report.mjs +1 -1
  90. package/scripts/tile-bakes.mjs +1 -1
  91. package/scripts/title-assets.generated.json +2 -0
  92. package/scripts/tsconfig.json +0 -2
  93. package/scripts/vendor/basisu/LICENSE +201 -0
  94. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  95. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  96. package/scripts/vitest-push-guards.config.ts +1 -1
  97. package/scripts/vps/harden-apply.sh +4 -1
  98. package/scripts/vps/harden-prometheus.sh +176 -0
  99. package/scripts/vps/harden.sh +16 -0
  100. package/scripts/vps/rebuild.sh +18 -0
  101. package/scripts/vps/wildshard-config +6 -2
  102. package/scripts/worker-client-play.mjs +6 -2
  103. package/scripts/worktree-reap.mjs +5 -5
  104. package/src/.oxlintrc.json +3 -182
  105. package/src/client/app/entry.ts +10 -2
  106. package/src/client/engine/boot/bootCache.ts +2 -2
  107. package/src/client/engine/boot/bootTrace.ts +12 -4
  108. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  109. package/src/client/engine/boot/clearDownloads.ts +5 -2
  110. package/src/client/engine/boot/contentRead.ts +11 -0
  111. package/src/client/engine/boot/gpuFiles.ts +4 -2
  112. package/src/client/engine/boot/lastEnd.ts +99 -12
  113. package/src/client/engine/boot/texturePack.ts +2 -2
  114. package/src/client/engine/net/netPlayer.ts +19 -2
  115. package/src/client/engine/net/otherPlayers.ts +55 -8
  116. package/src/client/engine/net/predictor.ts +33 -9
  117. package/src/client/engine/net/redial.ts +29 -6
  118. package/src/client/engine/pwa/cacheNames.ts +58 -1
  119. package/src/client/engine/pwa/sw.js +41 -11
  120. package/src/client/engine/render/dataLook.ts +152 -40
  121. package/src/client/engine/render/families/detail.ts +89 -0
  122. package/src/client/engine/render/families/pbr.ts +7 -1
  123. package/src/client/engine/render/look.ts +6 -0
  124. package/src/client/engine/render/lookLight.ts +103 -11
  125. package/src/client/engine/render/lookRender.ts +105 -0
  126. package/src/client/engine/saves/indexed.ts +2 -2
  127. package/src/client/engine/telemetry/browserErrors.ts +24 -3
  128. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  129. package/src/client/engine/ui/debugOptions.ts +1 -1
  130. package/src/client/engine/ui/lookLightOption.ts +10 -6
  131. package/src/client/engine/ui/namePrompt.ts +7 -0
  132. package/src/client/game/boot/audio.generated.ts +114 -114
  133. package/src/client/game/boot/bytes.generated.ts +118 -220
  134. package/src/client/game/boot/placedSpawn.ts +35 -0
  135. package/src/client/game/boot/spawnDownload.ts +25 -6
  136. package/src/client/game/boot/versions.generated.ts +7 -5
  137. package/src/client/game/devScene/hook.ts +291 -0
  138. package/src/client/game/grid/cellLoading.ts +12 -2
  139. package/src/client/game/grid/live.ts +112 -16
  140. package/src/client/game/grid/liveSession.ts +33 -2
  141. package/src/client/game/grid/mapAtlas.ts +18 -4
  142. package/src/client/game/grid/minimapBlend.ts +15 -5
  143. package/src/client/game/grid/oneWayIn.ts +5 -1
  144. package/src/client/game/grid/placedCells.ts +114 -12
  145. package/src/client/game/grid/placedContent.ts +85 -0
  146. package/src/client/game/grid/prefetch.ts +9 -1
  147. package/src/client/game/grid/productInputs.ts +3 -1
  148. package/src/client/game/grid/productLeases.ts +4 -1
  149. package/src/client/game/grid/products.ts +8 -4
  150. package/src/client/game/grid/roadLook.ts +24 -15
  151. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  152. package/src/client/game/grid/roadResources.ts +24 -0
  153. package/src/client/game/grid/roadSign.worker.ts +4 -3
  154. package/src/client/game/grid/roadSignPaint.ts +16 -5
  155. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  156. package/src/client/game/grid/roadSignScale.ts +8 -0
  157. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  158. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  159. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  160. package/src/client/game/grid/roadTileWriter.ts +2 -1
  161. package/src/client/game/grid/screenReports.ts +39 -0
  162. package/src/client/game/grid/session.ts +20 -4
  163. package/src/client/game/grid/softWallLook.ts +25 -8
  164. package/src/client/game/mainMenu.ts +6 -2
  165. package/src/client/game/plugin/context.ts +2 -1
  166. package/src/client/game/plugin/followedMovers.ts +7 -1
  167. package/src/client/game/quest/figures.ts +2 -0
  168. package/src/client/game/session/finish.ts +6 -0
  169. package/src/client/game/shardfile/assetCache.ts +4 -4
  170. package/src/client/game/shardfile/client.ts +4 -1
  171. package/src/client/game/shardfile/clientAssets.ts +9 -5
  172. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  173. package/src/client/game/shardfile/clientWater.ts +51 -9
  174. package/src/client/game/shardfile/clientWorker.ts +19 -7
  175. package/src/client/game/shardfile/look.ts +8 -3
  176. package/src/client/game/shardfile/product.ts +34 -7
  177. package/src/client/game/shardfile/productChecks.ts +2 -2
  178. package/src/client/game/shardfile/productCost.ts +2 -2
  179. package/src/client/game/shardfile/readAsset.ts +2 -2
  180. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  181. package/src/client/game/shardfile/seatGrace.ts +9 -0
  182. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  183. package/src/client/game/systems/npc/figureRows.ts +9 -0
  184. package/src/client/host/online/doctor.ts +2 -0
  185. package/src/client/host/online/linkScreens.ts +30 -4
  186. package/src/client/host/standalone/shell.ts +4 -0
  187. package/src/cook/game/astc6Encode.ts +55 -0
  188. package/src/cook/game/astc6Wasm.ts +176 -0
  189. package/src/cook/game/cookJob.ts +30 -6
  190. package/src/cook/game/cookWorker.ts +38 -11
  191. package/src/cook/game/entryTotals.ts +51 -24
  192. package/src/cook/game/shardCook.ts +35 -7
  193. package/src/cook/game/spawnParts.ts +33 -8
  194. package/src/cook/game/tierTextures.ts +87 -14
  195. package/src/server/engine/ai/bossContenders.ts +27 -3
  196. package/src/server/engine/ai/phases.ts +1 -1
  197. package/src/server/engine/entities/creatureRefill.ts +9 -2
  198. package/src/server/engine/net/ledgerBook.ts +2 -0
  199. package/src/server/engine/net/room.ts +15 -0
  200. package/src/server/engine/sim/respawn.ts +8 -0
  201. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  202. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  203. package/src/server/game/boss/native.ts +2 -1
  204. package/src/server/game/boss/nativeWake.ts +9 -5
  205. package/src/server/game/boss/openArenaNative.ts +2 -2
  206. package/src/server/game/boss/openArenaRoom.ts +3 -1
  207. package/src/server/game/grid/room.ts +44 -3
  208. package/src/server/game/grid/simulation.ts +23 -0
  209. package/src/server/game/population/mixedRoster.ts +11 -3
  210. package/src/server/game/population/nativeBake.ts +8 -3
  211. package/src/server/game/population/nativeReturns.ts +6 -3
  212. package/src/server/game/population/roster.ts +5 -3
  213. package/src/server/game/quest/eliteDrops.ts +15 -4
  214. package/src/server/game/quest/nativeChapter.ts +1 -1
  215. package/src/server/game/quest/nativeComposition.ts +5 -1
  216. package/src/server/game/riding/nativeTaming.ts +10 -6
  217. package/src/server/game/riding/wildRefill.ts +3 -2
  218. package/src/server/game/shardfile/bossRow.ts +4 -2
  219. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  220. package/src/server/host/bake/headlessWorker.ts +1 -1
  221. package/src/server/host/dedicated/cellHost.ts +98 -16
  222. package/src/server/host/dedicated/cellProtocol.ts +16 -1
  223. package/src/server/host/dedicated/cellWorker.ts +8 -5
  224. package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
  225. package/src/server/host/dedicated/gridCells.ts +15 -6
  226. package/src/server/host/dedicated/loopLag.ts +21 -0
  227. package/src/server/host/dedicated/main.ts +13 -5
  228. package/src/server/host/dedicated/packReader.ts +3 -3
  229. package/src/server/host/dedicated/placementFile.ts +3 -2
  230. package/src/server/host/dedicated/roadRoom.ts +34 -4
  231. package/src/server/host/dedicated/serverMetrics.ts +126 -0
  232. package/src/server/host/dedicated/socketPump.ts +21 -4
  233. package/src/server/host/dedicated/workerTable.ts +15 -4
  234. package/src/server/host/dedicated/world.ts +65 -7
  235. package/src/server/host/headless.ts +1 -1
  236. package/src/server/host/headlessRuntime.ts +1 -1
  237. package/src/server/host/standalone/roadWorld.ts +15 -3
  238. package/src/server/host/standalone/serverHost.ts +4 -1
  239. package/src/server/host/standalone/serverProduct.ts +41 -11
  240. package/src/shared/engine/ai/BossBrain.ts +8 -0
  241. package/src/shared/game/boss/wake.ts +6 -0
  242. package/src/shared/game/devColliders.ts +47 -0
  243. package/src/shared/game/eliteSystem.ts +8 -0
  244. package/src/shared/game/grid/allocator.ts +3 -0
  245. package/src/shared/game/grid/placementRows.ts +5 -2
  246. package/src/shared/game/plugin/bossRecord.ts +3 -2
  247. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  248. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  249. package/src/shared/game/shardfile/packReads.ts +28 -3
  250. package/src/shared/game/shardfile/serverPack.ts +9 -0
  251. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  252. package/src/shared/host/formatJsonSchema.ts +2 -2
  253. package/src/tsconfig.json +1 -27
  254. package/lint/host-reviews.json +0 -14
  255. package/lint/listed-view-code.json +0 -13
  256. package/lint/platform-pending-users.json +0 -2520
  257. package/lint/platform-pending-users.md +0 -18
  258. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  259. package/scripts/check-closed-components.d.mts +0 -7
  260. package/scripts/check-closed-components.mjs +0 -87
  261. package/scripts/g571-hosts.d.mts +0 -3
  262. package/scripts/g571-hosts.mjs +0 -54
  263. package/scripts/host-ruler/register-migrate.mjs +0 -242
  264. package/scripts/listed-view-code.d.mts +0 -7
  265. package/scripts/listed-view-code.mjs +0 -93
  266. package/scripts/look-loop/fit-lut.py +0 -142
  267. package/scripts/look-loop/palette-delta.py +0 -183
  268. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  269. package/scripts/look-loop/regions/far-reach.json +0 -225
  270. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  271. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  272. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  273. package/scripts/platform-chargebacks.d.mts +0 -9
  274. package/scripts/platform-chargebacks.mjs +0 -135
  275. package/scripts/shard-component-spans.d.mts +0 -15
  276. package/scripts/shard-component-spans.mjs +0 -18
  277. package/scripts/shard-components.d.mts +0 -16
  278. package/scripts/shard-components.mjs +0 -363
  279. package/scripts/shard-platform-hosts.d.mts +0 -2
  280. package/scripts/shard-platform-hosts.mjs +0 -93
  281. package/scripts/shard-platform-sections.d.mts +0 -2
  282. package/scripts/shard-platform-sections.mjs +0 -9
  283. package/scripts/shard-platform.d.mts +0 -76
  284. package/scripts/shard-platform.mjs +0 -1072
  285. package/src/.oxfmtrc.json +0 -48
  286. package/src/scripts/ask-new.sh +0 -29
  287. package/src/scripts/asks.mjs +0 -142
  288. package/src/scripts/herdr-prompt.sh +0 -34
  289. package/src/scripts/herdr-question-open.sh +0 -67
  290. package/src/scripts/md-wrap.mjs +0 -229
  291. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  292. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  293. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
@@ -15,7 +15,8 @@ import type { GridCell } from '../../../shared/game/grid/assembly';
15
15
  import { putRoadGrain, roadGrainSteps, type RoadGrainSource } from './roadGrain';
16
16
  import { packRoadSignPixels } from './roadSignPixels';
17
17
  import { paintRoadSignCanvas, roadSignPaintLayout, roadSignLineKey as lineKey, SIGN_LINE_W as LINE_W, SIGN_LINE_H as LINE_H, type RoadSignSource } from './roadSignPaint';
18
- import { ownRoadMesh } from './roadResources';
18
+ import { ownRoadMesh, type RoadMapShare } from './roadResources';
19
+ import { roadSignScale } from './roadSignScale';
19
20
  import { ROAD_SKY } from './frameModel';
20
21
  import { coverageMaterial, coverageTable, gpuOnlyTextureBytes, uniformPart, type CoverageColours, type SolidPart } from './roadSolid';
21
22
  import { bytePlan, cullIntoSteps, gpuOnlyRoad, meshBytesSteps, type CullSource, type RoadCuller } from './roadCull';
@@ -45,6 +46,8 @@ export interface RoadLookInput {
45
46
  readonly overlayLight?: RoadOverlayLight;
46
47
  /** Bind a source's shrink-only charge after its backing is durable. */
47
48
  readonly retireGeometry?: (mesh: Mesh, id: string, retainedBytes: number) => void;
49
+ /** PZ24: the road system's shared asphalt and junction maps (absent: each build paints its own) */
50
+ readonly maps?: RoadMapShare;
48
51
  }
49
52
 
50
53
  /**
@@ -370,20 +373,20 @@ const SIGN_BLUE_FROM_RED = 0.45;
370
373
  const signCoverage = (): CoverageColours => ({ from: SIGN_GREEN, to: WHITE, blueFromRed: SIGN_BLUE_FROM_RED, sentinel: { v: GREY_V - 0.5, colour: SIGN_GREY } });
371
374
  /** The atlas's layout, pure (its size and every uv), so the sign mesh and its byte plan never need the canvas. */
372
375
  interface SignAtlasLayout {
373
- readonly keys: readonly string[]; readonly lines: ReadonlyMap<string, SignLine>; readonly width: number; readonly height: number;
376
+ readonly keys: readonly string[]; readonly lines: ReadonlyMap<string, SignLine>; readonly width: number; readonly height: number; readonly scale: number;
374
377
  readonly slot: (k: number) => [number, number];
375
378
  readonly cell: (line: SignLine) => readonly [number, number, number, number];
376
379
  readonly swatch: Readonly<Record<'green' | 'grey' | 'white', readonly [number, number]>>;
377
380
  }
378
- function signAtlasLayout(signs: readonly RoadSign[]): SignAtlasLayout {
379
- const { keys, lines, width: W, height: H, slot } = roadSignPaintLayout(signs);
381
+ function signAtlasLayout(signs: readonly RoadSign[], scale: number): SignAtlasLayout {
382
+ const { keys, lines, width: W, height: H, slot } = roadSignPaintLayout(signs, scale), cellW = LINE_W * scale, cellH = LINE_H * scale;
380
383
  const [sx, sy] = slot(keys.length); // swatches in the last cell
381
384
  const uv = (px: number, py: number): readonly [number, number] => [px / W, 1 - py / H];
382
385
  const index = new Map(keys.map((k, i) => [k, i]));
383
386
  return {
384
- keys, lines, width: W, height: H, slot,
385
- cell: (line) => { const [x, y] = slot(index.get(lineKey(line)) ?? 0); return [x / W, 1 - (y + LINE_H) / H, (x + LINE_W) / W, 1 - y / H]; },
386
- swatch: { green: uv(sx + 32, sy + LINE_H / 2), grey: [0.5, GREY_V], white: uv(sx + 160, sy + LINE_H / 2) },
387
+ keys, lines, width: W, height: H, scale, slot,
388
+ cell: (line) => { const [x, y] = slot(index.get(lineKey(line)) ?? 0); return [x / W, 1 - (y + cellH) / H, (x + cellW) / W, 1 - y / H]; },
389
+ swatch: { green: uv(sx + 32 * scale, sy + cellH / 2), grey: [0.5, GREY_V], white: uv(sx + 160 * scale, sy + cellH / 2) },
387
390
  };
388
391
  }
389
392
  function signAtlasTexture(atlas: SignAtlasLayout, signs?: RoadSignSource): DataTexture {
@@ -433,6 +436,8 @@ interface TexturedSource {
433
436
  readonly overlay: boolean;
434
437
  /** GPU bytes per texel (4: an RGBA8 canvas; 2: the sign atlas's RG8 array) and what holds the texels until upload */
435
438
  readonly texelBytes: number; readonly source: 'canvas' | 'data';
439
+ /** PZ24: its map depends on the grain only, so every build of one road system shares one upload */
440
+ readonly shared: boolean;
436
441
  readonly material: (map: Texture) => MeshLambertMaterial;
437
442
  }
438
443
  // the map is the emissive map too, black until RoadOverlayLight lights it inside a cell (one program either way)
@@ -440,11 +445,11 @@ const overlayMaterial = (map: Texture): MeshLambertMaterial => new MeshLambertMa
440
445
  /** A texture painted in one stretch, as a paint step. */
441
446
  function* paintNow(paint: () => Texture): Generator<void, Texture> { yield; return paint(); }
442
447
  function texturedSources(layout: RoadLayout, home: GridCell, grain?: RoadGrainSource, signs?: RoadSignSource): TexturedSource[] {
443
- const atlas = signAtlasLayout(layout.signs);
448
+ const atlas = signAtlasLayout(layout.signs, roadSignScale());
444
449
  return [
445
- { id: 'road.asphalt', name: 'grid-asphalt', mesher: asphalt(layout, home), width: 1024, height: 512, paint: () => roadTextureSteps(grain), overlay: true, texelBytes: 4, source: 'canvas', material: overlayMaterial },
446
- { id: 'road.junctions', name: 'grid-junctions', mesher: junctionAsphalt(layout, home), width: 1024, height: 1024, paint: () => junctionTextureSteps(grain), overlay: true, texelBytes: 4, source: 'canvas', material: overlayMaterial },
447
- { id: 'road.signs', name: 'grid-signs', mesher: signMesher(layout.signs, home, atlas), width: atlas.width, height: atlas.height, paint: () => paintNow(() => signAtlasTexture(atlas, signs)), overlay: false, texelBytes: 2, source: 'data', material: (map) => coverageMaterial(map, signCoverage(), 'g227-grid-sign-cover') },
450
+ { id: 'road.asphalt', name: 'grid-asphalt', mesher: asphalt(layout, home), width: 1024, height: 512, paint: () => roadTextureSteps(grain), overlay: true, texelBytes: 4, source: 'canvas', shared: true, material: overlayMaterial },
451
+ { id: 'road.junctions', name: 'grid-junctions', mesher: junctionAsphalt(layout, home), width: 1024, height: 1024, paint: () => junctionTextureSteps(grain), overlay: true, texelBytes: 4, source: 'canvas', shared: true, material: overlayMaterial },
452
+ { id: 'road.signs', name: 'grid-signs', mesher: signMesher(layout.signs, home, atlas), width: atlas.width, height: atlas.height, paint: () => paintNow(() => signAtlasTexture(atlas, signs)), overlay: false, texelBytes: 2, source: 'data', shared: false, material: (map) => coverageMaterial(map, signCoverage(), 'g227-grid-sign-cover') },
448
453
  ];
449
454
  }
450
455
 
@@ -461,22 +466,26 @@ export function* installRoadLookSteps(input: RoadLookInput): Generator<void, Roa
461
466
  scene.add(group);
462
467
  scope.onDispose(() => { group.removeFromParent(); });
463
468
  for (const source of sources) {
469
+ const share = source.shared ? input.maps : undefined;
464
470
  const build = function* build(owner: LookScope): Generator<void, Mesh> {
465
471
  yield;
466
- const map = yield* source.paint(), material = source.material(map);
472
+ const held = share?.take(source.id), map = held ?? (yield* source.paint()), material = source.material(map);
473
+ if (share !== undefined && held === undefined) share.hold(source.id, map);
467
474
  const mesh = new Mesh(source.mesher.geometry(), material);
468
- ownRoadMesh(owner, mesh, [map]);
475
+ ownRoadMesh(owner, mesh, share === undefined ? [map] : []);
476
+ if (share !== undefined) owner.onDispose(() => { share.release(source.id, map); });
469
477
  mesh.name = source.name; if (source.overlay) { mesh.receiveShadow = true; input.overlayLight?.add(material, owner); }
470
478
  mesh.castShadow = false; mesh.matrixAutoUpdate = false; mesh.updateMatrix();
471
479
  if (cull !== undefined) yield* cullIntoSteps(cull, mesh); else hook?.(mesh);
472
480
  group.add(mesh);
473
- if (admission !== undefined) gpuOnlyRoad(mesh, [map]); // G144: admitted, its vertex arrays and canvas go on upload (nothing repaints it)
481
+ if (admission !== undefined) gpuOnlyRoad(mesh, held === undefined ? [map] : []); // G144: admitted, its vertex arrays and canvas go on upload (nothing repaints it)
474
482
  return mesh;
475
483
  };
476
484
  if (admission === undefined) yield* build(scope);
477
485
  else {
478
486
  const bytes = yield* meshBytesSteps([mesherSource(source.mesher)], ROAD_FLOATS, cull === undefined ? undefined : { pitch: cull.pitch, ...(cull.tileSize === undefined ? {} : { tileSize: cull.tileSize }) }, true);
479
- const textures = gpuOnlyTextureBytes(source.width, source.height, 1, source.source, source.texelBytes);
487
+ // a shared map another build of this road already holds costs this build nothing (PZ24)
488
+ const textures = share?.has(source.id) === true ? { jsBytes: 0, gpuBytes: 0 } : gpuOnlyTextureBytes(source.width, source.height, 1, source.source, source.texelBytes);
480
489
  const plan = bytePlan(source.id, bytes, textures);
481
490
  const mesh = yield* allocateRenderSteps(admission, plan, build);
482
491
  if (mesh === undefined) throw new Error('Road construction cancelled');
@@ -16,7 +16,7 @@ import type { RoadSignSource } from './roadSignPaint';
16
16
  */
17
17
  import { Mesh, type Camera, type Object3D } from 'three';
18
18
  import { CONTENT_CAPS } from '@wildshard/engine/core/config';
19
- import { ownRoadMesh } from './roadResources';
19
+ import { ownRoadMesh, type RoadMapShare } from './roadResources';
20
20
  import type { RoadTileBacking } from './roadTileBacking';
21
21
  import type { RoadGrainSource } from './roadGrain';
22
22
  import { diagnosticNow } from '@wildshard/engine/core/clock';
@@ -57,6 +57,8 @@ export interface PlatformRoadInput {
57
57
  readonly within?: (x: number, z: number) => boolean;
58
58
  /** build the void floor and its rail (default true; one build of a split road draws it) */
59
59
  readonly voidFloor?: boolean;
60
+ /** PZ24: one asphalt and one junction map for every build of this road (a split road's halves pass the same share) */
61
+ readonly maps?: RoadMapShare;
60
62
  }
61
63
  /** The readouts and the roots the road budget measures. */
62
64
  export interface PlatformRoad {
@@ -152,7 +154,7 @@ function* platformRoadSteps(input: PlatformRoadInput): Generator<void, PlatformR
152
154
  const overlayLight = new RoadOverlayLight();
153
155
  const road = yield* installRoadLookSteps({ layout, home, scene, scope, solid, cull: culler, admission, overlayLight, retireGeometry,
154
156
  ...(input.grain === undefined ? {} : { grain: input.grain }),
155
- ...(input.signs === undefined ? {} : { signs: input.signs }) });
157
+ ...(input.signs === undefined ? {} : { signs: input.signs }), ...(input.maps === undefined ? {} : { maps: input.maps }) });
156
158
  const voidLook = input.voidFloor === false ? null : installVoidLook({ rail: layout.rail, edge: layout.edge, holes: layout.holes, home, scene, scope, solid, admission });
157
159
  // this build's own boulevard group (a split road adds one per build)
158
160
  let boulevard: Object3D | undefined;
@@ -13,3 +13,27 @@ export function ownRoadMesh(scope: LookScope, mesh: Mesh, textures: readonly Tex
13
13
  scope.onDispose(() => { mesh.geometry.dispose(); });
14
14
  scope.onDispose(() => { mesh.removeFromParent(); });
15
15
  }
16
+
17
+ /**
18
+ * PZ24 (meta PAGE-SIZE): one upload of each road canvas that depends on the grain only (the asphalt and the junction), shared
19
+ * by every build of one road system: A1's ring-first halves painted and uploaded both twice, 8.4 MB of the iPhone profile's
20
+ * GPU texture on Driftwood. Each user takes a count; the last release disposes the texture, so a half retired before the
21
+ * other never pulls the map from under it.
22
+ */
23
+ export class RoadMapShare {
24
+ private readonly held = new Map<string, { readonly texture: Texture; users: number }>();
25
+ /** a held map for `id`, counted for the caller, or undefined (paint it, then `hold` it) */
26
+ take(id: string): Texture | undefined {
27
+ const row = this.held.get(id); if (row === undefined) return undefined;
28
+ row.users++; return row.texture;
29
+ }
30
+ has(id: string): boolean { return this.held.has(id); }
31
+ /** the first user's freshly painted map, counted for it */
32
+ hold(id: string, texture: Texture): void { if (!this.held.has(id)) this.held.set(id, { texture, users: 1 }); }
33
+ release(id: string, texture: Texture): void {
34
+ const row = this.held.get(id);
35
+ if (row?.texture !== texture) { texture.dispose(); return; }
36
+ if (--row.users > 0) return;
37
+ this.held.delete(id); texture.dispose();
38
+ }
39
+ }
@@ -1,5 +1,5 @@
1
1
  import type { SignLine } from '../../../shared/game/grid/roadLayout';
2
- import { paintRoadSignCanvas, roadSignPaintLayout } from './roadSignPaint';
2
+ import { paintRoadSignCanvas, roadSignPaintLayout, SIGN_SCALES } from './roadSignPaint';
3
3
  import { packRoadSignPixels } from './roadSignPixels';
4
4
  import { installWorkerBootTiming } from '@wildshard/engine/boot/workerTiming';
5
5
 
@@ -17,9 +17,10 @@ self.onmessage = (event: MessageEvent<unknown>): void => {
17
17
  try {
18
18
  const input = event.data;
19
19
  if (typeof input !== 'object' || input === null) throw new Error('Invalid sign job');
20
- const rows: unknown = Reflect.get(input, 'rows'), red: unknown = Reflect.get(input, 'red'), green: unknown = Reflect.get(input, 'green');
20
+ const rows: unknown = Reflect.get(input, 'rows'), red: unknown = Reflect.get(input, 'red'), green: unknown = Reflect.get(input, 'green'), scale: unknown = Reflect.get(input, 'scale') ?? 1;
21
21
  if (!signLines(rows) || !(red instanceof Uint8Array) || !(green instanceof Uint8Array) || red.length !== 256 || green.length !== 256) throw new Error('Invalid sign planes');
22
- const layout = roadSignPaintLayout(rows.map(line => ({ lines: [line] })));
22
+ if (typeof scale !== 'number' || !SIGN_SCALES.includes(scale)) throw new Error('Invalid sign scale');
23
+ const layout = roadSignPaintLayout(rows.map(line => ({ lines: [line] })), scale);
23
24
  if (layout.width * layout.height > 16 * 1024 * 1024) throw new Error('Worker sign plane too large');
24
25
  const context = new OffscreenCanvas(layout.width, layout.height).getContext('2d');
25
26
  if (context === null) throw new Error('Worker sign has no 2D canvas');
@@ -1,23 +1,33 @@
1
1
  import type { RoadSign, SignLine } from '../../../shared/game/grid/roadLayout';
2
2
 
3
3
  export const SIGN_LINE_W = 512, SIGN_LINE_H = 64;
4
+ /** PZ24: the atlas's texel scales. 1 is the painted size; the phone tier's 0.5 holds a quarter of the texels (Driftwood's
5
+ * two halves' atlases were 28.8 MB of GPU texture at 1, 7.2 MB at 0.5): the same painting, drawn half size. */
6
+ export const SIGN_SCALES: readonly number[] = [1, 0.5];
4
7
  export interface RoadSignPaintLayout {
5
- readonly keys: readonly string[]; readonly lines: ReadonlyMap<string, SignLine>; readonly width: number; readonly height: number;
8
+ readonly keys: readonly string[]; readonly lines: ReadonlyMap<string, SignLine>;
9
+ /** texels; `slot` and the cell size are texels too (a line cell is `SIGN_LINE_W * scale` by `SIGN_LINE_H * scale`) */
10
+ readonly width: number; readonly height: number; readonly scale: number;
6
11
  readonly slot: (index: number) => [number, number];
7
12
  }
8
13
  export type RoadSignSource = (layout: RoadSignPaintLayout) => Uint8Array<ArrayBuffer> | undefined;
9
14
  export function roadSignLineKey(line: SignLine): string { return `${line.arrow}|${line.names.join(' · ')}|${line.metres === null ? '' : String(line.metres)}`; }
10
15
  /** Original first-key ordering and last matching line, without canvas or renderer state. */
11
- export function roadSignPaintLayout(signs: readonly Pick<RoadSign, 'lines'>[]): RoadSignPaintLayout {
16
+ export function roadSignPaintLayout(signs: readonly Pick<RoadSign, 'lines'>[], scale = 1): RoadSignPaintLayout {
17
+ if (!SIGN_SCALES.includes(scale)) throw new Error(`No road sign atlas scale ${String(scale)}`);
12
18
  const keys = [...new Set(signs.flatMap(s => s.lines.map(roadSignLineKey)))], lines = new Map<string, SignLine>();
13
19
  for (const sign of signs) for (const line of sign.lines) lines.set(roadSignLineKey(line), line);
14
- const width = 1024, perRow = width / SIGN_LINE_W, height = Math.ceil((keys.length + 1) / perRow) * SIGN_LINE_H;
15
- return { keys, lines, width, height, slot: k => [(k % perRow) * SIGN_LINE_W, Math.floor(k / perRow) * SIGN_LINE_H] };
20
+ const perRow = 1024 / SIGN_LINE_W, cellW = SIGN_LINE_W * scale, cellH = SIGN_LINE_H * scale;
21
+ const width = 1024 * scale, height = Math.ceil((keys.length + 1) / perRow) * cellH;
22
+ return { keys, lines, width, height, scale, slot: k => [(k % perRow) * cellW, Math.floor(k / perRow) * cellH] };
16
23
  }
17
24
  /** Exact original commands, font, coordinates and canvas state on either native 2D surface. */
18
25
  export function paintRoadSignCanvas(g: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, atlas: RoadSignPaintLayout): void {
19
- const { keys, lines, slot, width: W, height: H } = atlas, LINE_W = SIGN_LINE_W, LINE_H = SIGN_LINE_H, WHITE = '#e9ebe6';
26
+ const { keys, lines, width: W, height: H, scale } = atlas, LINE_W = SIGN_LINE_W, LINE_H = SIGN_LINE_H, WHITE = '#e9ebe6';
27
+ // the same commands in painted units at every scale (PZ24): only the transform shrinks them
28
+ const slot = (k: number): [number, number] => { const [x, y] = atlas.slot(k); return [x / scale, y / scale]; };
20
29
  g.fillStyle = '#0d6b3c'; g.fillRect(0, 0, W, H);
30
+ g.save(); g.scale(scale, scale);
21
31
  keys.forEach((key, k) => {
22
32
  const line = lines.get(key); if (line === undefined) return;
23
33
  const [x, y] = slot(k), mid = y + LINE_H / 2;
@@ -35,4 +45,5 @@ export function paintRoadSignCanvas(g: CanvasRenderingContext2D | OffscreenCanva
35
45
  });
36
46
  const [sx, sy] = slot(keys.length);
37
47
  g.fillStyle = WHITE; g.fillRect(sx + 128, sy, 64, SIGN_LINE_H);
48
+ g.restore();
38
49
  }
@@ -3,12 +3,13 @@ import type { ResidencyAllocator } from '../../../shared/game/grid/allocator';
3
3
  import type { RoadSign } from '../../../shared/game/grid/roadLayout';
4
4
  import { coverageTable } from './roadSolid';
5
5
  import { roadSignPaintLayout, type RoadSignSource } from './roadSignPaint';
6
+ import { roadSignScale } from './roadSignScale';
6
7
 
7
8
  export interface RoadSignPreparation { readonly ready: Promise<void>; readonly get: RoadSignSource; readonly release: () => void }
8
9
  /** One road bank's scoped coverage; exact original main-thread painting remains the fallback. */
9
10
  export function startRoadSigns(parent: Scope, allocator: ResidencyAllocator, home: string, signs: readonly RoadSign[], phase: 'initial' | 'outer' = 'initial'): RoadSignPreparation | undefined {
10
11
  if (typeof Worker !== 'function' || typeof OffscreenCanvas !== 'function' || parent.disposed || parent.disposing) return undefined;
11
- const layout = roadSignPaintLayout(signs), rows = [...layout.lines.values()], signature = JSON.stringify(rows), count = layout.width * layout.height;
12
+ const layout = roadSignPaintLayout(signs, roadSignScale()), rows = [...layout.lines.values()], signature = JSON.stringify(rows), count = layout.width * layout.height;
12
13
  if (rows.length > 2048 || count > 16 * 1024 * 1024 || signature.length > 131072) return undefined;
13
14
  // Canvas + RGBA readback + final RG8 + conversion lookup; duplicated job text is bounded too.
14
15
  // T10: claimed at once: a stepped eviction here (6369cf2558, retired with the rest of it) kept the evicted world
@@ -38,8 +39,8 @@ export function startRoadSigns(parent: Scope, allocator: ResidencyAllocator, hom
38
39
  listeners.push(scope.listen(worker, 'messageerror', () => { failed('transfer failed'); }));
39
40
  deadline = scope.timeout(30_000, () => { failed('worker deadline'); });
40
41
  const colours = { from: '#0d6b3c', to: '#e9ebe6', blueFromRed: 0.45, sentinel: { v: 1.5, colour: '#6f7378' } };
41
- worker.postMessage({ rows, red: coverageTable(colours, 0), green: coverageTable(colours, 1) }, { transfer: [] });
42
+ worker.postMessage({ rows, scale: layout.scale, red: coverageTable(colours, 0), green: coverageTable(colours, 1) }, { transfer: [] });
42
43
  } catch (error) { failed(error instanceof Error ? error.message : String(error)); }
43
- return { ready, get: current => settled && current.width === layout.width && current.height === layout.height
44
+ return { ready, get: current => settled && current.width === layout.width && current.height === layout.height && current.scale === layout.scale
44
45
  && JSON.stringify([...current.lines.values()]) === signature ? plane : undefined, release: () => { scope.dispose(); } };
45
46
  }
@@ -0,0 +1,8 @@
1
+ import { TIER } from '@wildshard/engine/core/tier';
2
+
3
+ /**
4
+ * PZ24 (meta PAGE-SIZE): the road sign atlas's texel scale for this page's tier. The phone paints it half size: Driftwood's
5
+ * two road halves held 28.8 MB of sign atlas on the iPhone profile (1024x4096 and 1024x6464 RG8 with mips), a quarter of
6
+ * that at 0.5: a sign line is 256x32 texels across a 3.4 m board. The desktop keeps the painted size. Read at each build, so a tier change takes effect with the next road.
7
+ */
8
+ export function roadSignScale(): number { return TIER === 'phone' ? 0.5 : 1; }
@@ -2,6 +2,7 @@ import { roadTileCache } from './roadTileArchive';
2
2
  import { captureJobTiles } from './roadTileCaptureJob';
3
3
  import type { CaptureJob } from './roadTileCaptureWorker';
4
4
  import { installWorkerBootTiming } from '@wildshard/engine/boot/workerTiming';
5
+ import { setCacheChannel } from '@wildshard/engine/pwa/cacheNames';
5
6
 
6
7
  installWorkerBootTiming('road-tile-capture');
7
8
 
@@ -10,5 +11,6 @@ async function answer(job: CaptureJob): Promise<void> {
10
11
  try { self.postMessage({ id: job.id, ok: true, ...await captureJobTiles(job, roadTileCache(caches, job.origin)) }, { transfer: [] }); }
11
12
  catch (error: unknown) { self.postMessage({ id: job.id, ok: false, error: error instanceof Error ? error.message : String(error) }, { transfer: [] }); }
12
13
  }
13
- self.onmessage = (event: MessageEvent<CaptureJob>): void => { void answer(event.data); };
14
+ // OF12: this worker has no document stamp; each job names the page's cache channel
15
+ self.onmessage = (event: MessageEvent<CaptureJob>): void => { setCacheChannel(Reflect.get(event.data, 'channel')); void answer(event.data); };
14
16
  self.postMessage({ ready: true }, { transfer: [] });
@@ -1,3 +1,4 @@
1
+ import { pageCacheChannel } from '@wildshard/engine/pwa/cacheNames';
1
2
  /** DL11: the road tile capture's worker, owned by the backing's scope. A source's compaction, coarse merge and
2
3
  * archive writes run there on a copy of its arrays, so the page publishes (and uploads) the source at once and
3
4
  * only the references come back. Until the worker says it is running, and whenever it cannot start, the backing
@@ -69,7 +70,7 @@ export class RoadTileCaptureWorker {
69
70
  const worker = this.worker; if (!this.usable() || worker === undefined) return null;
70
71
  return new Promise<CaptureResult>((resolve, reject) => {
71
72
  this.waiting.set(job.id, { job, resolve, reject, refused });
72
- worker.postMessage(job, { transfer: [] });
73
+ worker.postMessage({ ...job, channel: pageCacheChannel() }, { transfer: [] }); // OF12: the worker's cache channel
73
74
  });
74
75
  }
75
76
  private message(reply: unknown): void {
@@ -1,4 +1,4 @@
1
- import { ASSET_CACHE_NAME } from '@wildshard/engine/pwa/cacheNames';
1
+ import { assetCacheName, setCacheChannel } from '@wildshard/engine/pwa/cacheNames';
2
2
  import { installWorkerBootTiming } from '@wildshard/engine/boot/workerTiming';
3
3
 
4
4
  installWorkerBootTiming('road-tile-write');
@@ -11,10 +11,12 @@ self.onmessage = (event: MessageEvent<unknown>): void => {
11
11
  if (typeof message !== 'object' || message === null) return;
12
12
  const id: unknown = Reflect.get(message, 'id'), url: unknown = Reflect.get(message, 'url'), bytes: unknown = Reflect.get(message, 'bytes');
13
13
  if (typeof id !== 'number' || typeof url !== 'string' || !(bytes instanceof Uint8Array) || !(bytes.buffer instanceof ArrayBuffer)) return;
14
+ // OF12: this worker has no document stamp; the page names its channel's cache
15
+ setCacheChannel(Reflect.get(message, 'channel'));
14
16
  const body = new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
15
17
  void (async (): Promise<void> => {
16
18
  try {
17
- await (await caches.open(ASSET_CACHE_NAME)).put(url, new Response(body, {
19
+ await (await caches.open(assetCacheName())).put(url, new Response(body, {
18
20
  headers: { 'content-type': 'application/octet-stream', 'content-length': String(body.length) },
19
21
  }));
20
22
  self.postMessage({ id, ok: true }, { transfer: [] });
@@ -1,3 +1,4 @@
1
+ import { pageCacheChannel } from '@wildshard/engine/pwa/cacheNames';
1
2
  /** DL11: road archive writes go to one dedicated worker that owns the Cache
2
3
  * Storage put; the page transfers each freshly encoded body instead of copying
3
4
  * it. Reads, hashes and URLs are the original store's. Until the worker says it
@@ -61,7 +62,7 @@ export function roadTileWriter(scope: Scope, storage: Pick<CacheStorage, 'open'>
61
62
  const id = next++;
62
63
  return new Promise<boolean>(resolve => {
63
64
  waiting.set(id, { hash, finish: resolve });
64
- target.postMessage({ id, url: roadTileUrl(origin, hash), bytes }, { transfer: [bytes.buffer] });
65
+ target.postMessage({ id, url: roadTileUrl(origin, hash), bytes, channel: pageCacheChannel() }, { transfer: [bytes.buffer] });
65
66
  });
66
67
  } };
67
68
  }
@@ -0,0 +1,39 @@
1
+ import { captureBrowserError } from '@wildshard/engine/telemetry/browserErrors';
2
+ import type { GridCrossingState } from '../../../shared/game/grid/crossing';
3
+ import type { CrossingSaveStatus } from './borderShimmer';
4
+
5
+ declare const __BUILD_ID__: string;
6
+ const buildId = (): string => { try { return __BUILD_ID__; } catch { return ''; } };
7
+
8
+ /**
9
+ * SENTRY-TRIAGE S18: the grid's SAVE FAILED, RETRY at a border is a screen of a fault. The first time a session shows it, one
10
+ * report names the cell the crossing left and the one it aimed for; later failures in the same session stay quiet, so an
11
+ * offline player who keeps trying can't fill the screen outbox (8 kept) and push out an unsent error-modal.
12
+ */
13
+ export function saveFailedReporter(slugOf: (instance: string | null) => string, capture: typeof captureBrowserError = captureBrowserError):
14
+ (status: CrossingSaveStatus, state: GridCrossingState | null | undefined) => void {
15
+ let reported = false;
16
+ return (status, state) => {
17
+ if (reported || status !== 'failed') return;
18
+ reported = true;
19
+ try {
20
+ capture(new Error(`a border crossing could not save (SAVE FAILED, RETRY): ${state?.issue ?? state?.phase ?? 'unknown'}`), {
21
+ system: 'grid', build: buildId(), shard: slugOf(state?.current ?? null), bootStage: 'playing', fatal: false, screen: 'save-failed',
22
+ diagnostic: { phase: state?.phase ?? null, target: slugOf(state?.target ?? null) } });
23
+ } catch { /* a report never holds the crossing */ }
24
+ };
25
+ }
26
+
27
+ /** S18: a neighbour that can't load shows UNAVAILABLE on Shard Select. One report per cell a session, at warning level. */
28
+ export function refusalReporter(capture: typeof captureBrowserError = captureBrowserError):
29
+ (instance: string, slug: string, refusal: string, error: unknown) => void {
30
+ const seen = new Set<string>();
31
+ return (instance, slug, refusal, error) => {
32
+ if (seen.has(instance)) return;
33
+ seen.add(instance);
34
+ try {
35
+ capture(error instanceof Error ? error : new Error(String(error)), { system: 'grid', build: buildId(), shard: slug, bootStage: 'playing',
36
+ fatal: false, screen: 'cell-unavailable', diagnostic: { refusal, cell: instance } });
37
+ } catch { /* a report never holds the refusal */ }
38
+ };
39
+ }
@@ -104,6 +104,7 @@ import { copyMarks } from './copyIdentity';
104
104
  import { CellMinimaps } from './minimapBlend';
105
105
  import { leaseMapImage } from '../shardfile/mapImage';
106
106
  import { crossingSaveStatus, installBorderShimmer, type BorderShimmerState, type CrossingSaveStatus } from './borderShimmer';
107
+ import { refusalReporter, saveFailedReporter } from './screenReports';
107
108
  import { GAME_STRINGS } from '../../../shared/game/strings';
108
109
  import { GridCellWaitingError, classifyRefusal, pageShardRefusals, refusalReason, type ShardRefusal } from './refusal';
109
110
  import { tileRing } from '../shardfile/tileDriver';
@@ -113,6 +114,7 @@ import { readGridSeamData, type GridSeamAddress } from '../../../shared/game/gri
113
114
  import { readCompiledGridStrips } from '../../../shared/game/grid/compiledStrips';
114
115
  import { startRoadGrain } from './roadGrainPreparation';
115
116
  import { startRoadSigns } from './roadSignPreparation';
117
+ import { RoadMapShare } from './roadResources';
116
118
  import { clientPreparationBatch } from '../shardfile/preparationTiming';
117
119
 
118
120
  import { admittedRuntimeProduct } from '../shardfile/runtimeProduct';
@@ -208,6 +210,10 @@ export interface GridSessionState {
208
210
  readonly shimmer: BorderShimmerState;
209
211
  /** G555: the cell whose step-by-step loading screen is open (its entry or re-entry waits), or null */
210
212
  readonly cellLoading: string | null;
213
+ /** NET-LAG NL7: the loading card's running row, by label (null: no card). */
214
+ readonly cellStage: string | null;
215
+ /** GC8: the `cell` path step that screen shows now and its detail, so a harness times each step. */
216
+ readonly cellStep: { readonly step: string; readonly detail: string } | null;
211
217
  /** the allocator's grid content (MB) and the §3.2 playing total with the engine base (MB, the 1.0 GB envelope, G65) */
212
218
  readonly residentMB: number; readonly playingMB: number;
213
219
  /** Exact category sum before engine base, overlap allowance or calibration factor; used by the soak harness. */
@@ -371,6 +377,8 @@ export class GridSession {
371
377
  private readonly shimmer: { readonly step: () => void; readonly state: () => BorderShimmerState };
372
378
  /** G167: why a neighbour's shard can't load (its product refused, with the admission's message) and its far view's status */
373
379
  private readonly refusals = new Map<string, ShardRefusal>();
380
+ /** SENTRY-TRIAGE S18: UNAVAILABLE reports once per cell a session (screenReports.ts) */
381
+ private readonly reportRefusal = refusalReporter();
374
382
  private readonly issues = new Map<string, string>();
375
383
  private readonly farViews = new Set<string>();
376
384
  private readonly farPreparation: () => readonly FarPreparationWait[];
@@ -500,7 +508,7 @@ export class GridSession {
500
508
  return compiledOuter?.strips ?? generatePlatformSliced(source.cells, source.empty, pause, OUTER_RING_STRETCH_MS, await seamPlans(), (x, z) => !ring(x, z)); // T10: built in play after controls, short stretches beside the frame
501
509
  };
502
510
  const roadInput = { strips, home, pitch: assembly.pitch, layout, scene: host.scene,
503
- scope: roadScope, camera: () => host.frame?.camera, plans, admission, tileBacking,
511
+ scope: roadScope, camera: () => host.frame?.camera, plans, admission, tileBacking, maps: new RoadMapShare(),
504
512
  ...(grain === undefined ? {} : { grain: grain.get }), ...(signs === undefined ? {} : { signs: signs.get }) };
505
513
  const pause = async (): Promise<void> => { await construction.check(); };
506
514
  // Spawn heap (T10): no closure here may capture `compiled`. Every closure of this scope shares one context, and the
@@ -674,7 +682,9 @@ export class GridSession {
674
682
  const look = { instance: cell.instance, x: edge.x, z: edge.z, axis: edge.axis, halfLength: edge.halfLength };
675
683
  return cell.edgeLook === undefined ? look : Object.assign(look, { height: cell.edgeLook.height });
676
684
  })),
677
- ports: { closed: (id) => this.live === null || !this.live.live.ready(id) } });
685
+ // GC12: drawn only while the traveller stands at that edge (the feet in the home frame)
686
+ ports: { closed: (id) => this.live === null || !this.live.live.ready(id),
687
+ feet: () => { const at = this.world(); return { x: at.x - home.origin.x, z: at.z - home.origin.z }; } } });
678
688
  // QA 2026-11-13: a waiting cell's loading steps on SHARD SELECT's loading card, inset over the live world
679
689
  this.cellLoading = new CellLoading(new CellLoadingCard(), (waiting) => this.neighbours.some(row => row.instance === waiting));
680
690
  setParkedMatricesFrozen(true); // G580 T2: a hidden parked world skips matrix updates during its warm-up
@@ -682,10 +692,15 @@ export class GridSession {
682
692
  // G78: a shimmer line at every shard border on its real ground; G119: SAVING… / SAVE FAILED, RETRY while a crossing waits
683
693
  const rows = new Map((edges ?? []).map((cell) => [cell.instance, cell.edges]));
684
694
  let status: CrossingSaveStatus = null, polled = 0;
695
+ // S18: SAVE FAILED, RETRY reports the first time a session shows it
696
+ const reportSave = saveFailedReporter((id) => { try { return id === null ? '' : this.assembly.cell(id).slug; } catch { return ''; } });
685
697
  this.shimmer = installBorderShimmer({ scene: host.scene, scope: host.scope, time: () => app.clock.now,
686
698
  cells: this.assembly.cells.map((cell) => ({ x: cell.origin.x - home.origin.x, z: cell.origin.z - home.origin.z, edges: rows.get(cell.instance) ?? null })),
687
699
  ports: { feet: () => { const at = this.world(); return { x: at.x - home.origin.x, z: at.z - home.origin.z }; },
688
- status: () => { if (++polled % 4 === 0) status = crossingSaveStatus(this.live?.state().crossing); return status; },
700
+ status: () => {
701
+ if (++polled % 4 === 0) { const crossing = this.live?.state().crossing; status = crossingSaveStatus(crossing); reportSave(status, crossing); }
702
+ return status;
703
+ },
689
704
  text: (shown) => (shown === 'saving' ? GAME_STRINGS.grid.saving : GAME_STRINGS.grid.saveFailed) } });
690
705
  this.constructorTiming?.('presentation');
691
706
  const nativeOrigin = { origin: { x: 0, z: 0 } };
@@ -947,6 +962,7 @@ export class GridSession {
947
962
  const refusal = classifyRefusal(error);
948
963
  if (refusal === null || this.host.scope.disposed) return;
949
964
  console.warn(`[grid] ${cell.instance} can't load (${refusal}):`, error);
965
+ this.reportRefusal(cell.instance, cell.slug, refusal, error);
950
966
  this.refusals.set(cell.instance, refusal); this.issues.set(cell.instance, error instanceof Error ? error.message : String(error)); pageShardRefusals().note(cell.slug, refusal);
951
967
  }
952
968
  /**
@@ -1231,7 +1247,7 @@ export class GridSession {
1231
1247
  pitch: this.assembly.pitch,
1232
1248
  home: this.home.instance, inside: gridCells.cell?.instance ?? null, feet: { x: Math.round(at.x * 100) / 100, z: Math.round(at.z * 100) / 100 },
1233
1249
  cells: this.assembly.cells.map((cell) => { const d = drawn(cell.instance); return { instance: cell.instance, slug: cell.slug, cell: cell.cell, shows: shows(cell.instance, d), drawn: d }; }),
1234
- strips: this.strips.length, road: this.road, seams: this.seams, softWalls: this.softWalls.state(), shimmer: this.shimmer.state(), cellLoading: this.cellLoading.open, ringsReady: this.rings.ready(), ringsWait: { cells: this.rings.waiting(), far: this.rings.farPlan(), preparation: this.farPreparation(), waits: { count: pending.length, oldest: pending.map(({ label, kind, ageMs }) => ({ label, kind, ageMs })).sort((a, b) => b.ageMs - a.ageMs).slice(0, 16) } },
1250
+ strips: this.strips.length, road: this.road, seams: this.seams, softWalls: this.softWalls.state(), shimmer: this.shimmer.state(), cellLoading: this.cellLoading.open, cellStage: this.cellLoading.stage, cellStep: this.cellLoading.now, ringsReady: this.rings.ready(), ringsWait: { cells: this.rings.waiting(), far: this.rings.farPlan(), preparation: this.farPreparation(), waits: { count: pending.length, oldest: pending.map(({ label, kind, ageMs }) => ({ label, kind, ageMs })).sort((a, b) => b.ageMs - a.ageMs).slice(0, 16) } },
1235
1251
  residentMB: Math.round(cost.accounted / 1e4) / 100, playingMB: Math.round(cost.playing / 1e4) / 100,
1236
1252
  accountedBytes: cost.accounted,
1237
1253
  rings: { frame: stats.frame, far: stats.resident.far, l1: stats.resident.l1, l0: stats.resident.l0, refused: stats.refused, inFlight: stats.inFlight, queued: stats.queued,
@@ -6,6 +6,10 @@
6
6
  *
7
7
  * One draw for every wall (a curtain quad per edge, additive, faded out past ~70 m so a 500 m wall never dominates the
8
8
  * view). Which walls are closed comes from the session each fixed step; a wall opens the moment its neighbour is ready.
9
+ *
10
+ * GC12 (Jake, 2026-11-13 ~22:50 Cancún, board A): the wall shows only when a player meets a closed edge. A closed wall is drawn
11
+ * while the traveller's feet stand within `MEET_METRES` of it, so a warm crossing (or a wall seen from across the cell) never
12
+ * shows it; the readiness wall itself still holds at every closed edge.
9
13
  */
10
14
  import { AdditiveBlending, BufferAttribute, BufferGeometry, Color, DoubleSide, DynamicDrawUsage, Group, Mesh, type Object3D, ShaderMaterial } from 'three';
11
15
  import type { LookScope } from '../../../shared/game/grid/roadLayout';
@@ -15,9 +19,19 @@ export interface SoftWallEdge { readonly instance: string; readonly x: number; r
15
19
  /** What the look reads each fixed step. */
16
20
  export interface SoftWallPorts {
17
21
  readonly closed: (instance: string) => boolean;
22
+ /** the traveller's feet in the home frame; absent: every closed wall shows, as before GC12 */
23
+ readonly feet?: () => { readonly x: number; readonly z: number };
24
+ }
25
+ /** GC12: how near a closed edge the feet must stand for its wall to show (a player at the wall, a stride or two short of it). */
26
+ export const MEET_METRES = 6;
27
+ /** Distance from the feet to an edge's wall segment, in the home frame. */
28
+ export function edgeDistance(edge: SoftWallEdge, feet: { readonly x: number; readonly z: number }): number {
29
+ const dx = feet.x - edge.x, dz = feet.z - edge.z;
30
+ const across = edge.axis === 'x' ? dx : dz, along = edge.axis === 'x' ? dz : dx;
31
+ return Math.hypot(across, Math.max(0, Math.abs(along) - edge.halfLength));
18
32
  }
19
- /** The readout: how many neighbour edges are closed. */
20
- export interface SoftWallState { readonly closed: number }
33
+ /** The readout: how many neighbour edges are closed, and how many of those show (GC12: the ones the traveller meets). */
34
+ export interface SoftWallState { readonly closed: number; readonly shown: number }
21
35
 
22
36
  const HEIGHT = 7, CYAN = new Color(0x38e6ff);
23
37
 
@@ -99,18 +113,21 @@ export function installSoftWallLook(input: { readonly edges: readonly SoftWallEd
99
113
  const closedAttr = wall.geometry.getAttribute('aClosed');
100
114
  group.add(wall); scene.add(group);
101
115
  const flags = edges.map(() => -1);
102
- let closedCount = 0;
116
+ let closedCount = 0, shownCount = 0;
103
117
  const step = (): void => {
104
118
  uTime.value = input.time();
105
- closedCount = 0;
119
+ closedCount = 0; shownCount = 0;
120
+ const feet = ports.feet?.();
106
121
  for (let k = 0; k < edges.length; k++) {
107
122
  const edge = edges[k];
108
123
  if (edge === undefined) continue;
109
- const closed = ports.closed(edge.instance) ? 1 : 0;
110
- if (closed === 1) closedCount++;
111
- if (flags[k] !== closed) { flags[k] = closed; for (let c = 0; c < 4; c++) closedAttr.setX(k * 4 + c, closed); closedAttr.needsUpdate = true; }
124
+ const closed = ports.closed(edge.instance);
125
+ if (closed) closedCount++;
126
+ const shown = closed && (feet === undefined || edgeDistance(edge, feet) <= MEET_METRES) ? 1 : 0;
127
+ shownCount += shown;
128
+ if (flags[k] !== shown) { flags[k] = shown; for (let c = 0; c < 4; c++) closedAttr.setX(k * 4 + c, shown); closedAttr.needsUpdate = true; }
112
129
  }
113
130
  };
114
131
  scope.onDispose(() => { group.removeFromParent(); wall.geometry.dispose(); material.dispose(); });
115
- return { step, state: () => ({ closed: closedCount }) };
132
+ return { step, state: () => ({ closed: closedCount, shown: shownCount }) };
116
133
  }
@@ -40,6 +40,10 @@ const LOW_POWER_BANNER = 'Low Power Mode is on, so you\'re on Low graphics. Turn
40
40
  export const MAIN_MENU_HERO: string = titleAssetURL('/assets/title/main-crossroads-landscape.jpg');
41
41
  /** Square title artwork shared by the menu deck. */
42
42
  export const MAIN_MENU_SQUARE_HERO: string = titleAssetURL('/assets/title/main-crossroads-square.jpg');
43
+ /** PZ19: the shell's ~30 kB first cuts of both heroes; the menu layers the full image over its first cut, so the art never
44
+ * blanks while the full image arrives, and the full image is fetched only once the title is up. */
45
+ const FIRST_HERO: string = titleAssetURL('/assets/title/main-crossroads-landscape-first.jpg');
46
+ const FIRST_SQUARE_HERO: string = titleAssetURL('/assets/title/main-crossroads-square-first.jpg');
43
47
 
44
48
  const CARDS_ICON = '<svg viewBox="0 0 64 48" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"><rect x="6" y="11" width="18" height="27" rx="2" transform="rotate(-16 15 24)"/><rect x="40" y="11" width="18" height="27" rx="2" transform="rotate(16 49 24)"/><rect x="22" y="4" width="20" height="31" rx="2" fill="rgba(6,10,18,0.85)"/></g></svg>';
45
49
  const GRID_CELLS = [0, 1, 2].flatMap((r) => [0, 1, 2].map((c) => `<rect x="${17 + c * 11}" y="${6 + r * 13}" width="8" height="9" rx="1"/>`)).join('');
@@ -125,8 +129,8 @@ export function buildTitleMenu(opts: TitleMenuOptions): TitleMenu {
125
129
  ${online ? `<div class="ws-main-row"><button class="ws-main-settings ws-main-doctor" type="button"><i class="ws-main-doctor-dot" aria-hidden="true"></i>${s.checkConnection}</button></div>` : ''}
126
130
  </div>`;
127
131
  const hero = required(main, '.ws-main-hero', HTMLElement);
128
- hero.style.setProperty('--ws-hero-landscape', `url('${MAIN_MENU_HERO}')`);
129
- hero.style.setProperty('--ws-hero-square', `url('${MAIN_MENU_SQUARE_HERO}')`);
132
+ hero.style.setProperty('--ws-hero-landscape', `url('${MAIN_MENU_HERO}'), url('${FIRST_HERO}')`);
133
+ hero.style.setProperty('--ws-hero-square', `url('${MAIN_MENU_SQUARE_HERO}'), url('${FIRST_SQUARE_HERO}')`);
130
134
  if (notice !== undefined && notice !== '') {
131
135
  const line = document.createElement('div');
132
136
  line.className = 'ws-main-notice';
@@ -19,6 +19,7 @@ import type { Shardfile } from '@wildshard/format/shardSchema';
19
19
  import { ownedPresentationImages } from '../shardfile/presentation';
20
20
  import { lookLightManifest } from '@wildshard/engine/render/lookLight';
21
21
  import { lookLightOn } from '@wildshard/engine/ui/lookLightOption';
22
+ import { TIER } from '@wildshard/engine/core/tier';
22
23
  import { absentShardProduct, type ShardProduct } from '../../../shared/game/shardfile/shardProduct';
23
24
 
24
25
 
@@ -163,7 +164,7 @@ export function sourceManifest(source: Pick<Shardfile, 'identity' | 'accent' | '
163
164
  const slug = parseShardSlug(source.identity.slug);
164
165
  const images = imageOwner === undefined ? undefined : ownedPresentationImages(source, assets, imageOwner);
165
166
  // LF1-4: the look's light settings (height fog, bloom, desktop AO) behind Settings ▸ Debug ▸ Look ▸ "Look light"
166
- const light = lookLightManifest(source.look, lookLightOn());
167
+ const light = lookLightManifest(source.look, lookLightOn(), TIER);
167
168
  const card = 'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/%3E';
168
169
  return {
169
170
  ...(source.navigation === null || source.navigation === undefined || navigation === undefined ? {} : { navigation: { row: source.navigation, bytes: navigation } }),
@@ -179,6 +179,12 @@ export function installFollowedMovers(ctx: LevelContext, world: World, options:
179
179
  ctx.scope.onDispose(() => { if (movers.riding()) world.player.carried = false; });
180
180
  if (options.onDispose !== undefined) ctx.scope.onDispose(options.onDispose);
181
181
  ctx.debug.expose(`movers.${options.systemId}`, { showRest: () => { movers.showRest(); } }); // the map bake poses movers at rest
182
- for (const row of options.data) wirePage.movers.set(row.id, { pose: pose => { wirePage.posed++; movers.follow(row.id, pose); }, place: (at, next) => { movers.replayPose(row.id, at, next); } });
182
+ // GC30b: the scope frees these movers' bodies, so their views leave the wire with it, or the next row of that id poses a freed
183
+ // body ("null pointer passed to rust"). Only this cell's own view: another cell may have lent one under the same id since.
184
+ for (const row of options.data) {
185
+ const view: MoverView = { pose: pose => { wirePage.posed++; movers.follow(row.id, pose); }, place: (at, next) => { movers.replayPose(row.id, at, next); } };
186
+ wirePage.movers.set(row.id, view);
187
+ ctx.scope.onDispose(() => { if (wirePage.movers.get(row.id) === view) wirePage.movers.delete(row.id); });
188
+ }
183
189
  return movers;
184
190
  }
@@ -84,6 +84,8 @@ export function questFigure(row: QuestFigureRows, ports: QuestFigurePorts): KitF
84
84
  const figure = new KitFigure(ports.sky, row.kit, ports.catalogue.rows(row.kit), ports.catalogue.kit(row.kit),
85
85
  { geometry, objects, channels: ports.channels }, ports.resources, ports.scope);
86
86
  figure.group.position.set(feet.x, feet.y, feet.z); figure.group.rotation.y = yaw;
87
+ // its body box was read at the origin, before the figure stood at its feet
88
+ figure.presentation.syncAnchors();
87
89
  return figure;
88
90
  }
89
91
 
@@ -397,6 +397,12 @@ export async function finishStage(ctx: Awaited<ReturnType<typeof playStage>>): P
397
397
  installProbe(handle, { leakPhysics, health: () => playerHealth.attributes.health, quest: () => ({ adventure: boot.runtime.hooks.adventureFlags?.() ?? [], quest: boot.runtime.hooks.questFlags?.() ?? [] }),
398
398
  // T2E-1b: a grid page's area is the cell the player is in, not the shell
399
399
  area: () => grid === null ? shardArea(slug, app.debug.snapshot()['shardfile'], boot.runtime.hooks.questFlags?.() ?? []) : grid.area() });
400
+ // SHARD-SOURCE AP5 (J347): a DEVSERVER page carries the dev hook sharddev's `watch` page script drives; a production
401
+ // build's define makes this `false` in this module, so the import and its chunk go (scripts/check-devserver.mjs checks;
402
+ // DEVSERVER imported from grid/menu did not fold across modules and kept the chunk).
403
+ if (typeof __DEVSERVER__ === 'boolean' && __DEVSERVER__) void import('../devScene/hook').then(dev => dev.installDevHook({ scope: game.levelScope, scene: game.rootScene, physics: () => world.physics,
404
+ look: () => game.look, server: () => window.__workerClientDevColliders ?? null, watchFrames: fn => game.watchFrames(fn) }))
405
+ .catch((cause: unknown) => { console.error('[devScene]', cause); });
400
406
  ctx.startExplore?.();
401
407
  document.dispatchEvent(new Event('ws:ready')); // booted to the title
402
408
  const completeOfflineCopy = async (): Promise<void> => {