@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
@@ -9,9 +9,11 @@ import { saves } from '@wildshard/engine/saves/runtime';
9
9
  import type { SimHost } from '@wildshard/engine/sim';
10
10
  import { actRoutes } from '@wildshard/engine/sim/actRoutes';
11
11
  import type { PlayerSim } from '@wildshard/engine/sim/playerSim';
12
+ import { carryMotion } from '@wildshard/engine/game/grid/simulation';
12
13
  import { netBuys, netWorldInput } from '../../../shared/host/standalone/netInput';
13
14
  import type { HeadlessRuntimeInput } from '../headlessRuntime';
14
- import { LEAD_SEAT, openCellWorld, type CellWorld } from '../standalone/cellWorld';
15
+ import { LEAD_SEAT, type CellWorld } from '../standalone/cellWorld';
16
+ import { openWorld } from '../openWorld';
15
17
  import type { FallFloor } from '../standalone/fallFloor';
16
18
  import { ledgerFilings } from '../standalone/ledgerFilings';
17
19
  import { questBooks } from '@wildshard/engine/quest/players';
@@ -24,7 +26,7 @@ import { LEFT } from './socketPump';
24
26
  import type {PlaytestHit} from './playtest';
25
27
  import { cellFrame, cellName } from './gridCells';
26
28
  import {hitHistoryOf} from '@wildshard/engine/combat/rewind';
27
- import { floorBelow } from '@wildshard/engine/physics/query';
29
+ import { entrywaysStand, floorBelow } from '@wildshard/engine/physics/query';
28
30
  import type { GridAssembly } from '@wildshard/engine/game/grid/assembly';
29
31
  import type { GridCollisionStrip } from '@wildshard/engine/game/grid/gridCollision';
30
32
  import { buildStrips } from '../standalone/roadWorld';
