@wildshard/engine 0.1.15 → 0.1.18

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 (262) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/index.html +157 -11
  3. package/lint/engine-sides.json +23 -0
  4. package/lint/host-callback-syntax.mjs +2 -1
  5. package/lint/host-callbacks.mjs +3 -3
  6. package/lint/host-files.mjs +5 -4
  7. package/lint/host-register.json +496 -0
  8. package/lint/no-base64.mjs +3 -1
  9. package/lint/ratchet.json +2 -2
  10. package/lint/shard-imports.d.mts +1 -0
  11. package/lint/shard-imports.mjs +60 -13
  12. package/lint/shard-source.d.mts +9 -0
  13. package/lint/shard-source.mjs +91 -0
  14. package/lint/shardfile-boundaries.mjs +10 -8
  15. package/lint/sim-closure.mjs +6 -3
  16. package/lint/wildshard-plugin.d.ts +4 -0
  17. package/lint/wildshard-plugin.js +44 -27
  18. package/package.json +24 -6
  19. package/scripts/app-build/buildIdentity.d.mts +3 -1
  20. package/scripts/app-build/buildIdentity.mjs +25 -5
  21. package/scripts/app-build/builtAt.d.mts +4 -0
  22. package/scripts/app-build/builtAt.mjs +21 -0
  23. package/scripts/app-build/outputProducts.d.mts +3 -0
  24. package/scripts/app-build/outputProducts.mjs +31 -0
  25. package/scripts/app-build/serviceWorker.ts +16 -2
  26. package/scripts/app-build/versionFiles.ts +2 -1
  27. package/scripts/app-build-pipeline.mjs +7 -1
  28. package/scripts/audio-download-proof.mjs +843 -0
  29. package/scripts/build-app.mjs +4 -0
  30. package/scripts/build-mirror.d.mts +2 -0
  31. package/scripts/build-mirror.mjs +5 -4
  32. package/scripts/built-product.mjs +3 -3
  33. package/scripts/cell-mem/metrics-preload.mjs +65 -0
  34. package/scripts/cell-mem-bench.mjs +130 -0
  35. package/scripts/check-chunks.mjs +2 -1
  36. package/scripts/check-devserver.mjs +1 -1
  37. package/scripts/chromium-keychain-check.mjs +4 -2
  38. package/scripts/chromium-keychain.mjs +3 -1
  39. package/scripts/cook.mjs +7 -3
  40. package/scripts/devices.d.mts +4 -0
  41. package/scripts/devices.mjs +39 -0
  42. package/scripts/devserver-client.d.mts +7 -0
  43. package/scripts/devserver-client.mjs +85 -0
  44. package/scripts/doctor-proof.mjs +1 -1
  45. package/scripts/e2e-faults.mjs +159 -0
  46. package/scripts/engine-ci-budget.ts +7 -1
  47. package/scripts/format-lock.mjs +20 -11
  48. package/scripts/generate-title-launch.mjs +3 -2
  49. package/scripts/grid-crossing-walk-proof.mjs +30 -11
  50. package/scripts/heavy-lane.py +25 -1
  51. package/scripts/host-ruler/register-migrate.mjs +242 -0
  52. package/scripts/host-ruler/register.d.mts +36 -0
  53. package/scripts/host-ruler/register.mjs +116 -0
  54. package/scripts/host-ruler/roots.d.mts +29 -0
  55. package/scripts/host-ruler/roots.mjs +333 -0
  56. package/scripts/host-ruler/server-roots.d.mts +23 -0
  57. package/scripts/host-ruler/server-roots.mjs +272 -0
  58. package/scripts/main-watch.d.mts +1 -1
  59. package/scripts/main-watch.mjs +10 -6
  60. package/scripts/map-hash.mjs +3 -6
  61. package/scripts/memory-proof.mjs +158 -0
  62. package/scripts/mmo-bots.mjs +2 -2
  63. package/scripts/offline-proof-rules.d.mts +5 -2
  64. package/scripts/offline-proof-rules.mjs +43 -6
  65. package/scripts/offline-proof.mjs +15 -6
  66. package/scripts/online-rig.mjs +4 -4
  67. package/scripts/page-release/flow.d.mts +1 -0
  68. package/scripts/page-release/flow.mjs +6 -2
  69. package/scripts/page-release.mjs +5 -1
  70. package/scripts/physics-route.json +0 -71
  71. package/scripts/pins-catalogue.ts +103 -0
  72. package/scripts/pins-reuse.mjs +3 -1
  73. package/scripts/pins.ts +22 -14
  74. package/scripts/preview-grid.ts +203 -0
  75. package/scripts/road-preload-proof.mjs +167 -0
  76. package/scripts/server-release/publish.mjs +2 -2
  77. package/scripts/server-release/served-slug.d.mts +2 -0
  78. package/scripts/server-release/served-slug.mjs +10 -0
  79. package/scripts/server-release/sign.d.mts +1 -0
  80. package/scripts/server-release/sign.mjs +3 -7
  81. package/scripts/shard-components.mjs +0 -2
  82. package/scripts/shard-outputs.d.mts +8 -0
  83. package/scripts/shard-outputs.mjs +45 -11
  84. package/scripts/side-parity.d.mts +2 -1
  85. package/scripts/side-parity.mjs +25 -4
  86. package/scripts/test-amber.d.mts +1 -0
  87. package/scripts/test-amber.mjs +10 -0
  88. package/scripts/test-products.json +3 -3
  89. package/scripts/tier-textures-proof.mjs +101 -0
  90. package/scripts/tier-textures.mjs +60 -0
  91. package/scripts/tracked-public.d.mts +1 -0
  92. package/scripts/tracked-public.mjs +17 -0
  93. package/scripts/tsconfig.json +1 -0
  94. package/scripts/vps/wildshard-config +79 -23
  95. package/scripts/worker-client-play.mjs +1 -0
  96. package/scripts/worker-client-proof.mjs +1 -1
  97. package/scripts/worker-client-slug.mjs +44 -0
  98. package/src/cli/engine.mjs +8 -0
  99. package/src/client/app/bootRoute.ts +4 -1
  100. package/src/client/app/dropModal.ts +15 -2
  101. package/src/client/app/entry.ts +96 -13
  102. package/src/client/app/slugPath.ts +5 -0
  103. package/src/client/engine/audio/Audio.ts +20 -2
  104. package/src/client/engine/boot/bakedTextures.ts +3 -2
  105. package/src/client/engine/boot/bootTrace.ts +6 -1
  106. package/src/client/engine/boot/bytes.ts +4 -3
  107. package/src/client/engine/boot/clearDownloads.ts +1 -1
  108. package/src/client/engine/boot/contentRead.ts +4 -0
  109. package/src/client/engine/boot/dropNotice.ts +20 -6
  110. package/src/client/engine/boot/gpuFiles.ts +25 -2
  111. package/src/client/engine/boot/lastEnd.ts +8 -2
  112. package/src/client/engine/boot/parsedPages.ts +127 -58
  113. package/src/client/engine/boot/shardPrefetch.ts +7 -1
  114. package/src/client/engine/boot/sw.ts +19 -0
  115. package/src/client/engine/build.d.ts +2 -0
  116. package/src/client/engine/core/Game.ts +29 -3
  117. package/src/client/engine/core/GpuRecovery.ts +7 -0
  118. package/src/client/engine/core/Volumetrics.ts +5 -0
  119. package/src/client/engine/core/assets.ts +27 -20
  120. package/src/client/engine/core/bootstrap.ts +5 -3
  121. package/src/client/engine/core/ktx2.ts +84 -11
  122. package/src/client/engine/debug/probe.ts +18 -1
  123. package/src/client/engine/explore/Compare.ts +2 -2
  124. package/src/client/engine/explore/TouchFly.ts +3 -5
  125. package/src/client/engine/fx/LightPool.ts +41 -1
  126. package/src/client/engine/input/dom.ts +12 -0
  127. package/src/client/engine/net/predictor.ts +6 -2
  128. package/src/client/engine/player/Player.ts +10 -2
  129. package/src/client/engine/player/TouchControls.ts +12 -4
  130. package/src/client/engine/pwa/sw.js +59 -11
  131. package/src/client/engine/render/drawCheck.ts +96 -0
  132. package/src/client/engine/render/precompile.ts +20 -14
  133. package/src/client/engine/saves/staleBuildNote.ts +46 -0
  134. package/src/client/engine/telemetry/browserErrors.ts +161 -21
  135. package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
  136. package/src/client/engine/telemetry/screenOutbox.ts +61 -0
  137. package/src/client/engine/telemetry/staleBuildReport.ts +12 -0
  138. package/src/client/engine/ui/DeathFade.ts +99 -11
  139. package/src/client/engine/ui/ErrorModal.ts +13 -6
  140. package/src/client/engine/ui/Feedback.ts +2 -1
  141. package/src/client/engine/ui/Loading.ts +10 -6
  142. package/src/client/engine/ui/Map.ts +2 -1
  143. package/src/client/engine/ui/WeaponStrip.ts +2 -1
  144. package/src/client/engine/ui/backGuard.ts +104 -0
  145. package/src/client/engine/ui/hudAdapters.ts +30 -4
  146. package/src/client/engine/ui/loading.css +17 -0
  147. package/src/client/engine/ui/namePrompt.ts +6 -5
  148. package/src/client/engine/ui/styles/combat.css +12 -0
  149. package/src/client/engine/ui/styles/namePrompt.css +4 -2
  150. package/src/client/game/boot/audio.generated.ts +0 -396
  151. package/src/client/game/boot/bytes.generated.ts +42 -71
  152. package/src/client/game/boot/versions.generated.ts +0 -13
  153. package/src/client/game/compendium/keepsakes.ts +16 -6
  154. package/src/client/game/grapple/tool.ts +10 -7
  155. package/src/client/game/grid/area.ts +38 -0
  156. package/src/client/game/grid/cellLoading.ts +23 -12
  157. package/src/client/game/grid/cellScreens.ts +39 -74
  158. package/src/client/game/grid/live.ts +28 -2
  159. package/src/client/game/grid/liveSession.ts +54 -10
  160. package/src/client/game/grid/menu.ts +4 -0
  161. package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
  162. package/src/client/game/grid/nearPlaceholderView.ts +9 -3
  163. package/src/client/game/grid/neighbourPanels.ts +10 -1
  164. package/src/client/game/grid/oneWayIn.ts +92 -27
  165. package/src/client/game/grid/pageEntry.ts +19 -0
  166. package/src/client/game/grid/pageShell.ts +1 -1
  167. package/src/client/game/grid/placedCards.ts +55 -0
  168. package/src/client/game/grid/placedCells.ts +131 -0
  169. package/src/client/game/grid/plotAudio.ts +114 -0
  170. package/src/client/game/grid/products.ts +55 -5
  171. package/src/client/game/grid/regionalRuntime.ts +6 -0
  172. package/src/client/game/grid/regionalWorld.ts +15 -2
  173. package/src/client/game/grid/roadCull.ts +44 -14
  174. package/src/client/game/grid/roadLookPlatform.ts +2 -2
  175. package/src/client/game/grid/roadTileBacking.ts +13 -3
  176. package/src/client/game/grid/session.ts +47 -22
  177. package/src/client/game/grid/shardfileFar.ts +9 -3
  178. package/src/client/game/grid/spawnGround.ts +68 -0
  179. package/src/client/game/grid/voidLook.ts +29 -23
  180. package/src/client/game/loot/runtime.ts +3 -1
  181. package/src/client/game/mainMenu.ts +14 -6
  182. package/src/client/game/riding/hud.ts +6 -4
  183. package/src/client/game/session/finish.ts +22 -4
  184. package/src/client/game/session/play.ts +8 -2
  185. package/src/client/game/session/session.ts +4 -1
  186. package/src/client/game/shard/titleList.ts +6 -2
  187. package/src/client/game/shardfile/clientWorker.ts +43 -13
  188. package/src/client/game/shardfile/serverRoute.ts +10 -22
  189. package/src/client/game/slugPage.css +11 -0
  190. package/src/client/game/slugPage.ts +84 -0
  191. package/src/client/game/systems/viewmodel/heldView.ts +6 -3
  192. package/src/client/game/titleDeck.ts +56 -32
  193. package/src/client/host/online/doctor.ts +7 -6
  194. package/src/client/host/online/linkScreens.ts +16 -0
  195. package/src/client/host/online/release.ts +51 -5
  196. package/src/client/host/online/shell.ts +62 -27
  197. package/src/client/host/standalone/shell.ts +7 -3
  198. package/src/cook/game/audioReport.ts +57 -0
  199. package/src/cook/game/entryTotals.ts +26 -6
  200. package/src/cook/game/installedRuntimeReads.ts +3 -0
  201. package/src/cook/game/shardCook.ts +38 -8
  202. package/src/cook/game/tierTextures.ts +276 -0
  203. package/src/e2e/smoke/game.ts +19 -14
  204. package/src/e2e/smoke/page-globals.d.ts +9 -8
  205. package/src/e2e/smoke/template2.spec.ts +8 -7
  206. package/src/server/engine/sim/respawn.ts +6 -1
  207. package/src/server/engine/sim.ts +3 -0
  208. package/src/server/game/grid/simulation.ts +35 -0
  209. package/src/server/game/loot/harvest.ts +2 -0
  210. package/src/server/game/loot/keepsakeProgression.ts +40 -0
  211. package/src/server/game/loot/playerOwned.ts +5 -1
  212. package/src/server/game/plugin/simulation.ts +4 -0
  213. package/src/server/game/population/nativeBake.ts +2 -1
  214. package/src/server/game/quest/chapterRecords.ts +2 -0
  215. package/src/server/game/quest/serverChapters.ts +4 -0
  216. package/src/server/game/quest/serverDoors.ts +11 -5
  217. package/src/server/game/roomRespawn.ts +4 -0
  218. package/src/server/game/shardfile/installedSides.ts +18 -0
  219. package/src/server/game/shardfile/nativeAssemblyHosts.ts +19 -10
  220. package/src/server/game/shardfile/nativeAssemblyInput.ts +1 -4
  221. package/src/server/host/bake/headlessWorker.ts +5 -1
  222. package/src/server/host/dedicated/cellHost.ts +98 -29
  223. package/src/server/host/dedicated/cellProtocol.ts +11 -1
  224. package/src/server/host/dedicated/cellWorker.ts +9 -3
  225. package/src/server/host/dedicated/crossing.ts +6 -2
  226. package/src/server/host/dedicated/dedicatedRoom.ts +21 -8
  227. package/src/server/host/dedicated/gridCells.ts +52 -9
  228. package/src/server/host/dedicated/main.ts +31 -12
  229. package/src/server/host/dedicated/placementFile.ts +56 -0
  230. package/src/server/host/dedicated/releaseFile.ts +17 -10
  231. package/src/server/host/dedicated/roadRoom.ts +21 -5
  232. package/src/server/host/dedicated/socketTransport.ts +2 -1
  233. package/src/server/host/dedicated/workerTable.ts +13 -1
  234. package/src/server/host/dedicated/world.ts +111 -10
  235. package/src/server/host/headlessRuntime.ts +10 -5
  236. package/src/server/host/installers.ts +62 -0
  237. package/src/server/host/openWorld.ts +59 -0
  238. package/src/server/host/ropeDecks.ts +2 -0
  239. package/src/server/host/standalone/cellWorld.ts +25 -19
  240. package/src/server/host/standalone/fallFloor.ts +2 -2
  241. package/src/server/host/standalone/gridServer.ts +7 -4
  242. package/src/server/host/standalone/roadWorld.ts +41 -4
  243. package/src/shared/engine/audio/bootAudio.ts +33 -0
  244. package/src/shared/engine/level/spec.ts +3 -3
  245. package/src/shared/engine/net/acts.ts +3 -0
  246. package/src/shared/engine/net/deviceWord.ts +138 -0
  247. package/src/shared/engine/net/socketFrames.ts +7 -4
  248. package/src/shared/engine/physics/query.ts +27 -0
  249. package/src/shared/engine/physics/terrain.ts +19 -28
  250. package/src/shared/engine/saves/saves.lock.json +15 -0
  251. package/src/shared/engine/sim/actRoutes.ts +2 -0
  252. package/src/shared/game/compendium/keepsakeProgression.ts +24 -0
  253. package/src/shared/game/grid/catalogue.ts +12 -5
  254. package/src/shared/game/grid/catalogueSlot.ts +18 -0
  255. package/src/shared/game/grid/farProxy.ts +6 -5
  256. package/src/shared/game/grid/pageMode.ts +1 -1
  257. package/src/shared/game/grid/placementRows.ts +33 -0
  258. package/src/shared/game/grid/roadLayout.ts +26 -3
  259. package/src/shared/game/grid/singleplayer.json +0 -13
  260. package/src/shared/game/grid/voidFloor.ts +122 -0
  261. package/src/shared/game/strings.ts +15 -0
  262. package/src/shared/host/standalone/netInput.ts +2 -1