@@ -69,7 +71,7 @@ export interface DedicatedRoomOptions {
69
71
  /** GO3: the grid instance this room is, which names it everywhere else and numbers its frames. Left out, the shard's own grid cell. */
70
72
  readonly cell?: string;
71
73
  /**
72
- * GC15 (`WORLD_CROSSING=worker`): this worker's road, which the cell opens onto instead of standing inside its lone walls. Its seam
74
+ * GC15 (`WORLD_CROSSING=worker`): this worker's road, which the cell opens onto instead of standing lone. Its seam
73
75
  * strips are built into the cell's world, and a seat whose feet leave the cell asks the door to cross onto the road.
74
76
  */
75
77
  readonly road?: DedicatedRoomRoad;
@@ -138,7 +140,8 @@ export class DedicatedRoom implements CrossTarget {
138
140
  if (seat === undefined) throw new Error(`No seat for ${body}`);
139
141
  return seat;
140
142
  };
141
- const cell = await openCellWorld({ instance: options.cell ?? cellName(slug) }, input, undefined, { saves, lone: options.road === undefined, wholeSolids: true, pageless: true,
143
+ // SERVER-PARITY HS1: the one world-build entry a shard's CI journeys tick too
144
+ const cell = await openWorld(input, { room: true, cell: options.cell ?? cellName(slug), saves, lone: options.road === undefined,
142
145
  owned: body => seated(body).store.slots,
143
146
  profiles: {
144
147
  read: identity => seats.get(identity)?.store.rewards.read(slug).players[identity] ?? null,
@@ -227,6 +230,8 @@ export class DedicatedRoom implements CrossTarget {
227
230
  }
228
231
  return seat;
229
232
  }
233
+ /** GC30: whether a walker off the road stands at this cell's entryways (`entrywaysStand`); else its worker's road walls it. */
234
+ entrywaysStand(): boolean { return entrywaysStand(this.host.physics, ARRIVAL_LIFT); }
230
235
  /** GC15: this seat's feet left for cell `to`, standing at `at` in that cell's own frame. The door reads their save there and orders `handOver`. */
231
236
  crossing(device: string, to: string, at: ResumeAt): void {
232
237
  if ((this.seats.get(device)?.transport ?? null) !== null) this.options.post({ kind: 'crossing', device, to, at });
@@ -241,7 +246,8 @@ export class DedicatedRoom implements CrossTarget {
241
246
  handOver(device: string, target: CrossTarget, entry: SeatEntry, at: ResumeAt): boolean {
242
247
  const seat = this.seats.get(device), transport = seat?.transport ?? null;
243
248
  if (seat === undefined || transport === null || seat.client === null || !this.net.live(seat.client) || target === this || target.holds(device)) return false;
244
- const arrived = target.admit(entry, transport, at);
249
+ // GC34: the walker's own motion goes with them; a rider's lives on the mount it leaves here, so it arrives on foot from rest
250
+ const arrived = target.admit(entry, transport, at, mountedPlayerOf(this.host, seat.body)?.mounted === true ? undefined : this.host.players.get(seat.body));
245
251
  if (typeof arrived === 'string') return false;
246
252
  mountedPlayerOf(this.host, seat.body)?.dismount();
247
253
  this.write(seat, 'cross');
@@ -252,13 +258,14 @@ export class DedicatedRoom implements CrossTarget {
252
258
  return arrived.land(client);
253
259
  }
254
260
  /** GC15: a crossing seat's body here, from the door's read of its save on this shard (the previous copy if that one won't import). */
255
- admit(entry: SeatEntry, transport: Transport, at: ResumeAt): CrossArrival | string {
261
+ admit(entry: SeatEntry, transport: Transport, at: ResumeAt, motion?: PlayerSim): CrossArrival | string {
256
262
  const { previous, ...current } = entry, { device } = entry;
257
263
  let arrived = this.place(current, transport, at), recovered = false;
258
264
  if (typeof arrived === 'string' && previous !== undefined) { arrived = this.place({ ...current, doc: previous.doc, recovery: previous.recovery }, transport, at); recovered = typeof arrived !== 'string'; }
259
265
  if (typeof arrived === 'string') return arrived;
260
266
  if (recovered) this.options.post({ kind: 'recovered', device, seq: entry.seq });
261
- const seat = arrived;
267
+ const seat = arrived, player = this.host.players.get(seat.body);
268
+ if (motion !== undefined && player !== undefined) carryMotion(motion, player);
262
269
  this.arriving.add(seat.body);
263
270
  return { body: seat.body, land: client => {
264
271
  this.settle(seat);
@@ -368,7 +375,13 @@ export class DedicatedRoom implements CrossTarget {
368
375
  const player = this.host.players.get(body);
369
376
  if (player === undefined || !finite(player.position)) continue;
370
377
  const { x, y, z } = player.position, top = floorBelow(this.host.physics, x, z, y + ARRIVAL_LIFT, ARRIVAL_LIFT * 2);
371
- if (top !== undefined && top > y + ARRIVAL_SKIN) player.resetPose({ x, y: top + ARRIVAL_SKIN, z }, player.yaw);
378
+ if (top === undefined || top <= y + ARRIVAL_SKIN) continue;
379
+ // GC34: set on the top, the walker keeps the ground speed, board, push and dash it crossed with (a reset stands it still, on foot)
380
+ const { x: vx, z: vz } = player.velocity, { on, hoverAir, hoverBob } = player.board, impulse = player.impulse.clone(), dash = { ...player.dash };
381
+ player.resetPose({ x, y: top + ARRIVAL_SKIN, z }, player.yaw);
382
+ if (on) player.setBoard(true);
383
+ player.board.hoverAir = hoverAir; player.board.hoverBob = hoverBob;
384
+ player.velocity.x = vx; player.velocity.z = vz; player.impulse.copy(impulse); Object.assign(player.dash, dash);
372
385
  }
373
386
  }
374
387
  private filings(): readonly LedgerFiling[] {
@@ -3,6 +3,7 @@
3
3
  // player's progress under the shard's slug, so a save made before GO3 reads back. A name the grid doesn't place is a cell of its own.
4
4
  import { GridAssembly } from '@wildshard/engine/game/grid/assembly';
5
5
  import { catalogueDocument } from '@wildshard/engine/game/grid/catalogueDocument';
6
+ import { GRID_RADIUS } from '@wildshard/format/contentBounds';
6
7
 
7
8
  /** `WORLD_CELLS=grid`: every grid cell the release names, the home cell first. */
8
9
  export const WHOLE_GRID = 'grid';
@@ -10,19 +11,61 @@ export const WHOLE_GRID = 'grid';
10
11
  const UNPLACED_FRAME = 1;
11
12
 
12
13
  /** The grid's cells in catalogue order, and each one's frame, by instance and by shard. */
13
- interface GridNames { readonly instances: readonly string[]; readonly frames: ReadonlyMap<string, number>; readonly shards: ReadonlyMap<string, string>; readonly cells: ReadonlyMap<string, string>; readonly home: string | undefined }
14
- let read: { readonly from: unknown; readonly names: GridNames } | null = null;
15
- /** Parsed once per installed catalogue, the way a grid page assembles it. */
14
+ interface GridNames { readonly instances: readonly string[]; readonly frames: ReadonlyMap<string, number>; readonly shards: ReadonlyMap<string, string>; readonly cells: ReadonlyMap<string, string>; readonly home: string | undefined;
15
+ /** Each taken spot (`x,z`), and the instance on it. */
16
+ readonly spots: ReadonlyMap<string, string> }
17
+ /** SA33: one cell a signed placement file names: the API's placement of a new slug (SA30), on a spot the catalogue leaves empty. */
18
+ export interface PlacedCell { readonly instance: string; readonly slug: string; readonly cell: readonly [number, number] }
19
+ /** SA33: the cells placed on this running server, in the placement file's order, after the catalogue's. A restart forgets them; the
20
+ * placement watch's first look places them again. */
21
+ const placed: PlacedCell[] = [];
22
+ let read: { readonly from: unknown; readonly placed: number; readonly names: GridNames } | null = null;
23
+ /** Parsed once per installed catalogue, the way a grid page assembles it, then the placed cells: frame `catalogue count + n`. */
16
24
  function gridNames(): GridNames {
17
25
  const { grid } = catalogueDocument();
18
- if (read?.from === grid) return read.names;
19
- const { cells } = new GridAssembly({ developer: false, devserver: false }, grid);
20
- const names: GridNames = { instances: cells.map(cell => cell.instance), frames: new Map(cells.map((cell, index) => [cell.instance, index + 1])),
21
- shards: new Map(cells.map(cell => [cell.instance, cell.slug])), cells: new Map(cells.map(cell => [cell.slug, cell.instance])),
22
- home: cells.find(cell => cell.cell[0] === 0 && cell.cell[1] === 0)?.instance };
23
- read = { from: grid, names };
26
+ if (read?.from === grid && read.placed === placed.length) return read.names;
27
+ const { cells } = new GridAssembly({ developer: false, devserver: false }, grid), rows = [...cells.map(({ instance, slug, cell }) => ({ instance, slug, cell })), ...placed];
28
+ const names: GridNames = { instances: rows.map(cell => cell.instance), frames: new Map(rows.map((cell, index) => [cell.instance, index + 1])),
29
+ shards: new Map(rows.map(cell => [cell.instance, cell.slug])), cells: new Map(rows.map(cell => [cell.slug, cell.instance])),
30
+ home: cells.find(cell => cell.cell[0] === 0 && cell.cell[1] === 0)?.instance, spots: new Map(rows.map(cell => [cell.cell.join(','), cell.instance])) };
31
+ read = { from: grid, placed: placed.length, names };
24
32
  return names;
25
33
  }
34
+ /**
35
+ * SA33: place a cell the API placed (a new slug, J314) on this running server. True when it is new here, false when this server already
36
+ * places it the same way. A slug keeps one cell for life and a spot holds one cell, so a row that disagrees with the catalogue or an earlier
37
+ * placement throws and changes nothing. The server draws nothing, so any spot inside the format's grid (the 7 × 7, SA29) is admitted.
38
+ */
39
+ export function placeCell(row: PlacedCell): boolean {
40
+ const { shards, cells, spots } = gridNames(), [x, z] = row.cell, spot = `${String(x)},${String(z)}`;
41
+ if (shards.has(row.instance)) {
42
+ if (cells.get(row.slug) === row.instance && spots.get(spot) === row.instance) return false;
43
+ throw new Error(`${row.instance} is already placed elsewhere`);
44
+ }
45
+ if (!Number.isInteger(x) || !Number.isInteger(z) || Math.abs(x) > GRID_RADIUS || Math.abs(z) > GRID_RADIUS) throw new Error(`${row.instance}'s cell ${spot} is off the grid`);
46
+ if (cells.has(row.slug) || shards.has(row.slug)) throw new Error(`${row.slug} already has a cell`);
47
+ if (cells.has(row.instance)) throw new Error(`${row.instance} is a placed shard's name`);
48
+ const taken = spots.get(spot);
49
+ if (taken !== undefined) throw new Error(`${spot} is ${taken}'s`);
50
+ placed.push({ instance: row.instance, slug: row.slug, cell: [x, z] });
51
+ return true;
52
+ }
53
+ let assembled: { readonly from: unknown; readonly placed: number; readonly assembly: GridAssembly } | null = null;
54
+ /**
55
+ * SA34a: the grid a road walks: the installed catalogue's cells and then the placed ones, so a road and its cells know a placed cell's
56
+ * square. `placedToo` false: the catalogue's alone, the grid the build's road pack was baked for.
57
+ */
58
+ export function gridAssembly(placedToo = true): GridAssembly {
59
+ const { grid } = catalogueDocument(), count = placedToo ? placed.length : 0;
60
+ if (assembled?.from === grid && assembled.placed === count) return assembled.assembly;
61
+ const assembly = new GridAssembly({ developer: false, devserver: false }, count === 0 ? grid : { ...grid, cells: [...grid.cells, ...placed.map(({ instance, slug, cell }) => ({ instance, slug, cell: [...cell] }))] });
62
+ assembled = { from: grid, placed: count, assembly };
63
+ return assembly;
64
+ }
65
+ /** What a worker thread is booted with, so its rooms name, frame and load a placed cell as the door does. */
66
+ export function placedCells(): readonly PlacedCell[] { return [...placed]; }
67
+ /** Tests only: forget every placed cell. */
68
+ export function forgetPlacedCells(): void { placed.length = 0; read = null; assembled = null; }
26
69
 
27
70
  /** The instance a name means: an instance stands, a grid shard's slug becomes its cell, and anything else is its own name. */
28
71
  export function cellName(name: string): string { const { shards, cells } = gridNames(); return shards.has(name) ? name : cells.get(name) ?? name; }
@@ -24,9 +24,10 @@ import { sendSentryTest, serverSentry } from './serverSentry';
24
24
  import {PlaytestFile} from './playtest';
25
25
  import { World, type PlayerSaves, type WorkerLink } from './world';
26
26
  import { cloudflareTurn } from './voiceRelay';
27
- import { worldSettings } from './workerTable';
27
+ import { worldCrossing, worldSettings } from './workerTable';
28
28
  import { doorTrust } from './doorTrust';
29
- import { cellShard, worldCells } from './gridCells';
29
+ import { WHOLE_GRID, cellShard, placeCell, placedCells, worldCells } from './gridCells';
30
+ import { PlacementWatch, fetchPlacementFile } from './placementFile';
30
31
 
31
32
  declare const __BUILD_ID__: string;
32
33
  /** scripts/build-server.mjs: package.json's version, the Sentry release (S8). */
@@ -56,8 +57,8 @@ async function installedRelease(): Promise<ReleaseFile> {
56
57
  const release = await installedRelease();
57
58
  // C5, C11, GO3: the cells, by grid instance, fixed at startup; a player with no save lands in the first. `grid` opens every grid cell
58
59
  // the release names, home first. A cell runs its shard's pack, and the release must name that shard.
59
- const cells = worldCells(process.env['WORLD_CELLS'] ?? 'driftwood-isle', release.shards.map(shard => shard.slug)), shards = [...new Set(cells.map(cellShard))];
60
- const hold = process.env['HOLD_MS'], grace = process.env['GRACE_MS'], poll = process.env['RELEASE_POLL_MS'], recordEvery = process.env['RECORD_MS'];
60
+ const listed = process.env['WORLD_CELLS'] ?? 'driftwood-isle', cells = worldCells(listed, release.shards.map(shard => shard.slug)), shards = [...new Set(cells.map(cellShard))];
61
+ const hold = process.env['HOLD_MS'], empty = process.env['EMPTY_MS'], grace = process.env['GRACE_MS'], poll = process.env['RELEASE_POLL_MS'], recordEvery = process.env['RECORD_MS'];
61
62
  // An env file's blank row means unset.
62
63
  const setting = (name: string): string | undefined => { const value = process.env[name]; return value === '' ? undefined : value; };
63
64
  const sentry = serverSentry({ dsn: setting('SENTRY_DSN'), version: engineVersion, build, channel: release.channel });
@@ -65,15 +66,16 @@ const reports = new ServerReports({ build, channel: release.channel, telemetryUr
65
66
  const url = process.env['DATABASE_URL'] ?? savesUrl(release.channel), saves: PlayerSaves = url === 'memory:' ? memoryPlayerSaves() : await openPlayerSaves(url, new URL('migrations/', import.meta.url), release.saveEpoch, log, issue => { reports.contract(issue); });
66
67
  const recordTag=setting('RECORD_TAG');
67
68
  const turnKey = setting('WILDSHARD_TURN_KEY_ID'), turnToken = setting('WILDSHARD_TURN_KEY_TOKEN');
68
- // GC15: `WORLD_CROSSING=worker` opens each worker's road and lets a seat walk between the cells it hosts. Off unless set (GRID-CROSSING).
69
- const crossingSetting = setting('WORLD_CROSSING');
70
- if (crossingSetting !== undefined && crossingSetting !== 'worker') throw new Error(`WORLD_CROSSING=${crossingSetting}: only worker, or unset`);
71
- const crossing = crossingSetting === 'worker';
69
+ // GC15, GC35: each worker opens its road and lets a seat walk between the cells it hosts; only `WORLD_CROSSING=off` keeps cells lone (J322).
70
+ const crossing = worldCrossing(setting('WORLD_CROSSING'));
71
+ // SA33: where the API's signed placement file is, and its own key's public half. Both or neither; only a whole-grid world grows.
72
+ const placementAt = setting('PLACEMENT_URL'), placementKey = setting('PLACEMENT_PUBLIC_KEY');
73
+ if ((placementAt === undefined) !== (placementKey === undefined)) throw new Error('PLACEMENT_URL and PLACEMENT_PUBLIC_KEY go together');
72
74
  const playtest=process.env['PLAYTEST']==='1'?new PlaytestFile({directory:setting('PLAYTEST_DIR')??'/var/log/wildshard',build,log,...(recordTag===undefined?{}:{tag:recordTag})}):undefined;
73
75
 
74
76
  /** One row of the table is one worker thread, started once (J182). */
75
77
  function bootWorker(slugs: readonly string[]): WorkerLink {
76
- const data: CellWorkerData = { slugs, build, origin, cache, ...(hold === undefined ? {} : { holdMs: Number(hold) }), ...(crossing ? { crossing } : {}),...(playtest===undefined?{}:{playtest:true}) };
78
+ const data: CellWorkerData = { slugs, build, origin, cache, placed: placedCells(), ...(hold === undefined ? {} : { holdMs: Number(hold) }), ...(empty === undefined ? {} : { emptyMs: Number(empty) }), ...(crossing ? { crossing } : {}),...(playtest===undefined?{}:{playtest:true}) };
77
79
  const worker = new Worker(new URL('cellWorker.mjs', import.meta.url), { workerData: data });
78
80
  let stopped = false;
79
81
  return { send: (order, transfer = []) => { worker.postMessage(order, transfer as never); },
@@ -93,17 +95,19 @@ const failed = (error: unknown): void => { if (ending) return; ending = true; lo
93
95
  process.on('uncaughtException', failed);
94
96
  // VH10: which forwarded header the door believes, and which pages may open a socket. A word it doesn't know stops here.
95
97
  const trust = doorTrust(process.env);
96
- const world: World = await World.open({ build, cells, ...worldSettings(release.channel, process.env), ...trust, secret: need('SEAT_SECRET'), saves, log, boot: bootWorker, ...(grace === undefined ? {} : { graceMs: Number(grace) }),
98
+ const world: World = await World.open({ build, cells, roads: crossing, ...worldSettings(release.channel, process.env), ...trust, secret: need('SEAT_SECRET'), saves, log, boot: bootWorker, ...(grace === undefined ? {} : { graceMs: Number(grace) }),
97
99
  // Q77: a worker that fails ends the process. systemd starts it again, clients redial, and saves stand at the last checkpoint.
98
100
  crashed: failed, reading: (index, row) => { reports.heard(index, row); },
99
101
  ...(playtest===undefined?{}:{playtest:row=>{playtest.append(row);}}),
100
102
  // J218: phones on 4G need TURN to reach each other's voice. Without the key, voice falls back to public STUN.
101
103
  ...(turnKey === undefined || turnToken === undefined ? {} : { voiceIce: cloudflareTurn(turnKey, turnToken) }),
102
104
  restart: () => { stop(0); } });
105
+ /** SA33's watch, once the door listens; `/health` names its serial. */
106
+ let placements: PlacementWatch | null = null;
103
107
  const server = createServer((request, response) => {
104
108
  if (request.url !== '/health') { response.writeHead(404).end(); return; }
105
109
  // E7.5 prep: any page may read it (no player data), so the Connection doctor sees the build; `now` lets it read a phone's clock.
106
- response.writeHead(200, { 'content-type': 'application/json', 'access-control-allow-origin': '*', 'cache-control': 'no-store' }).end(JSON.stringify({ ...world.health(), serial: release.serial, uptime: Math.round((Date.now() - started) / 1000), now: Date.now() }));
110
+ response.writeHead(200, { 'content-type': 'application/json', 'access-control-allow-origin': '*', 'cache-control': 'no-store' }).end(JSON.stringify({ ...world.health(), serial: release.serial, ...(placements === null ? {} : { placements: placements.serial }), uptime: Math.round((Date.now() - started) / 1000), now: Date.now() }));
107
111
  });
108
112
  server.on('upgrade', (request, socket, head) => { world.upgrade(request, socket, head); });
109
113
  stop = (code): void => { void (async (): Promise<void> => {
@@ -131,4 +135,19 @@ const watch = new ReleaseWatch({ read: readRelease, serving: release, cells: sha
131
135
  for (const slug of shards) await readPackProduct(slug, next.engineBuild, await rapier(), { origin, cache }, reads);
132
136
  world.beginGrace(next.engineBuild);
133
137
  } });
134
- process.once('SIGTERM', () => { watch.dispose(); stop(0); });
138
+ // SA33: a cell the API placed opens on this running server within a look, on a worker of its own, with no grace and no restart. Its shard's
139
+ // server pack must already be in this build's book: one that isn't is refused here, before any worker boots, and asked for again next look.
140
+ placements = placementAt === undefined || placementKey === undefined || listed.trim() !== WHOLE_GRID ? null : new PlacementWatch({
141
+ read: () => fetchPlacementFile(placementAt, placementKey), channel: release.channel, ...(poll === undefined ? {} : { everyMs: Number(poll) }),
142
+ failed: error => { log({ at: 'placement.failed', error: String(error) }); },
143
+ open: async rows => {
144
+ const ready: string[] = [];
145
+ for (const row of rows) {
146
+ // SA34a: the pack first, so the door's placed list (and so every worker's frame numbers) holds only cells it opens.
147
+ try { await readPackProduct(row.slug, build, await rapier(), { origin, cache }, reads); placeCell(row); ready.push(row.instance); }
148
+ catch (error) { log({ at: 'placement.refused', instance: row.instance, slug: row.slug, error: String(error) }); }
149
+ }
150
+ return ready.length === 0 ? [] : world.openCells(ready);
151
+ } });
152
+ void placements?.look();
153
+ process.once('SIGTERM', () => { watch.dispose(); placements?.dispose(); stop(0); });
@@ -0,0 +1,56 @@
1
+ // SA33 (meta SHARD-AUTHORING, J314): a new slug's cell reaches a running server with no engine release. The API places a new slug (SA30) and
2
+ // writes this file, signed with its own placement key; the release key stays engine CI's, because it vouches for the server bundle the box
3
+ // runs. A placement can only add a cell on an empty spot, for a shard whose server pack this build's book already holds: it never moves the
4
+ // build, the bundle or the save epoch, and a new serial here starts no grace, so players in every other cell stay connected.
5
+ import { Scope } from '@wildshard/engine/app/scope';
6
+ import { fetchSignedText, readSigned } from './releaseFile';
7
+ import { PlacementSchema, type PlacementFile } from '@wildshard/engine/game/grid/placementRows';
8
+ import type { PlacedCell } from './gridCells';
9
+
10
+ /** How often the server looks, in ms: the release file's minute, so a placement is open inside SA33's two minutes. */
11
+ const POLL_MS = 60_000;
12
+ const WHAT = 'placement file';
13
+ /** The file's text as what it says, under the placement key (SPKI DER in hex). */
14
+ export function readPlacementFile(text: string, publicKey: string): PlacementFile { return readSigned(text, publicKey, PlacementSchema, WHAT); }
15
+ /** The placement file at `url`, an `https:` bucket or a `file:` path. */
16
+ export async function fetchPlacementFile(url: string, publicKey: string): Promise<PlacementFile> { return readPlacementFile(await fetchSignedText(url, WHAT), publicKey); }
17
+
18
+ /** How a placement watch is built. */
19
+ export interface PlacementWatchOptions {
20
+ readonly read: () => Promise<PlacementFile>;
21
+ /** The channel this server plays. */
22
+ readonly channel: string;
23
+ /** Open these cells, the ones this server hasn't opened yet; answer the instances that opened. A cell left out is asked for again next look. */
24
+ readonly open: (cells: readonly PlacedCell[]) => Promise<readonly string[]>;
25
+ /** A look that failed. The server plays on with the cells it has. */
26
+ readonly failed: (error: unknown) => void;
27
+ readonly everyMs?: number;
28
+ }
29
+ /** SA33: a running server's cells grow when the placement file names one it hasn't opened. It never closes one: delete is SA31's, at a restart. */
30
+ export class PlacementWatch {
31
+ private readonly options: PlacementWatchOptions;
32
+ private readonly scope = new Scope('dedicated.placement');
33
+ private readonly opened = new Set<string>();
34
+ private looking = false;
35
+ private seen = -1;
36
+ constructor(options: PlacementWatchOptions) {
37
+ this.options = options;
38
+ this.scope.interval(options.everyMs ?? POLL_MS, () => { void this.look(); });
39
+ }
40
+ /** The newest serial this server has believed, or -1. */
41
+ get serial(): number { return this.seen; }
42
+ /** One look. An older file than one already believed changes nothing. */
43
+ async look(): Promise<void> {
44
+ if (this.looking) return;
45
+ this.looking = true;
46
+ try {
47
+ const file = await this.options.read();
48
+ if (file.channel !== this.options.channel) throw new Error(`A ${file.channel} placement file on a ${this.options.channel} server`);
49
+ if (file.serial < this.seen) throw new Error(`Placement serial ${String(file.serial)} is older than ${String(this.seen)}`);
50
+ this.seen = file.serial;
51
+ const fresh = file.cells.filter(cell => !this.opened.has(cell.instance));
52
+ if (fresh.length > 0) for (const instance of await this.options.open(fresh)) this.opened.add(instance);
53
+ } catch (error) { this.options.failed(error); } finally { this.looking = false; }
54
+ }
55
+ dispose(): void { this.scope.dispose(); }
56
+ }
@@ -10,19 +10,26 @@ import { ReleaseSchema, SignedSchema, type ReleaseFile } from '../../../shared/h
10
10
 
11
11
  /** How often the server looks, in ms: as the cook worker does, outbound, so the VPS opens no port (J175, Q91). */
12
12
  const POLL_MS = 60_000;
13
- /** The file's text as what it says. It throws on a bad signature, before a byte of the body is believed. `publicKey` is SPKI DER in hex, and the signature is hex. */
14
- export function readReleaseFile(text: string, publicKey: string): ReleaseFile {
13
+ /** A look that hangs would stop every later look: one minute's poll is the most it may take. */
14
+ const FETCH_MS = 30_000;
15
+ /** A signed file's text as what it says. It throws on a bad signature, before a byte of the body is believed. `publicKey` is SPKI DER in hex, and the signature is hex.
16
+ * The release file and SA33's placement file share it, each under its own key. */
17
+ export function readSigned<T>(text: string, publicKey: string, schema: v.GenericSchema<T>, what: string): T {
15
18
  const signed = v.parse(SignedSchema, JSON.parse(text)), key = createPublicKey({ key: Buffer.from(publicKey, 'hex'), format: 'der', type: 'spki' });
16
- if (!verify(null, Buffer.from(signed.body), key, Buffer.from(signed.signature, 'hex'))) throw new Error('A release file has a bad signature');
17
- return v.parse(ReleaseSchema, JSON.parse(signed.body));
19
+ if (!verify(null, Buffer.from(signed.body), key, Buffer.from(signed.signature, 'hex'))) throw new Error(`A ${what} has a bad signature`);
20
+ return v.parse(schema, JSON.parse(signed.body));
18
21
  }
19
- /** The release file at `url`, an `https:` bucket or a `file:` path. */
20
- export async function fetchReleaseFile(url: string, publicKey: string): Promise<ReleaseFile> {
21
- if (url.startsWith('file:')) return readReleaseFile(await readFile(new URL(url), 'utf8'), publicKey);
22
- const response = await fetch(url, { cache: 'no-store' });
23
- if (!response.ok) throw new Error(`No release file at ${url}: ${String(response.status)}`);
24
- return readReleaseFile(await response.text(), publicKey);
22
+ /** A signed file's text at `url`, an `https:` bucket or a `file:` path. */
23
+ export async function fetchSignedText(url: string, what: string): Promise<string> {
24
+ if (url.startsWith('file:')) return readFile(new URL(url), 'utf8');
25
+ const response = await fetch(url, { cache: 'no-store', signal: AbortSignal.timeout(FETCH_MS) });
26
+ if (!response.ok) throw new Error(`No ${what} at ${url}: ${String(response.status)}`);
27
+ return response.text();
25
28
  }
29
+ /** The release file's text as what it says. */
30
+ export function readReleaseFile(text: string, publicKey: string): ReleaseFile { return readSigned(text, publicKey, ReleaseSchema, 'release file'); }
31
+ /** The release file at `url`, an `https:` bucket or a `file:` path. */
32
+ export async function fetchReleaseFile(url: string, publicKey: string): Promise<ReleaseFile> { return readReleaseFile(await fetchSignedText(url, 'release file'), publicKey); }
26
33
 
27
34
  /** Boot from the release whose bundle passed the pull. Remote metadata alone cannot change its epoch.
28
35
  * A direct local boot without a kept file may use the signed file for its build and configured channel. */
@@ -7,13 +7,16 @@ import { SimNetWorld } from '@wildshard/engine/net/simWorld';
7
7
  import type { Transport } from '@wildshard/engine/net/transport';
8
8
  import type { SimHost } from '@wildshard/engine/sim';
9
9
  import type { PlayerSim } from '@wildshard/engine/sim/playerSim';
10
- import type { GridAssembly } from '@wildshard/engine/game/grid/assembly';
10
+ import { carryMotion } from '@wildshard/engine/game/grid/simulation';
11
+ import type { GridAssembly, GridCell } from '@wildshard/engine/game/grid/assembly';
12
+ import type { GridCollisionStrip } from '@wildshard/engine/game/grid/gridCollision';
11
13
  import { mountedPlayerOf } from '@wildshard/engine/game/riding/native';
12
14
  import { commandsOf } from '@wildshard/engine/game/grid/roomNet';
13
15
  import { LEAD_SEAT } from '../standalone/cellWorld';
14
16
  import { HOLD_MS, type ResumeAt, type RoomNews, type SeatEntry } from './cellProtocol';
15
17
  import { crossedTo, finite, type CrossArrival, type CrossTarget } from './crossing';
16
18
  import { FallFloor } from '../standalone/fallFloor';
19
+ import { placeOnRoad } from '../standalone/roadWorld';
17
20
  import { LEFT } from './socketPump';
18
21
 
19
22
  /** How often a seat whose crossing is asked for asks again, and how often holds are looked at, in ticks. */
@@ -51,8 +54,10 @@ export class RoadRoom implements CrossTarget {
51
54
  readonly host: SimHost;
52
55
  private readonly options: RoadRoomOptions;
53
56
  private readonly seats = new Map<string, RoadSeat>();
57
+ /** The grid the trigger reads: the options' until a placement grows it (SA34a). */
58
+ private assembly: GridAssembly;
54
59
  constructor(options: RoadRoomOptions) {
55
- this.options = options; this.host = options.host;
60
+ this.options = options; this.host = options.host; this.assembly = options.assembly;
56
61
  // The road's level has a lead seat of its own, which nobody takes: every crossing seat is a body of its own.
57
62
  const lead = this.host.players.get(LEAD_SEAT);
58
63
  if (lead !== undefined) { lead.motor.setEnabled(false); this.host.parked.add(lead.id); }
@@ -70,11 +75,12 @@ export class RoadRoom implements CrossTarget {
70
75
  bodyId(device: string): string | undefined { return this.seats.get(device)?.body; }
71
76
  bodyOf(device: string): PlayerSim | undefined { const seat = this.seats.get(device); return seat === undefined ? undefined : this.host.players.get(seat.body); }
72
77
 
73
- admit(entry: SeatEntry, transport: Transport, at: ResumeAt): CrossArrival | string {
78
+ admit(entry: SeatEntry, transport: Transport, at: ResumeAt, motion?: PlayerSim): CrossArrival | string {
74
79
  if (this.seats.has(entry.device)) return 'held';
75
80
  const player = this.host.addPlayer(entry.body, at, at.yaw);
76
81
  player.netName = entry.name;
77
82
  player.resetPose(at, at.yaw);
83
+ if (motion !== undefined) carryMotion(motion, player);
78
84
  const seat: RoadSeat = { device: entry.device, name: entry.name, body: entry.body, transport, client: null, closeOff: null, holdEnds: null, asked: null, askedAt: 0, fall: new FallFloor(ROAD_FLOOR, true, at) };
79
85
  this.seats.set(entry.device, seat);
80
86
  return { body: seat.body, land: client => {
@@ -98,7 +104,8 @@ export class RoadRoom implements CrossTarget {
98
104
  handOver(device: string, target: CrossTarget, entry: SeatEntry, at: ResumeAt): boolean {
99
105
  const seat = this.seats.get(device), transport = seat?.transport ?? null;
100
106
  if (seat === undefined || transport === null || seat.client === null || !this.net.live(seat.client) || target.holds(device)) return false;
101
- const arrived = target.admit(entry, transport, at);
107
+ // GC34: the walker's own motion goes with them; a rider's lives on the mount it leaves here, so it arrives on foot from rest
108
+ const arrived = target.admit(entry, transport, at, mountedPlayerOf(this.host, seat.body)?.mounted === true ? undefined : this.host.players.get(seat.body));
102
109
  if (typeof arrived === 'string') return false;
103
110
  mountedPlayerOf(this.host, seat.body)?.dismount();
104
111
  seat.closeOff?.(); seat.closeOff = null; seat.transport = null;
@@ -107,6 +114,15 @@ export class RoadRoom implements CrossTarget {
107
114
  this.release(seat);
108
115
  return arrived.land(client);
109
116
  }
117
+ /**
118
+ * SA34a: cells placed on the running world (SA33). The trigger reads the grown grid, so feet inside a placed cell this worker hosts ask
119
+ * to cross into it; the void floor is laid again without their squares, their strips go in, and `walled` (placed cells on other workers)
120
+ * get the walls every other worker's cell has.
121
+ */
122
+ place(assembly: GridAssembly, strips: readonly GridCollisionStrip[], walled: readonly Pick<GridCell, 'origin'>[]): void {
123
+ this.assembly = assembly;
124
+ placeOnRoad(this.host, assembly.cells, strips, walled);
125
+ }
110
126
  private bind(seat: RoadSeat, transport: Transport, client: number): void {
111
127
  seat.closeOff?.();
112
128
  seat.transport = transport; seat.client = client;
@@ -137,7 +153,7 @@ export class RoadRoom implements CrossTarget {
137
153
  for (const seat of this.seats.values()) {
138
154
  const player = this.host.players.get(seat.body);
139
155
  if (seat.transport === null || player === undefined || !finite(player.position)) continue;
140
- const crossed = crossedTo(this.options.assembly, null, player.position);
156
+ const crossed = crossedTo(this.assembly, null, player.position);
141
157
  const to = crossed?.cell?.instance ?? null;
142
158
  if (crossed === undefined || to === null || !this.options.hosts(to)) { seat.asked = null; continue; }
143
159
  if (seat.asked === to && this.host.state.tick - seat.askedAt < ASK_TICKS) continue;
@@ -1,7 +1,7 @@
1
1
  import { Scope } from '@wildshard/engine/app/scope';
2
2
  import { diagnosticNow } from '@wildshard/engine/core/clock';
3
3
  import { CLIENT_FLOOD_DEBT, CLIENT_MESSAGES_PER_TICK, MAX_CLIENT_MESSAGES, MAX_CLIENT_MESSAGE_BYTES } from '@wildshard/engine/net/room';
4
- import { channelPrefix, closeCode, closeReason, controlPrefix, decodePing, encodePong, FRAME_SKIP_BYTES, framed, PING_FLOOR_MS, SILENCE_MS, SOCKET_PING, SOCKET_PLAYTEST, SOCKET_READY, SOCKET_RELIABLE, SOCKET_UNRELIABLE, SOCKET_VOICE, STALL_CLOSE_BYTES, type SocketControl } from '@wildshard/engine/net/socketFrames';
4
+ import { channelPrefix, closeCode, closeReason, controlPrefix, decodePing, encodePong, FRAME_SKIP_BYTES, framed, PING_FLOOR_MS, SILENCE_MS, SOCKET_DEVICE, SOCKET_PING, SOCKET_PLAYTEST, SOCKET_READY, SOCKET_RELIABLE, SOCKET_UNRELIABLE, SOCKET_VOICE, STALL_CLOSE_BYTES, type SocketControl } from '@wildshard/engine/net/socketFrames';
5
5
  import type { NetChannel, Transport, TransportStats } from '@wildshard/engine/net/transport';
6
6
  import type { RawData, ServerOptions, WebSocket } from 'ws';
7
7
 
@@ -105,6 +105,7 @@ export class SocketTransport implements Transport {
105
105
  else if (prefix === SOCKET_READY) for (const listener of this.controls) listener('ready', body);
106
106
  else if (prefix === SOCKET_PLAYTEST) for (const listener of this.controls) listener('playtest', body);
107
107
  else if (prefix === SOCKET_VOICE) for (const listener of this.controls) listener('voice', body);
108
+ else if (prefix === SOCKET_DEVICE) for (const listener of this.controls) listener('device', body);
108
109
  else this.close('refused');
109
110
  }
110
111
  private ping(bytes: Buffer): void {
@@ -15,6 +15,16 @@ export function worldSettings(channel: string, env: Readonly<Record<string, stri
15
15
  return { workers: Number(env['WORLD_WORKERS'] ?? start.workers), seats: Number(env['WORLD_SEATS'] ?? start.seats) };
16
16
  }
17
17
 
18
+ /**
19
+ * GC35 (J322, Jake 11-13: "World crossing should be on by default. There should never be any walls"): each worker hosts the road between
20
+ * its cells unless `WORLD_CROSSING=off` (a bench's lone cells). Unset, or blank, is `worker`.
21
+ */
22
+ export function worldCrossing(value: string | undefined): boolean {
23
+ if (value === undefined || value === '' || value === 'worker') return true;
24
+ if (value === 'off') return false;
25
+ throw new Error(`WORLD_CROSSING=${value}: only worker (the default) or off`);
26
+ }
27
+
18
28
  /**
19
29
  * The table for the cells this server opens: one row a worker, at most `workers` rows. Only an open cell takes a row, so one cell is one
20
30
  * worker. Named rows go first; the rest are shared, and if the count runs out the last row takes whatever is left.
@@ -25,5 +35,7 @@ export function workerTable(cells: readonly string[], workers: number): readonly
25
35
  const room = Math.max(1, workers - rows.length), share = Array.from({ length: room }, (): string[] => []);
26
36
  rest.forEach((slug, index) => { share[index % room]?.push(slug); });
27
37
  const table = [...rows, ...share.filter(row => row.length > 0)], kept = table.slice(0, Math.max(1, workers - 1)), over = table.slice(kept.length).flat();
28
- return table.length <= workers ? table : [...kept, over];
38
+ if (table.length <= workers) return table;
39
+ // GC31: one worker is one row, so a crossing reaches every cell (`kept` keeps a first row whenever it can).
40
+ return workers <= 1 ? [table.flat()] : [...kept, over];
29
41
  }