@@ -33,7 +33,7 @@ import { landedBy } from '@wildshard/engine/combat/damageBook';
33
33
  import type { HeadlessRuntimeInput } from '../headlessRuntime';
34
34
  import { actRoutes } from '@wildshard/engine/sim/actRoutes';
35
35
  import { openCellWorld, type CellWorld, type CellWorldOptions } from './cellWorld';
36
- import { addCellWalls, ROAD } from './roadWorld';
36
+ import { addCellWalls, addVoidFloor, renewVoidFloor, ROAD } from './roadWorld';
37
37
  import { netBuys, netWorldInput } from '../../../shared/host/standalone/netInput';
38
38
  import { cellDocuments, CONTINUATION, ContinuationSlots, SITE, siteDocuments, type SavedContinuation, type SavedSite } from './continuation';
39
39
  import { ledgerFilings } from './ledgerFilings';
@@ -57,7 +57,8 @@ export interface GridServerOptions {
57
57
  /** A world's tick finished, in how many milliseconds. */
58
58
  readonly stepped: (host: SimHost, ms: number) => void;
59
59
  readonly now: () => number;
60
- /** A one-shard page: this cell alone, inside its own walls, with no crossing out of it, whether the grid places it or not. */
60
+ /** A one-shard page: this cell alone, with no crossing out of it, whether the grid places it or not. It has no walls (GC36, J322): past
61
+ * its edge a player falls and is set back on the ground they last stood on. */
61
62
  readonly lone?: boolean;
62
63
  /** A proof's way in: start on the road at this world point, as no player can, rather than in the home cell. */
63
64
  readonly arrival?: Readonly<GridPoint>;
@@ -132,7 +133,7 @@ export class StandaloneGrid {
132
133
  if (home === undefined) throw new Error(`Standalone needs a grid cell: ${options.slug}`);
133
134
  const { saves, storage, savePrefix } = options, worlds = new Map<string, CellWorld>(), cells = new Map<string, ContinuationSlots<SavedContinuation>>();
134
135
  let settle: (held: ContinuationSlots<SavedContinuation>) => void = () => undefined;
135
- // A lone cell's world has walls and a grid cell's has a rim, so neither can restore the other's continuation. Facts and page progress they share.
136
+ // A lone cell's world stands alone and a grid cell's has a rim, so neither can restore the other's continuation. Facts and page progress they share.
136
137
  const documents = options.lone === true ? (instance: string): readonly [string, string] => cellDocuments(`lone-${instance}`) : cellDocuments;
137
138
  const continuation = saves.define(CONTINUATION), sites = new ContinuationSlots(saves.define(SITE), siteDocuments(options.lone === true ? `lone-${home.instance}` : 'grid'), storage, savePrefix);
138
139
  const slots = (instance: string): ContinuationSlots<SavedContinuation> => {
@@ -195,13 +196,15 @@ export class StandaloneGrid {
195
196
  private static road(rapier: Rapier, cells: readonly GridCell[], strips: readonly GridCollisionStrip[], saved: string | undefined, arrival: Readonly<GridPoint> | undefined, refused: GridServerOptions['refused']): SimHost {
196
197
  if (saved !== undefined) {
197
198
  try {
198
- const restored = restoreSimHost(ROAD, { rapier }, decodeSimSnapshot(saved));
199
+ const restored = restoreSimHost(ROAD, { rapier }, decodeSimSnapshot(saved)), player = sessionPlayer(restored);
200
+ if (renewVoidFloor(restored, cells, player.position, ROAD_SKIN)) player.motor.resetAt(player.position);
199
201
  holdStrips(restored, strips.map(strip => strip.mesh));
200
202
  return restored;
201
203
  } catch (error) { refused?.(error); } // a road holds no progress but where the player stood
202
204
  }
203
205
  const road = createSimHost(ROAD, { rapier }), [x, y, z] = readableSnapshot(saved ?? '')?.players[0]?.position ?? [], stood = arrival ?? (x === undefined || y === undefined || z === undefined ? undefined : { x, y, z });
204
206
  addCellWalls(road, cells);
207
+ addVoidFloor(road, cells);
205
208
  holdStrips(road, strips.map(strip => strip.mesh));
206
209
  const player = sessionPlayer(road);
207
210
  if (stood !== undefined) { player.position.set(stood.x, Math.max(stood.y, ROAD_SKIN), stood.z); player.motor.resetAt(player.position); }
@@ -1,15 +1,18 @@
1
1
  // The grid's road as a world of its own: the solo grid server's highway (`gridServer.ts`), and since GC15 a dedicated worker's road room
2
2
  // (`dedicated/roadRoom.ts`). Its frame is the world's; the ground lies far below the road's strips, which C2's grid pack carries.
3
+ import type { Collider } from '@dimforge/rapier3d-simd';
3
4
  import { withOwner } from '@wildshard/engine/app/ownership';
4
- import { CHUNK_HALF } from '@wildshard/engine/core/config';
5
+ import { CHUNK_HALF, CONTENT_CAPS } from '@wildshard/engine/core/config';
5
6
  import { groups } from '@wildshard/engine/physics/groups';
6
- import { stripCollider } from '@wildshard/engine/physics/stripColliders';
7
+ import { PLATFORM_COLLIDER_OWNER, stripCollider } from '@wildshard/engine/physics/stripColliders';
8
+ import { tagOf } from '@wildshard/engine/physics/surface';
7
9
  import type { Rapier } from '@wildshard/engine/physics/rapier';
8
10
  import { createSimHost, type SimHost, type SimLevel } from '@wildshard/engine/sim';
9
11
  import { SIM_API_VERSION } from '@wildshard/engine/sim/apiVersion';
10
12
  import type { GridCell } from '@wildshard/engine/game/grid/assembly';
11
13
  import type { GridCollisionStrip } from '@wildshard/engine/game/grid/gridCollision';
12
14
  import { HOST_PROBE } from '@wildshard/engine/game/plugin/simulation';
15
+ import { installVoidFloor, voidFloorBoxes } from '@wildshard/engine/game/grid/voidFloor';
13
16
  import { FALL_FLOOR } from './fallFloor';
14
17
 
15
18
  /** Ground under the whole grid, far below the road's strips, and a player's pace on them. */
@@ -33,17 +36,51 @@ export function addCellWalls(road: SimHost, cells: readonly Pick<GridCell, 'orig
33
36
  world.createCollider(R.ColliderDesc.cuboid(hx, WALL_HEIGHT, hz).setTranslation(origin.x + x, WALL_HEIGHT, origin.z + z).setCollisionGroups(groups('WORLD')));
34
37
  });
35
38
  }
39
+ /** Each road world's void floor colliders, so a placement can lift them (SA34a). */
40
+ const floors = new WeakMap<SimHost, readonly Collider[]>();
41
+ /** SA34: the 7 × 7's void, walkable: a road-level floor over every empty cell and out to the rail, and the rim on the rail. */
42
+ export function addVoidFloor(road: SimHost, cells: readonly Pick<GridCell, 'cell'>[], rim = true): void {
43
+ withOwner(road.scope, () => { floors.set(road, installVoidFloor(road.physics, cells, CONTENT_CAPS.pitch, rim)); });
44
+ }
45
+ /**
46
+ * SA34a: a running road is told of cells placed after it opened (SA33). The void floor is laid again for the grown grid, so none lies over a
47
+ * new cell's square; the new strips go in; and a new cell this worker can't hand a seat to gets the walls every other worker's cell has.
48
+ * The rim stays: it stands on the 7 × 7's rail whatever is placed.
49
+ */
50
+ export function placeOnRoad(road: SimHost, cells: readonly Pick<GridCell, 'cell'>[], strips: readonly GridCollisionStrip[], walled: readonly Pick<GridCell, 'origin'>[]): void {
51
+ const { world } = road.physics;
52
+ for (const collider of floors.get(road) ?? []) world.removeCollider(collider, false);
53
+ addVoidFloor(road, cells, false);
54
+ buildStrips(road, strips.map(strip => strip.mesh));
55
+ addCellWalls(road, walled);
56
+ }
57
+ /**
58
+ * SA34: a restored road's save holds the void floor and rim the saving build made (strips are held as data and out of every save,
59
+ * `gridServer.ts` `capture`, so each platform collider in it is the void's). Take them out and install this build's, so a restore
60
+ * never stacks a second floor and a save from the one-slab floor gets the tiles. Feet the slab had sunk below road level over the
61
+ * void stand back on it at `skin`.
62
+ */
63
+ export function renewVoidFloor(road: SimHost, cells: readonly Pick<GridCell, 'cell'>[], feet: { x: number; y: number; z: number }, skin: number): boolean {
64
+ const { world } = road.physics, saved: Parameters<typeof world.removeCollider>[0][] = [];
65
+ world.forEachCollider(collider => { if (tagOf(collider)?.owner === PLATFORM_COLLIDER_OWNER) saved.push(collider); });
66
+ for (const collider of saved) world.removeCollider(collider, false);
67
+ addVoidFloor(road, cells);
68
+ const overVoid = voidFloorBoxes(cells, CONTENT_CAPS.pitch).some(box => Math.abs(feet.x - box.x) <= box.hx && Math.abs(feet.z - box.z) <= box.hz);
69
+ if (!overVoid || feet.y >= skin || feet.y < -1) return false;
70
+ feet.y = skin; return true;
71
+ }
36
72
  /** C6: a room's world builds every strip at once, since no one list can follow every player. */
37
73
  export function buildStrips(host: SimHost, meshes: readonly GridCollisionStrip['mesh'][]): void {
38
74
  withOwner(host.scope, () => { for (const mesh of meshes) stripCollider(host.physics, mesh); });
39
75
  }
40
76
  /**
41
- * GC15: a dedicated worker's road, with nobody on it yet: every strip built, and walls only round `walled`, the cells it can't hand a
77
+ * GC15: a dedicated worker's road, with nobody on it yet: every strip built, the void's floor round `placed` (SA34), and walls only round `walled`, the cells it can't hand a
42
78
  * seat to (those on another worker: GC7's one line). Its lead seat is the room's to park.
43
79
  */
44
- export function openRoad(rapier: Rapier, walled: readonly Pick<GridCell, 'origin'>[], strips: readonly GridCollisionStrip[]): SimHost {
80
+ export function openRoad(rapier: Rapier, walled: readonly Pick<GridCell, 'origin'>[], strips: readonly GridCollisionStrip[], placed: readonly Pick<GridCell, 'cell'>[]): SimHost {
45
81
  const road = createSimHost(ROAD, { rapier });
46
82
  addCellWalls(road, walled);
83
+ addVoidFloor(road, placed);
47
84
  buildStrips(road, strips.map(strip => strip.mesh));
48
85
  return road;
49
86
  }
@@ -314,3 +314,36 @@ export function defaultBootAudio(data: AudioData): string[] {
314
314
  const selection = audioSelection(data, () => DEFAULT_SFX_SET), files = selectedBootAudio(selection.files(), new Set(selection.bootFiles(ENGINE_MUSIC_STYLE)));
315
315
  return [...files.music, ...files.sfx];
316
316
  }
317
+
318
+ // ---- AU18 (J304): the engine music a level names, and the files the cook derives from those names ----
319
+
320
+ type LevelMusic = NonNullable<AudioData['music']>;
321
+ /** The engine style's slots and stings a level's audio rows name. Slots: `title` when it boots one or plays a score set
322
+ * (whose `setCatalogue.inventory`, `title` or `base`, plays the engine title), and each score slot whose set is `base`
323
+ * (unset means `base`), as shard-format's `engineMusicSlots` reads them (a bank-mode score decodes its boot slots from
324
+ * the engine style; every shard today sets those `base`). Stings: each of `catalogue.extraStings` with no `stingSets`
325
+ * row, when the score's stings come from the engine (`SetScore.sting`: bank mode, or a base slot set `base`). */
326
+ export function engineMusicNames(music: LevelMusic): { slots: string[]; stings: StemSting[] } {
327
+ const base = music.setCatalogue === undefined ? music.slots.filter(slot => (music.sets[slot] ?? 'base') === 'base') : [];
328
+ const title = music.bootSlots.includes('title') || music.setCatalogue !== undefined ? ['title'] : [];
329
+ const catalogue = music.catalogue, engineStings = catalogue !== undefined && (catalogue.mode === 'bank' || (music.sets[music.base] ?? 'base') === 'base');
330
+ const stings = engineStings ? catalogue.extraStings.filter(sting => catalogue.stingSets[sting] === undefined) : [];
331
+ return { slots: [...new Set([...title, ...base])], stings: [...new Set(stings)] };
332
+ }
333
+ /** The names `engineMusicNames` reads that this build's engine style lacks, or ships without one of their files (a slot's
334
+ * calm, tension or layer stem, as the client drops the whole slot to the synth): `slot harbor`, `sting dawn`. Empty when
335
+ * every name resolves. The selection would drop them silently through `shipped`. */
336
+ export function missingEngineMusic(music: LevelMusic): string[] {
337
+ const manifest = musicManifest(ENGINE_MUSIC_STYLE), dir = musicDir(ENGINE_MUSIC_STYLE), { slots, stings } = engineMusicNames(music);
338
+ const has = (files: readonly string[]): boolean => files.every(file => shipped(`${dir}${file}`));
339
+ return [...slots.filter(slot => { const spec = manifest?.slots[slot]; return spec === undefined || !has([spec.calm, ...(spec.tension === undefined ? [] : [spec.tension]), ...spec.layers]); }).map(slot => `slot ${slot}`),
340
+ ...stings.filter(sting => { const file = manifest?.stings[sting]; return file === undefined || !has([file]); }).map(sting => `sting ${sting}`)];
341
+ }
342
+ /** AU18: the engine music a level's DOWNLOAD carries, derived from its names: the files of its default boot set
343
+ * (`defaultBootAudio`) under the engine style. Throws, naming each, when the rows name engine music this build lacks. */
344
+ export function engineMusicFiles(data: AudioData): string[] {
345
+ if (data.music === undefined) return [];
346
+ const missing = missingEngineMusic(data.music);
347
+ if (missing.length > 0) throw new Error(`its audio rows name engine music the ${ENGINE_MUSIC_STYLE} style lacks: ${missing.join(', ')}`);
348
+ return data.samples === undefined ? [] : defaultBootAudio(data).filter(url => url.startsWith(musicDir(ENGINE_MUSIC_STYLE)));
349
+ }
@@ -105,10 +105,10 @@ export interface LevelSpec {
105
105
  species: readonly string[]; spawns: readonly HerdPlan[]; spawnTables?: readonly string[];
106
106
  faunaTuning?: Partial<Record<string, Partial<HuntTuning>>>;
107
107
  /**
108
- * Edge dressing and containment. `visible` hides the drawing only; `walls: false` leaves out the four chunk-edge walls,
109
- * for a level placed inside a larger platform that owns what lies past its edge (absent = walls).
108
+ * Edge dressing. `visible` hides the drawing only. No level has chunk-edge walls (GRID-CROSSING GC36, J322): past its edge a
109
+ * one-shard page falls to its fall floor, and a grid cell opens onto the road.
110
110
  */
111
- boundary?: { visible?: boolean; walls?: boolean };
111
+ boundary?: { visible?: boolean };
112
112
  trees?: TreeSpec; forest?: ForestSpec; horizon?: HorizonSpec; horizonStrips?: HorizonStrips;
113
113
  minimap: MinimapSpec; hud?: HudSpec; pois?: readonly PoiSpec[];
114
114
  groundColor?: (x: number, z: number, h: number, slope: number, terrain: TerrainField, out: RGB) => RGB;
@@ -15,6 +15,9 @@ export interface NetChatReport { readonly kind: 'report'; readonly seq: number;
15
15
  export const STORY_ACT = 'story:';
16
16
  /** The `interact` a page's DEV tab Unstuck sends (Jake, 2026-11-12): the server puts its player back where a fall would, with no fall. */
17
17
  export const UNSTUCK_ACT = 'unstuck';
18
+ /** The `interact` the death card's Respawn now sends (QA 11-13, Jake: "It needs a button, a Respawn now button"): the server
19
+ * has already placed its fallen player, and ends that player's fade so their commands move them again. */
20
+ export const RESPAWN_NOW_ACT = 'respawn-now';
18
21
  export interface NetClimateAct { readonly kind: 'climate'; readonly seq: number; readonly op: typeof CLIMATE_OPS[number]; readonly name: string; readonly at: number }
19
22
  /** Buy one of the shard's goods, by its place in the shard's exchange. The server checks it and takes the price. */
20
23
  export interface NetBuyAct { readonly kind: 'buy'; readonly seq: number; readonly good: number }
@@ -0,0 +1,138 @@
1
+ // DEVICE-TELEMETRY DT3/DT4 (meta docs/plans/DEVICE-TELEMETRY-PLAN.md; Jake, 2026-11-13: "start gathering metadata for every single
2
+ // client that connects [...] so we can kind of reverse engineer what device is up playing"): the device word a client sends once per
3
+ // socket, and the one shape both sides bound it to. The client cuts its snapshot with `cleanDevice` before it sends; the door reads the
4
+ // word as untrusted input with `readDeviceWord` and logs `deviceLine`.
5
+ //
6
+ // Privacy line: device characteristics only, the ones any page can read (Client Hints, the User-Agent, the GPU name, screen, cores,
7
+ // memory, locale, connection type). No IP address, no new persistent identifier, no fingerprint hash, and nothing that reads files,
8
+ // contacts, sensors, the camera, the microphone or location.
9
+
10
+ /** The most bytes a device word may hold; a longer one is refused whole. Under the room's 1024-byte message cap
11
+ * (room.ts MAX_CLIENT_MESSAGE_BYTES), past which the socket itself closes `refused`. */
12
+ export const DEVICE_WORD_MAX_BYTES = 1000;
13
+ /** The `world` word's flag that says this door reads the device word. An older door never says it, so a client never sends one there:
14
+ * an older door closes `refused` on a control prefix it does not know (socketTransport.ts `receive`). */
15
+ export const DEVICE_WORD_FLAG = 'device';
16
+
17
+ /** Whether the door's `world` word says it reads the device word. Never throws. */
18
+ export function worldReadsDevice(bytes: ArrayBuffer): boolean {
19
+ try { const said: unknown = JSON.parse(new TextDecoder().decode(bytes)); return typeof said === 'object' && said !== null && DEVICE_WORD_FLAG in said && said[DEVICE_WORD_FLAG] === 1; }
20
+ catch { return false; }
21
+ }
22
+
23
+ type Kind = 'text' | 'long' | 'number' | 'flag' | 'list';
24
+ /** A device snapshot: every field optional. Nothing else crosses the wire. */
25
+ export interface DeviceSnapshot {
26
+ readonly build?: string;
27
+ // User-Agent Client Hints (Chromium): `model` names an Android phone ("Pixel 8", "SM-S918B")
28
+ readonly ua?: string; readonly model?: string; readonly platform?: string; readonly platformVersion?: string; readonly architecture?: string;
29
+ readonly bitness?: string; readonly wow64?: boolean; readonly mobile?: boolean;
30
+ readonly brands?: readonly string[]; readonly fullVersionList?: readonly string[]; readonly formFactors?: readonly string[];
31
+ // the game's own WebGL context
32
+ readonly gpu?: string; readonly gpuVendor?: string; readonly maxTexture?: number; readonly astc?: boolean; readonly etc2?: boolean; readonly bptc?: boolean;
33
+ readonly screenW?: number; readonly screenH?: number; readonly availW?: number; readonly availH?: number; readonly dpr?: number; readonly orientation?: string;
34
+ readonly cores?: number; readonly memory?: number; readonly touch?: number; readonly pointer?: string; readonly hover?: boolean;
35
+ readonly language?: string; readonly languages?: readonly string[]; readonly timeZone?: string;
36
+ readonly net?: string; readonly downlink?: number; readonly saveData?: boolean;
37
+ readonly display?: string;
38
+ }
39
+ type Field = keyof DeviceSnapshot;
40
+ /** Each field's kind, which `cleanDevice` bounds it by. */
41
+ const FIELDS: Readonly<Record<Field, Kind>> = {
42
+ build: 'text',
43
+ ua: 'long', model: 'text', platform: 'text', platformVersion: 'text', architecture: 'text', bitness: 'text', wow64: 'flag', mobile: 'flag',
44
+ brands: 'list', fullVersionList: 'list', formFactors: 'list',
45
+ gpu: 'text', gpuVendor: 'text', maxTexture: 'number', astc: 'flag', etc2: 'flag', bptc: 'flag',
46
+ screenW: 'number', screenH: 'number', availW: 'number', availH: 'number', dpr: 'number', orientation: 'text',
47
+ cores: 'number', memory: 'number', touch: 'number', pointer: 'text', hover: 'flag',
48
+ language: 'text', languages: 'list', timeZone: 'text',
49
+ net: 'text', downlink: 'number', saveData: 'flag',
50
+ display: 'text',
51
+ };
52
+
53
+ const TEXT_MAX = 96, LONG_MAX = 320, LIST_ITEMS = 6, ITEM_MAX = 48;
54
+ // Control, format (bidi, zero-width, soft hyphen), private-use and line/paragraph separators would let a junk word reorder or hide
55
+ // text in a journal line
56
+ const UNPRINTABLE = /[\p{Cc}\p{Cf}\p{Co}\p{Zl}\p{Zp}]/gu;
57
+ const text = (value: unknown, max: number): string | undefined => {
58
+ if (typeof value !== 'string') return undefined;
59
+ const cut = value.replaceAll(UNPRINTABLE, '').trim().slice(0, max);
60
+ return cut === '' ? undefined : cut;
61
+ };
62
+
63
+ /** A snapshot cut to the known fields and their bounds: unknown fields, wrong types and non-finite numbers drop. Never throws. */
64
+ export function cleanDevice(raw: unknown): DeviceSnapshot {
65
+ const out: Record<string, unknown> = {};
66
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return out;
67
+ for (const [field, kind] of Object.entries(FIELDS) as [Field, Kind][]) {
68
+ let value: unknown;
69
+ try { value = (raw as Record<string, unknown>)[field]; } catch { continue; }
70
+ if (kind === 'text' || kind === 'long') { const said = text(value, kind === 'long' ? LONG_MAX : TEXT_MAX); if (said !== undefined) out[field] = said; }
71
+ else if (kind === 'number') { if (typeof value === 'number' && Number.isFinite(value) && Math.abs(value) < 1e9) out[field] = Math.round(value * 1000) / 1000; }
72
+ else if (kind === 'flag') { if (typeof value === 'boolean') out[field] = value; }
73
+ else if (Array.isArray(value)) {
74
+ const items = value.slice(0, LIST_ITEMS).map(item => text(item, ITEM_MAX)).filter((item): item is string => item !== undefined);
75
+ if (items.length > 0) out[field] = items;
76
+ }
77
+ }
78
+ return out;
79
+ }
80
+
81
+ /** What a word too long sheds first, in order: the least telling fields go, the model and GPU stay. */
82
+ const SHED: readonly Field[] = ['fullVersionList', 'languages', 'brands', 'formFactors', 'ua', 'availW', 'availH', 'downlink', 'orientation', 'timeZone', 'gpuVendor'];
83
+ /** The word a client sends: its cleaned snapshot as JSON, under DEVICE_WORD_MAX_BYTES (fields shed in SHED's order until it fits). */
84
+ export function encodeDeviceWord(snapshot: DeviceSnapshot): ArrayBuffer {
85
+ const encoder = new TextEncoder(), clean: Record<string, unknown> = { ...cleanDevice(snapshot) };
86
+ let bytes = encoder.encode(JSON.stringify(clean));
87
+ for (const field of SHED) {
88
+ if (bytes.byteLength <= DEVICE_WORD_MAX_BYTES) break;
89
+ delete clean[field]; bytes = encoder.encode(JSON.stringify(clean));
90
+ }
91
+ return bytes.byteLength > DEVICE_WORD_MAX_BYTES ? encoder.encode('{}').buffer : bytes.buffer;
92
+ }
93
+
94
+ /** The door's read of a device word: untrusted bytes, so an oversized, non-JSON or non-object word is null. Never throws. */
95
+ export function readDeviceWord(bytes: ArrayBuffer): DeviceSnapshot | null {
96
+ if (bytes.byteLength === 0 || bytes.byteLength > DEVICE_WORD_MAX_BYTES) return null;
97
+ let said: unknown;
98
+ try { said = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)); } catch { return null; }
99
+ if (typeof said !== 'object' || said === null || Array.isArray(said)) return null;
100
+ return cleanDevice(said);
101
+ }
102
+
103
+ /** The browser and its major version, from the Client Hints brands, else the User-Agent. */
104
+ export function deviceBrowser(device: DeviceSnapshot): string | undefined {
105
+ const brand = [...(device.fullVersionList ?? []), ...(device.brands ?? [])].find(entry => !/not.?a.?brand|chromium/iu.test(entry));
106
+ if (brand !== undefined) return brand;
107
+ const ua = device.ua ?? '';
108
+ const found = /(Firefox|FxiOS|EdgA?|SamsungBrowser|OPR|CriOS|Chrome)\/(\d+)/u.exec(ua) ?? /Version\/(\d+)[^ ]* (?:Mobile\/\S+ )?Safari/u.exec(ua);
109
+ if (found === null) return undefined;
110
+ return found.length === 3 ? `${found[1] ?? ''} ${found[2] ?? ''}` : `Safari ${found[1] ?? ''}`;
111
+ }
112
+
113
+ /** Who a device line names: the player's Name (what everyone in the world sees) and their body id (the door's secret-keyed hash of the
114
+ * player id, `seats.ts` bodyId). Never the raw player id, which whoever holds it can play as, and never an address. */
115
+ export interface DeviceWho { readonly name: string; readonly body: string }
116
+ /** The door's one journal line per connect: who and what device. */
117
+ export function deviceLine(who: DeviceWho, device: DeviceSnapshot): Record<string, unknown> {
118
+ const line: Record<string, unknown> = { at: 'client.device', name: who.name, body: who.body };
119
+ const put = (key: string, value: unknown): void => { if (value !== undefined) line[key] = value; };
120
+ put('model', device.model); put('platform', device.platform); put('platformVersion', device.platformVersion);
121
+ put('browser', deviceBrowser(device)); put('gpu', device.gpu); put('gpuVendor', device.gpuVendor);
122
+ put('screen', device.screenW !== undefined && device.screenH !== undefined ? `${String(device.screenW)}x${String(device.screenH)}` : undefined);
123
+ put('dpr', device.dpr); put('memory', device.memory); put('cores', device.cores); put('touch', device.touch); put('mobile', device.mobile);
124
+ put('formFactors', device.formFactors?.join(',')); put('architecture', device.architecture); put('maxTexture', device.maxTexture);
125
+ put('textures', [device.astc === true ? 'astc' : '', device.etc2 === true ? 'etc2' : '', device.bptc === true ? 'bptc' : ''].filter(Boolean).join(',') || undefined);
126
+ put('language', device.language); put('timeZone', device.timeZone); put('net', device.net); put('display', device.display);
127
+ put('clientBuild', device.build); put('ua', device.ua);
128
+ return line;
129
+ }
130
+
131
+ /** SENTRY: the searchable tags (`device.model:*`), each under Sentry's 200-character tag value limit. */
132
+ export function deviceTags(device: DeviceSnapshot): Record<string, string> {
133
+ const tags: Record<string, string> = {};
134
+ const put = (key: string, value: string | number | undefined): void => { if (value !== undefined && value !== '') tags[key] = String(value).slice(0, 200); };
135
+ put('device.model', device.model); put('device.gpu', device.gpu); put('device.platform', device.platform);
136
+ put('device.platform_version', device.platformVersion); put('device.memory', device.memory);
137
+ return tags;
138
+ }
@@ -6,13 +6,16 @@ import type { NetChannel } from './transport';
6
6
  // `NET_SCHEMA_HASH` does not move.
7
7
 
8
8
  /** The prefix byte of every message on a game socket. */
9
- export const SOCKET_RELIABLE = 0, SOCKET_UNRELIABLE = 1, SOCKET_PING = 2, SOCKET_PONG = 3, SOCKET_RESUME = 4, SOCKET_READY = 5, SOCKET_COUNTDOWN = 6, SOCKET_PLAYTEST=7, SOCKET_VOICE = 8, SOCKET_WORLD = 9;
9
+ export const SOCKET_RELIABLE = 0, SOCKET_UNRELIABLE = 1, SOCKET_PING = 2, SOCKET_PONG = 3, SOCKET_RESUME = 4, SOCKET_READY = 5, SOCKET_COUNTDOWN = 6, SOCKET_PLAYTEST=7, SOCKET_VOICE = 8, SOCKET_WORLD = 9, SOCKET_DEVICE = 10;
10
10
  /** The messages outside the game protocol: the server's word on where to load, the client's that it has, and the server's that a new build is coming (J174). */
11
- export type SocketControl = 'resume' | 'ready' | 'countdown' | 'playtest' | 'voice' | 'world';
11
+ export type SocketControl = 'resume' | 'ready' | 'countdown' | 'playtest' | 'voice' | 'world' | 'device';
12
12
  /** GO4: the door's first word on every socket, before any hello: how many grid cells it hosts and, since opus-route2, the shard each
13
13
  * one runs, and nothing else (D7 keeps `/health` off the rooms address, so a page learns this here). A one-shard page joins only a
14
14
  * world that names its shard. A build from before it ignores the prefix. */
15
- export interface WorldWord { readonly cells: number; readonly shards: readonly string[] }
15
+ export interface WorldWord { readonly cells: number; readonly shards: readonly string[];
16
+ /** DEVICE-TELEMETRY DT3: 1 when this door reads the client's `device` word (deviceWord.ts). An older door never says it, and closes
17
+ * `refused` on a prefix it does not know, so a client sends the word only after hearing this. */
18
+ readonly device?: 1 }
16
19
  /** J218: a voice word is JSON in a few hundred bytes; an SDP travels in pieces of this many characters, under the room's 1024-byte cap. */
17
20
  export const VOICE_PIECE_CHARS = 400;
18
21
  /** The server sends no frame while this much is waiting (E7.1). Delta-against-ack heals, and the next frame is just bigger. */
@@ -43,7 +46,7 @@ export function closeReason(code: number): string {
43
46
  /** The prefix of a game message on `channel`. */
44
47
  export const channelPrefix = (channel: NetChannel): number => channel === 'reliable' ? SOCKET_RELIABLE : SOCKET_UNRELIABLE;
45
48
  /** The prefix of a control message. */
46
- export const controlPrefix = (control: SocketControl): number => control === 'resume' ? SOCKET_RESUME : control === 'ready' ? SOCKET_READY : control==='playtest'?SOCKET_PLAYTEST:control === 'voice' ? SOCKET_VOICE : control === 'world' ? SOCKET_WORLD : SOCKET_COUNTDOWN;
49
+ export const controlPrefix = (control: SocketControl): number => control === 'resume' ? SOCKET_RESUME : control === 'ready' ? SOCKET_READY : control==='playtest'?SOCKET_PLAYTEST:control === 'voice' ? SOCKET_VOICE : control === 'world' ? SOCKET_WORLD : control === 'device' ? SOCKET_DEVICE : SOCKET_COUNTDOWN;
47
50
  /** J174: seconds until everyone moves, and the build they move to, which a client preloads. */
48
51
  export interface Countdown { readonly seconds: number; readonly build: string }
49
52
  /** A `countdown` word. */
@@ -8,6 +8,8 @@ import type { Ball, Collider, Ray } from '@dimforge/rapier3d-simd';
8
8
  import type { Physics } from './Physics';
9
9
  import { GROUP, queryGroups, type GroupName } from './groups';
10
10
  import { tagOf, type Material } from './surface';
11
+ import { PLATFORM_COLLIDER_OWNER } from './stripColliders';
12
+ import { CHUNK_HALF } from '../core/config';
11
13
 
12
14
  interface Vec3 { x: number; y: number; z: number }
13
15
 
@@ -159,3 +161,28 @@ export function hasStaticGround(physics: Physics): boolean {
159
161
  });
160
162
  return found;
161
163
  }
164
+
165
+ /** GC30: the middle of each cell edge, 1 m in (a cell's own frame), where every platform edge has its 8 m entryway. */
166
+ export const CELL_ENTRYWAYS: readonly (readonly [number, number])[] = [[0, CHUNK_HALF - 1], [0, 1 - CHUNK_HALF], [CHUNK_HALF - 1, 0], [1 - CHUNK_HALF, 0]];
167
+ /**
168
+ * GC30: whether a cell's world has its own ground within `reach` of road height (y 0) at all four entryways, so a walker coming off the
169
+ * road stands. Asked of each collider, not the broad phase: a world that has never stepped has an empty one. The road's strips copied
170
+ * into the cell (its seams) don't count. Far Reach's sky islands have none, and a walker set down there fell out of the world.
171
+ */
172
+ export function entrywaysStand(physics: Physics, reach = 8): boolean {
173
+ const stands = entrywayProbe(physics, reach);
174
+ return CELL_ENTRYWAYS.every(([x, z]) => stands(x, z));
175
+ }
176
+ /**
177
+ * GC30b: the same probe at the one entryway on the side nearest `x`, `z` (a cell's own frame): whether a walker crossing in there
178
+ * from the road stands. Held solids (`NearColliders`) must be up around that entryway first.
179
+ */
180
+ export function entrywayStands(physics: Physics, x: number, z: number, reach = 8): boolean {
181
+ const side = Math.abs(x) > Math.abs(z) ? (x > 0 ? 2 : 3) : (z > 0 ? 0 : 1), [ex, ez] = CELL_ENTRYWAYS[side] ?? [0, 0];
182
+ return entrywayProbe(physics, reach)(ex, ez);
183
+ }
184
+ function entrywayProbe(physics: Physics, reach: number): (x: number, z: number) => boolean {
185
+ const ray = new physics.R.Ray({ x: 0, y: reach, z: 0 }, { x: 0, y: -1, z: 0 }), world: Collider[] = [];
186
+ physics.world.forEachCollider(collider => { if (!collider.isSensor() && ((collider.collisionGroups() >>> 16) & GROUP.WORLD) !== 0 && tagOf(collider)?.owner !== PLATFORM_COLLIDER_OWNER) world.push(collider); });
187
+ return (x, z) => { ray.origin = { x, y: reach, z }; return world.some(collider => collider.castRay(ray, reach * 2, true) >= 0); };
188
+ }
@@ -29,9 +29,6 @@ export function toColumnMajor(grid: Float32Array, res: number): Float32Array {
29
29
  return out;
30
30
  }
31
31
 
32
- /** Inner faces of the edge walls sit here; with the player's 0.4 m capsule the centre stops 1.2 m inside the chunk. */
33
- export const EDGE_WALL_INSET = 0.8;
34
-
35
32
  interface Ground { collider: Collider; grid: Float32Array; res: number; size: number; declared?: true }
36
33
  const grounds = new WeakMap<Physics, Ground>();
37
34
 
@@ -126,30 +123,24 @@ export function cutTerrain(physics: Physics, cuts: readonly TerrainCut[]): numbe
126
123
  return changed;
127
124
  }
128
125
 
129
- /** Four walls a little inside the chunk edge — the chunk floats; there is nothing to walk onto. `reuse` (SERVER-PARITY SS10):
130
- * a wall the world already holds (a native bake's own copy of these walls) stands as that wall, tagged `edge`, not twice. */
131
- export function addEdgeWalls(physics: Physics, options: { readonly reuse?: boolean } = {}): Collider[] {
132
- const { R, world } = physics;
133
- const t = 1, reach = CHUNK_HALF - EDGE_WALL_INSET + t, lo = -60, hi = 400;
134
- const cy = (lo + hi) / 2, hy = (hi - lo) / 2, span = CHUNK_HALF + 2;
135
- const walls: [number, number, number, number][] = [[reach, 0, t, span], [-reach, 0, t, span], [0, reach, span, t], [0, -reach, span, t]];
136
- const same = (a: number, b: number): boolean => Math.abs(a - b) < 1e-3;
137
- const held = (x: number, z: number, hx: number, hz: number): Collider | undefined => {
138
- let found: Collider | undefined;
139
- if (options.reuse === true) world.forEachCollider(c => {
140
- const material = tagOf(c)?.material;
141
- if (found !== undefined || (material !== undefined && material !== 'edge') || c.isSensor() || !c.isEnabled() || c.collisionGroups() !== groups('WORLD')
142
- || c.shapeType() !== R.ShapeType.Cuboid || c.parent()?.isDynamic() === true) return;
143
- const at = c.translation(), h = c.halfExtents(), q = c.rotation();
144
- if (h !== null && same(at.x, x) && same(at.y, cy) && same(at.z, z) && same(h.x, hx) && same(h.y, hy) && same(h.z, hz) && same(Math.abs(q.w), 1)) found = c;
145
- });
146
- return found;
147
- };
148
- return walls.map(([x, z, hx, hz]) => {
149
- const old = held(x, z, hx, hz);
150
- if (old !== undefined) { if (tagOf(old) === undefined) tagCollider(old, 'edge'); return old; }
151
- const c = world.createCollider(R.ColliderDesc.cuboid(hx, hy, hz).setTranslation(x, cy, z).setCollisionGroups(groups('WORLD')));
152
- tagCollider(c, 'edge');
153
- return c;
126
+ /** GRID-CROSSING GC36 (J322, no walls): whether a box is one of the four chunk-edge walls a page used to stand inside (the retired
127
+ * `addEdgeWalls`: 1 m thick, inner face 0.8 m inside the edge, y -60 to 400, unrotated at the cell's own origin). An older bake or
128
+ * a saved world still holds them, some with no material (Nalati's bake), so they are known by their shape. */
129
+ export function isChunkEdgeWall(at: readonly [number, number, number], half: readonly [number, number, number], w: number): boolean {
130
+ const near = (a: number, b: number): boolean => Math.abs(a - b) < 1e-2, reach = CHUNK_HALF - 0.8 + 1, span = CHUNK_HALF + 2;
131
+ if (!near(Math.abs(w), 1) || !near(at[1], 170) || !near(half[1], 230)) return false;
132
+ return near(Math.abs(at[0]), reach) && near(at[2], 0) && near(half[0], 1) && near(half[2], span)
133
+ || near(Math.abs(at[2]), reach) && near(at[0], 0) && near(half[2], 1) && near(half[0], span);
134
+ }
135
+
136
+ /** GC36: take out the chunk-edge walls a restored world brought back from a save made while lone cells had them. Returns how many. */
137
+ export function removeChunkEdgeWalls(physics: Physics): number {
138
+ const { R, world } = physics, walls: Collider[] = [];
139
+ world.forEachCollider(c => {
140
+ const material = tagOf(c)?.material, h = c.halfExtents(), at = c.translation();
141
+ if ((material !== undefined && material !== 'edge') || c.isSensor() || c.shapeType() !== R.ShapeType.Cuboid || c.parent()?.isDynamic() === true || h === null) return;
142
+ if (isChunkEdgeWall([at.x, at.y, at.z], [h.x, h.y, h.z], c.rotation().w)) walls.push(c);
154
143
  });
144
+ for (const wall of walls) world.removeCollider(wall, false);
145
+ return walls.length;
155
146
  }
@@ -423,6 +423,11 @@
423
423
  "shape": "e3b0c44298fc1c14",
424
424
  "migrations": []
425
425
  },
426
+ "json:device/'drop.seen'": {
427
+ "version": 1,
428
+ "shape": "e3b0c44298fc1c14",
429
+ "migrations": []
430
+ },
426
431
  "json:device/'drop.step.once'": {
427
432
  "version": 1,
428
433
  "shape": "e3b0c44298fc1c14",
@@ -468,6 +473,16 @@
468
473
  "shape": "e3b0c44298fc1c14",
469
474
  "migrations": []
470
475
  },
476
+ "json:device/'release.kept'": {
477
+ "version": 1,
478
+ "shape": "e3b0c44298fc1c14",
479
+ "migrations": []
480
+ },
481
+ "json:device/'screen.reports'": {
482
+ "version": 1,
483
+ "shape": "e3b0c44298fc1c14",
484
+ "migrations": []
485
+ },
471
486
  "json:device/'storage.persisted'": {
472
487
  "version": 1,
473
488
  "shape": "e3b0c44298fc1c14",
@@ -40,6 +40,8 @@ export interface ActRoutes {
40
40
  wear: ((player: string, id: string) => void) | null;
41
41
  /** A player's Unstuck (UNSTUCK_ACT): back to their last place or the spawn, as a fall would put them, with no fall. */
42
42
  unstuck: ((player: string) => void) | null;
43
+ /** A fallen player's Respawn now (RESPAWN_NOW_ACT): their fade ends at once. Absent where no room respawn is installed. */
44
+ respawnNow?: (player: string) => void;
43
45
  /** A boss's intro holds whoever stands in its arena. Only a page's session asks: a tape's steps run on through one. */
44
46
  introLocks?: boolean;
45
47
  /** A Developer asked that a fight's blows not land: a lair's script sees it, as a page's did. */
@@ -0,0 +1,24 @@
1
+ /** The keepsakes' law, shared by the page (compendium/keepsakes.ts) and the room (server/game/loot/keepsakeProgression.ts,
2
+ * SERVER-PARITY SS3b): how many of the economy's progression flags a player holds picks one admitted state, and that state
3
+ * names everything earned so far (Driftwood's sea glass charms). And whose book a taken pickup lands in (HS4). */
4
+ import { isCosmetic, type CosmeticId, type Owned, type OwnedId } from '../loot/Owned';
5
+
6
+ /** The admitted state for a player who holds `has`'s flags. A table with no state for that count is refused. */
7
+ export function progressionState<S>(progression: { readonly flags: readonly string[]; readonly states: readonly S[] }, has: (flag: string) => boolean): S {
8
+ const state = progression.states[progression.flags.filter(has).length];
9
+ if (state === undefined) throw new Error('Missing admitted reward state');
10
+ return state;
11
+ }
12
+
13
+ /** What a page reads and asks of the room it plays in: whether the server's book has a cosmetic on, and a wear act to flip it. */
14
+ export interface KeepsakeRoom { readonly worn: (id: CosmeticId) => boolean; readonly wear: (id: CosmeticId) => void }
15
+
16
+ /**
17
+ * A keepsake pickup the player took (Driftwood's trophies and the captain's hat). Off a room the page owns the book: it grants
18
+ * the item and puts on what its drop wears. In a room the server granted it at the kill (personal loot, a filed item) and keeps
19
+ * what is worn (SERVER-PARITY HS4), so the page grants nothing and asks the room to put a worn drop on, unless its book already has.
20
+ */
21
+ export function takeKeepsake(owned: Owned, id: OwnedId, wear: boolean, room: KeepsakeRoom | null): void {
22
+ if (room === null) { owned.grant(id); if (wear && isCosmetic(id)) owned.wear(id); return; }
23
+ if (wear && isCosmetic(id) && !room.worn(id)) room.wear(id);
24
+ }
@@ -4,7 +4,14 @@ import { GRID_RADIUS, GRID_CELL_COUNT } from '@wildshard/format/contentBounds';
4
4
  import { AccentSchema } from '@wildshard/format/accent';
5
5
 
6
6
  const id = v.pipe(v.string(), v.regex(/^_?[a-z0-9]+(?:-[a-z0-9]+)*$/u));
7
- const signed = v.pipe(v.number(), v.integer(), v.minValue(-GRID_RADIUS), v.maxValue(GRID_RADIUS));
7
+ /**
8
+ * The grid radius the engine places and draws: the format's 7 × 7 (shard-format v0.4.7 `GRID_RADIUS` 3, SA29). SA34 drew it:
9
+ * the sightline, the far ring's reach and the road sky's dome are sized from it (`farProxy.ts`), the rail stands on its outer
10
+ * shoulder and every empty cell is walkable void floor (`voidFloor.ts`). J305's 25 keep their cells; ring 3 starts empty.
11
+ */
12
+ export const DRAWN_GRID_RADIUS: number = GRID_RADIUS;
13
+ if (DRAWN_GRID_RADIUS > GRID_RADIUS) throw new RangeError('DRAWN_GRID_RADIUS exceeds the format grid');
14
+ const signed = v.pipe(v.number(), v.integer(), v.minValue(-DRAWN_GRID_RADIUS), v.maxValue(DRAWN_GRID_RADIUS));
8
15
  const local = v.pipe(v.number(), v.finite(), v.minValue(-250), v.maxValue(250));
9
16
  /** one number panel: a cell-local spot (metres, x east, y up, z north) on the copy's own structures, facing `yaw` (0 = +z) */
10
17
  const mark = v.strictObject({ x: local, y: v.pipe(v.number(), v.finite(), v.minValue(0), v.maxValue(250)), z: local, yaw: v.pipe(v.number(), v.finite()), size: v.pipe(v.number(), v.minValue(0.5), v.maxValue(12)) });
@@ -30,10 +37,10 @@ export const GridCatalogueSchema: v.GenericSchema<BoundedGridCatalogueInput, Bou
30
37
  fog: v.pipe(v.strictObject({ colour, near: distance, far: distance }), v.check((row) => row.far > row.near, 'increasing fog distance')) }),
31
38
  }), v.check((rows) => {
32
39
  const valid = (entries: readonly { instance: string; cell: readonly [number, number] }[]): boolean => new Set(entries.map((row) => row.instance)).size === entries.length && new Set(entries.map((row) => row.cell.join(','))).size === entries.length;
33
- // One complete layout fills every cell for every audience (G972).
34
- const base = rows.cells;
35
- return valid(base) && base.length === GRID_CELL_COUNT;
36
- }, 'unique stable instance identities and complete signed cell layout'));
40
+ // One layout for every audience (G972). shard-format v0.4.7 (SA29) made GRID_CELL_COUNT the 7 × 7's 49 as a maximum
41
+ // and lets any cell stay empty, so J305's 25 still reads; `maxLength` above and `signed` cap the count.
42
+ return valid(rows.cells);
43
+ }, 'unique stable instance identities and cells'));
37
44
  /** Admitted assembly input; a cell remains a mutable placement attribute, never a save namespace. */
38
45
  export type GridCatalogue = v.InferOutput<typeof GridCatalogueSchema>;
39
46
  /** A copy's declared identity: its accent and its number panels (copyIdentity.ts). */
@@ -16,6 +16,8 @@ export interface CatalogueDocument {
16
16
  /** Parsed by `parseGridCatalogue`, which owns its shape. */
17
17
  readonly grid: {readonly cells: readonly {readonly instance: string; readonly slug: string}[]};
18
18
  readonly shards?: readonly CatalogueHead[];
19
+ /** The slugs a released page's placement file added to `grid` at runtime (SA33's file, `placedCells.ts`); never in a baked copy. */
20
+ readonly placed?: readonly string[];
19
21
  }
20
22
 
21
23
  const SLOT = Symbol.for('game.catalogue');
@@ -51,3 +53,19 @@ export function titleStatus(row: {readonly slug: string; readonly status?: strin
51
53
  export function playerHidden(row: {readonly slug: string; readonly status?: string}): boolean {
52
54
  return titleStatus(row) === 'hidden' || (row.slug.startsWith('_') && placedStatus(row) === undefined);
53
55
  }
56
+ /**
57
+ * SA34 (J314, grill Q12): an auto-placed shard gets no Shard Select card; you cross in from a neighbour. Auto-placed means the
58
+ * installed catalogue's grid places the slug and its `placements` (the title's rows) don't name it: api-server's first-upload
59
+ * placement (SA30, `grid-autoplace.ts`) writes only a `grid.cells` row, never a placement, while every carded shard (J305's
60
+ * grid shards and the off-grid ones) has a placement row. A page with no installed catalogue has nothing auto-placed.
61
+ */
62
+ export function autoPlaced(row: {readonly slug: string}): boolean {
63
+ const catalogue = installedCatalogue();
64
+ if (catalogue === undefined || catalogue.placements.some(placed => bareSlug(placed.slug) === bareSlug(row.slug))) return false;
65
+ return catalogue.grid.cells.some(cell => bareSlug(cell.slug) === bareSlug(row.slug));
66
+ }
67
+ /** A shard the API placed on this channel after the build (the placement file's cell, `placedCells.ts`): Shard Select cards it, an open
68
+ * plot or an auto-placed shard too, because with no crossing (staging's default) its card and `?chunk=` are the only ways in. */
69
+ export function placedByFile(row: {readonly slug: string}): boolean {
70
+ return installedCatalogue()?.placed?.some(slug => bareSlug(slug) === bareSlug(row.slug)) === true;
71
+ }