castle-web-cli 0.4.237 → 0.4.238

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 (216) hide show
  1. package/dist/bundle.d.ts +24 -0
  2. package/dist/bundle.js +447 -4
  3. package/dist/bundleLatin1.d.ts +6 -0
  4. package/dist/bundleLatin1.js +333 -0
  5. package/dist/castle-host/host.d.ts +10 -1
  6. package/dist/castle-host/host.js +78 -9
  7. package/dist/castleJson.d.ts +2 -0
  8. package/dist/castleJson.js +1 -0
  9. package/dist/deckExports.d.ts +35 -0
  10. package/dist/deckExports.js +365 -0
  11. package/dist/importCheckHook.d.ts +1 -0
  12. package/dist/importCheckHook.js +1 -1
  13. package/dist/index.js +5 -0
  14. package/dist/init.js +2 -1
  15. package/dist/save-deck.js +4 -0
  16. package/kits/base/castle.json +1 -1
  17. package/kits/base/sdk/README.md +47 -0
  18. package/kits/base/sdk/castle.d.ts +3 -1
  19. package/kits/base/sdk/castle.js +1 -0
  20. package/kits/base/sdk/commands.d.ts +25 -1
  21. package/kits/base/sdk/commands.js +29 -1
  22. package/kits/base/sdk/hub.d.ts +17 -0
  23. package/kits/base/sdk/hub.js +33 -9
  24. package/kits/base/sdk/localCache.d.ts +27 -0
  25. package/kits/base/sdk/localCache.js +115 -0
  26. package/kits/base/sdk/localCacheStore.d.ts +15 -0
  27. package/kits/base/sdk/localCacheStore.js +358 -0
  28. package/kits/base/sdk/transport.d.ts +1 -0
  29. package/kits/base/sdk/transport.js +4 -5
  30. package/kits/hub-game/CLAUDE.md +22 -2
  31. package/kits/hub-game/castle.json +4 -1
  32. package/kits/hub-game/code/client/act.js +66 -91
  33. package/kits/hub-game/code/client/actCore.js +134 -0
  34. package/kits/hub-game/code/client/car.js +35 -0
  35. package/kits/hub-game/code/client/chrome.js +207 -381
  36. package/kits/hub-game/code/client/crowdNames.js +2 -2
  37. package/kits/hub-game/code/client/emoteWheel.js +109 -0
  38. package/kits/hub-game/code/client/hats.js +2 -0
  39. package/kits/hub-game/code/client/hookLayer.js +99 -48
  40. package/kits/hub-game/code/client/hostGo.js +77 -0
  41. package/kits/hub-game/code/client/hubControls.js +125 -0
  42. package/kits/hub-game/code/client/hubEntry.js +187 -0
  43. package/kits/hub-game/code/client/hudSurface.js +148 -0
  44. package/kits/hub-game/code/client/hudTree.js +96 -0
  45. package/kits/hub-game/code/client/idle.js +59 -13
  46. package/kits/hub-game/code/client/invites.js +13 -4
  47. package/kits/hub-game/code/client/menuIcons.js +8 -0
  48. package/kits/hub-game/code/client/noTrips.js +38 -0
  49. package/kits/hub-game/code/client/qualityEntry.js +6 -1
  50. package/kits/hub-game/code/client/rehello.js +3 -1
  51. package/kits/hub-game/code/client/riders.js +26 -0
  52. package/kits/hub-game/code/client/role.js +79 -0
  53. package/kits/hub-game/code/client/safeLayout.js +32 -3
  54. package/kits/hub-game/code/client/sound.js +10 -3
  55. package/kits/hub-game/code/client/soundscape.js +2 -2
  56. package/kits/hub-game/code/client/soundscapeAmbience.js +38 -8
  57. package/kits/hub-game/code/client/soundscapeBaked.js +24 -5
  58. package/kits/hub-game/code/client/soundscapeCues.js +2 -1
  59. package/kits/hub-game/code/client/state.js +19 -0
  60. package/kits/hub-game/code/client/stuck.js +2 -1
  61. package/kits/hub-game/code/client/talkSurface.js +178 -0
  62. package/kits/hub-game/code/client/talkTree.js +238 -0
  63. package/kits/hub-game/code/client/tiers.js +8 -5
  64. package/kits/hub-game/code/client/uiDom.js +600 -0
  65. package/kits/hub-game/code/client/uiTree.js +359 -0
  66. package/kits/hub-game/code/client/vehicle.js +154 -0
  67. package/kits/hub-game/code/client/wear.js +27 -5
  68. package/kits/hub-game/code/client/worldLabels.js +3 -2
  69. package/kits/hub-game/code/client/yours.js +10 -3
  70. package/kits/hub-game/code/server/actors.js +4 -3
  71. package/kits/hub-game/code/server/analytics.js +56 -6
  72. package/kits/hub-game/code/server/decor.js +56 -16
  73. package/kits/hub-game/code/server/hub.js +258 -46
  74. package/kits/hub-game/code/server/idle.js +118 -5
  75. package/kits/hub-game/code/server/manifest.js +46 -4
  76. package/kits/hub-game/code/server/npcs.js +4 -2
  77. package/kits/hub-game/code/server/players.js +3 -0
  78. package/kits/hub-game/code/server/role.js +142 -0
  79. package/kits/hub-game/code/server/standing.js +6 -4
  80. package/kits/hub-game/code/server/vehicle.js +126 -0
  81. package/kits/hub-game/code/shared/car.js +52 -0
  82. package/kits/hub-game/code/shared/deckFlags.js +34 -0
  83. package/kits/hub-game/code/shared/deviceClass.js +39 -0
  84. package/kits/hub-game/code/shared/expression.js +9 -0
  85. package/kits/hub-game/code/systems/hub.js +272 -84
  86. package/kits/hub-game/docs/analytics.md +11 -2
  87. package/kits/hub-game/docs/contract.md +352 -14
  88. package/kits/hub-game/docs/vehicle-preset.md +132 -0
  89. package/kits/hub-game/models/hats/baker-cap.pxmodel +89 -0
  90. package/kits/hub-game/models/hats/chef-toque.pxmodel +60 -0
  91. package/kits/hub-game/models/hats/delivery-cap.pxmodel +105 -0
  92. package/kits/hub-game/models/hats/fire-helmet.pxmodel +87 -0
  93. package/kits/hub-game/models/hats/hard-hat.pxmodel +71 -0
  94. package/kits/hub-game/models/hats/nurse-cap.pxmodel +61 -0
  95. package/kits/hub-game/models/hats/police-cap.pxmodel +105 -0
  96. package/kits/hub-game/models/hats/teacher-beret.pxmodel +52 -0
  97. package/kits/hub-game/models/role/square/top-apron.pxmodel +109 -0
  98. package/kits/hub-game/models/role/square/top-cardigan.pxmodel +141 -0
  99. package/kits/hub-game/models/role/square/top-coat.pxmodel +157 -0
  100. package/kits/hub-game/models/role/square/top-scrubs.pxmodel +93 -0
  101. package/kits/hub-game/models/role/square/top-tabard.pxmodel +109 -0
  102. package/kits/hub-game/models/role/square/top-vest.pxmodel +109 -0
  103. package/kits/hub-game/models/role/tool-bag.pxmodel +75 -0
  104. package/kits/hub-game/models/role/tool-bell.pxmodel +71 -0
  105. package/kits/hub-game/models/role/tool-hose.pxmodel +60 -0
  106. package/kits/hub-game/models/role/tool-parcel.pxmodel +61 -0
  107. package/kits/hub-game/models/role/tool-torch.pxmodel +55 -0
  108. package/kits/hub-game/models/role/tool-tray.pxmodel +75 -0
  109. package/kits/hub-game/models/role/top-apron.pxmodel +70 -0
  110. package/kits/hub-game/models/role/top-cardigan.pxmodel +102 -0
  111. package/kits/hub-game/models/role/top-coat.pxmodel +79 -0
  112. package/kits/hub-game/models/role/top-scrubs.pxmodel +54 -0
  113. package/kits/hub-game/models/role/top-tabard.pxmodel +70 -0
  114. package/kits/hub-game/models/role/top-vest.pxmodel +70 -0
  115. package/kits/hub-game/package-lock.json +1 -1
  116. package/kits/hub-game/package.json +1 -1
  117. package/kits/hub-game/scripts/check.mjs +7 -4
  118. package/kits/hub-game/scripts/fixtures/car-vectors.json +279 -0
  119. package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +2 -1
  120. package/kits/hub-game/scripts/fixtures/hud-surface.json +670 -0
  121. package/kits/hub-game/scripts/fixtures/talk-surface.json +3930 -0
  122. package/kits/hub-game/scripts/gen-hats.mjs +46 -2
  123. package/kits/hub-game/scripts/gen-role.mjs +80 -0
  124. package/kits/hub-game/scripts/test-act-core.mjs +167 -0
  125. package/kits/hub-game/scripts/test-actions-client.mjs +34 -0
  126. package/kits/hub-game/scripts/test-actors.mjs +48 -0
  127. package/kits/hub-game/scripts/test-analytics.mjs +99 -5
  128. package/kits/hub-game/scripts/test-apply-deck.mjs +122 -0
  129. package/kits/hub-game/scripts/test-back-visibility.mjs +3 -1
  130. package/kits/hub-game/scripts/test-ballot.mjs +2 -0
  131. package/kits/hub-game/scripts/test-car.mjs +43 -0
  132. package/kits/hub-game/scripts/test-decor-client.mjs +2 -1
  133. package/kits/hub-game/scripts/test-decor.mjs +77 -0
  134. package/kits/hub-game/scripts/test-device-class.mjs +83 -0
  135. package/kits/hub-game/scripts/test-emote-wheel.mjs +374 -0
  136. package/kits/hub-game/scripts/test-hats.mjs +5 -4
  137. package/kits/hub-game/scripts/test-host-go.mjs +265 -0
  138. package/kits/hub-game/scripts/test-hub-controls.mjs +108 -0
  139. package/kits/hub-game/scripts/test-hub-entry.mjs +531 -0
  140. package/kits/hub-game/scripts/test-hub-ops.mjs +75 -0
  141. package/kits/hub-game/scripts/test-hud-clear.mjs +12 -2
  142. package/kits/hub-game/scripts/test-hud-rate.mjs +6 -2
  143. package/kits/hub-game/scripts/test-hud-surface.mjs +272 -0
  144. package/kits/hub-game/scripts/test-idle.mjs +347 -1
  145. package/kits/hub-game/scripts/test-interest-cells.mjs +8 -1
  146. package/kits/hub-game/scripts/test-invites-client.mjs +42 -1
  147. package/kits/hub-game/scripts/test-manifest.mjs +30 -0
  148. package/kits/hub-game/scripts/test-no-trips.mjs +42 -0
  149. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  150. package/kits/hub-game/scripts/test-quality.mjs +13 -0
  151. package/kits/hub-game/scripts/test-rehello.mjs +258 -3
  152. package/kits/hub-game/scripts/test-resume-pose-server.mjs +203 -0
  153. package/kits/hub-game/scripts/test-resync.mjs +183 -0
  154. package/kits/hub-game/scripts/test-role-client.mjs +421 -0
  155. package/kits/hub-game/scripts/test-role.mjs +350 -0
  156. package/kits/hub-game/scripts/test-safe-layout.mjs +50 -1
  157. package/kits/hub-game/scripts/test-soundscape.mjs +124 -7
  158. package/kits/hub-game/scripts/test-standing.mjs +15 -1
  159. package/kits/hub-game/scripts/test-talk-surface.mjs +296 -0
  160. package/kits/hub-game/scripts/test-tiers.mjs +13 -0
  161. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +96 -0
  162. package/kits/hub-game/scripts/test-ui-tree.mjs +711 -0
  163. package/kits/hub-game/scripts/test-vehicle-client.mjs +159 -0
  164. package/kits/hub-game/scripts/test-vehicle.mjs +135 -0
  165. package/kits/hub-game/scripts/test-yours.mjs +33 -0
  166. package/kits/hub-game/tools/hubScene/export.mjs +613 -0
  167. package/kits/hub-game/tools/hubScene/hubdata.mjs +921 -0
  168. package/kits/hub-game/tools/hubScene/merge-root.mjs +39 -0
  169. package/kits/hub-game/tools/hubScene/nodeworld.mjs +227 -0
  170. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +798 -0
  171. package/kits/hub-game/tools/hubScene/test/fixture.json +637 -0
  172. package/kits/hub-game/tools/hubScene/test/paint-export.mjs +40 -0
  173. package/kits/hub-game/tools/hubScene/test/upload.test.mjs +655 -0
  174. package/kits/hub-game/tools/hubScene/upload.mjs +636 -0
  175. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +291 -0
  176. package/kits/multiplayer-3d/castle.json +4 -4
  177. package/kits/multiplayer-3d/code/client/resumeGate.js +30 -2
  178. package/kits/multiplayer-3d/code/client/steer.js +3 -1
  179. package/kits/multiplayer-3d/code/systems/multiplayer.js +30 -2
  180. package/kits/multiplayer-3d/package-lock.json +1 -1
  181. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +74 -2
  182. package/kits/physics-3d/CLAUDE.md +1 -1
  183. package/kits/physics-3d/behaviors/Player.jsx +37 -27
  184. package/kits/physics-3d/castle.json +2 -2
  185. package/kits/physics-3d/docs/engine-geometry-memory.md +23 -0
  186. package/kits/physics-3d/engine3d/memoryprofile.js +17 -0
  187. package/kits/physics-3d/engine3d/playerRun.js +6 -1
  188. package/kits/physics-3d/engine3d/pxmodel.js +6 -1
  189. package/kits/physics-3d/engine3d/world3d.js +6 -3
  190. package/kits/physics-3d/package.json +1 -1
  191. package/kits/physics-3d/play/behaviors/Player.js +40 -28
  192. package/kits/physics-3d/scripts/test-memory-profile.mjs +237 -0
  193. package/kits/physics-3d/systems/physics3d.js +5 -2
  194. package/kits/real-time/castle.json +2 -2
  195. package/kits/real-time/code/client/messages.js +5 -0
  196. package/kits/real-time/code/server/session.js +28 -1
  197. package/kits/real-time/package-lock.json +1 -1
  198. package/package.json +5 -4
  199. package/vendor/three/LICENSE +21 -0
  200. package/vendor/three/build/three.core.js +58773 -0
  201. package/vendor/three/build/three.module.js +18251 -0
  202. package/vendor/three/examples/jsm/controls/OrbitControls.js +1860 -0
  203. package/vendor/three/examples/jsm/controls/TransformControls.js +1918 -0
  204. package/vendor/three/examples/jsm/exporters/GLTFExporter.js +3595 -0
  205. package/vendor/three/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
  206. package/vendor/three/examples/jsm/math/MeshSurfaceSampler.js +315 -0
  207. package/vendor/three/examples/jsm/postprocessing/EffectComposer.js +363 -0
  208. package/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
  209. package/vendor/three/examples/jsm/postprocessing/OutputPass.js +139 -0
  210. package/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
  211. package/vendor/three/examples/jsm/postprocessing/RenderPass.js +183 -0
  212. package/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
  213. package/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
  214. package/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
  215. package/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1435 -0
  216. package/vendor/three/package.json +134 -0
@@ -23,6 +23,7 @@ import * as Cabinets from './cabinets.js';
23
23
  import * as Grab from './grab.js';
24
24
  import * as Act from './act.js';
25
25
  import * as Idle from './idle.js';
26
+ import * as Vehicle from './vehicle.js';
26
27
  import * as Decor from './decor.js';
27
28
  import * as Actions from './actions.js';
28
29
  import * as Invites from './invites.js';
@@ -37,11 +38,12 @@ import * as Manifest from './manifest.js';
37
38
  import { setLabel, wireLabel } from './labels.js';
38
39
  import { makeNpcs } from './npcs.js';
39
40
  import * as Party from './party.js';
40
- import { bodySize, standingY } from './standing.js';
41
+ import { bodySize, boundingRadius, footprintHas as poseFootprintHas, solids, standingY } from './standing.js';
41
42
  import * as Place from './place.js';
42
43
  import * as Say from './say.js';
43
44
  import * as Ballot from './ballot.js';
44
45
  import * as Wear from './wear.js';
46
+ import * as Role from './role.js';
45
47
  import * as Earned from './earned.js';
46
48
  import * as Analytics from './analytics.js';
47
49
  import * as DoorAnalytics from './doorAnalytics.js';
@@ -75,6 +77,8 @@ const PAD_REFRESH_MS = 20000;
75
77
  // step off its pad (`hub.pad` says who stands there); a deck that never
76
78
  // reports the pad gets this long instead.
77
79
  const SHUT_HOLD_MS = 60000;
80
+ // What a pad says to a player whose app has no door trips (v1.156).
81
+ const NO_TRIPS_LABEL = 'Update Castle to play';
78
82
  // How often a place re-reads its doors' boards.
79
83
  const BOARD_EVERY_MS = 60000;
80
84
  // A weekly Cup clock is refreshed with its board once a minute. Two missed
@@ -366,6 +370,10 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
366
370
  hello(h, player, data);
367
371
  return;
368
372
  }
373
+ if (data?.k === 'hub-no-trips') {
374
+ noTrips(h, session, player);
375
+ return;
376
+ }
369
377
  // A reset check is in flight. Old client actions must not recreate the
370
378
  // player's deleted progress before the deck has reloaded it.
371
379
  if (h.players.get(player?.playerId)?.progressReading) { return; }
@@ -441,10 +449,15 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
441
449
  Grab.message(h, player?.playerId, data);
442
450
  return;
443
451
  }
452
+ if (data?.k === 'hub-horn' && h.cars) {Vehicle.horn(h, player?.playerId); return;}
444
453
  if (data?.k === 'hub-emote') {
445
454
  Idle.emoteMessage(h, player?.playerId, data);
446
455
  return;
447
456
  }
457
+ if (h.place.idle?.expression && data?.k === 'hub-sit-here') {
458
+ Idle.sitHereMessage(h, placeAt, player?.playerId);
459
+ return;
460
+ }
448
461
  if (data?.k === 'hub-sit') {
449
462
  Idle.sitMessage(h, placeAt, player?.playerId, data);
450
463
  return;
@@ -466,6 +479,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
466
479
  const dt = h.lastPlaceAt === null ? 0 : Math.min(0.25, (sim.timeMs - h.lastPlaceAt) / 1000);
467
480
  h.lastPlaceAt = sim.timeMs;
468
481
  reconcile(h);
482
+ if (Role.used(h)) { Role.prune(h); }
469
483
  Friends.tick(h, friendUserIdOf);
470
484
  // v1.28: a try-on on a player who went before saying hello goes too.
471
485
  if (Wear.tryOnUsed(h)) {
@@ -479,6 +493,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
479
493
  readResults(h);
480
494
  arrivals(h);
481
495
  if (h.place.visibility === true) {notifyVisibility(h);}
496
+ Vehicle.tick(h, (id, at, face) => placeAt(h, id, at, face));
482
497
  enforceHolds(h);
483
498
  enforceSettle(h);
484
499
  Idle.tick(h);
@@ -526,6 +541,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
526
541
  Ballot.send(h, ballotDeps(h));
527
542
  }
528
543
  Actors.applyTunes(h, h.engine?.maxSpeed?.() ?? 12);
544
+ Vehicle.tick(h, (id, at, face) => placeAt(h, id, at, face));
529
545
  sendLabelOverrides(h);
530
546
  Vis.send(h);
531
547
  sendAvatarOverrides(h);
@@ -542,6 +558,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
542
558
  if (Wear.tryOnUsed(h)) {
543
559
  Wear.sendTryOverrides(h, blockedPairs(h));
544
560
  }
561
+ if (Role.used(h)) { Role.sendOverrides(h, blockedPairs(h)); }
545
562
  // Cabinet cards (v1.7): nothing in a place with no classic door.
546
563
  Cabinets.send(h, (playerId) => namesOf(h, blockedPairs(h)?.get(playerId) ?? []));
547
564
  notifyResumes(h, false, resumeDeferred);
@@ -591,6 +608,21 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
591
608
  },
592
609
  } : {}),
593
610
 
611
+ // A client back from an away whose frames the host dropped asks for the
612
+ // world again (the real-time kit's `resync`), always granted: the client
613
+ // holds its cover until that WORLD comes. An arrived player's Act prompts
614
+ // go again too, as a dropped frame may have carried them; sync sends only
615
+ // changes, so they would never come back.
616
+ resync(session, player) {
617
+ const id = player?.playerId, entry = h.players.get(id);
618
+ if (h.manifest.act === true && entry?.arrived && !entry.ended && !h.actDeparting?.has(id) && !h.resumeDeparting?.has(id) &&
619
+ session?.players.some((p) => p.playerId === id)) {
620
+ Act.replay(h, id);
621
+ }
622
+ return true;
623
+ },
624
+
625
+ allowPlayerPose: (id) => !Vehicle.riding(h, id),
594
626
  shutdown: () => shutdown(h),
595
627
 
596
628
  join() {
@@ -618,10 +650,12 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
618
650
  spawnTemplates: Actors.templatesOf(h),
619
651
  // v1.6, only in a place that turns idle play on.
620
652
  ...Idle.fields(h),
653
+ ...Vehicle.fields(h),
621
654
  // v1.27, only once the place keeps an object for a player.
622
655
  ...(h.keptFor.size > 0 ? { hubKept: Grab.keptOf(h) } : {}),
623
656
  // v1.28, only while the place shows a try-on on someone.
624
657
  ...(h.trying.size > 0 ? tryingForJoin(h) : {}),
658
+ ...(h.roles.size > 0 ? rolesForJoin(h) : {}),
625
659
  // v1.33, only a town of a deck with `hub.stuck`.
626
660
  ...(stuckHere(h) ? { hubStuck: { to: arrivalName(h), ...(hasUnstick(h) ? { hook: true } : {}) } } : {}),
627
661
  };
@@ -655,6 +689,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
655
689
  for (const [field, value] of Object.entries(Idle.fields(h))) {
656
690
  latch(h, field, value, out);
657
691
  }
692
+ if (h.cars?.size || h.sent.has('hubCars')) {latch(h, 'hubCars', Vehicle.fields(h).hubCars ?? {}, out);}
658
693
  // v1.27 `hub.keepFor`: nothing until something is kept, then each change.
659
694
  if (h.keptFor.size > 0 || h.sent.has('hubKept')) {
660
695
  latch(h, 'hubKept', Grab.keptOf(h), out);
@@ -663,6 +698,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
663
698
  if (h.trying.size > 0 || h.sent.has('hubTry')) {
664
699
  latchTrying(h, out);
665
700
  }
701
+ if (h.roles.size > 0 || h.sent.has('hubRole')) { latchRoles(h, out); }
666
702
  return Object.keys(out).length ? out : null;
667
703
  },
668
704
 
@@ -823,6 +859,10 @@ function newState(manifest, savedDeckId) {
823
859
  pads: new Map(),
824
860
  // playerId -> { door, at }: the door that last stayed shut for them
825
861
  shut: new Map(),
862
+ // v1.156: players whose app cannot go through a door (no `hub.go`), and
863
+ // the door whose pad tells such a player so: playerId -> { door, actor }
864
+ noTrips: new Set(),
865
+ noTripsLabel: new Map(),
826
866
  // door id -> who the deck last said stands on its pad (`hub.pad`)
827
867
  padDoors: new Map(),
828
868
  // door id -> its board from ghost, and when the boards were last read
@@ -867,6 +907,7 @@ function newState(manifest, savedDeckId) {
867
907
  ...Grab.newGrabState(),
868
908
  // what players wear on their avatars (`wear.js`, v1.4)
869
909
  ...Wear.newWearState(),
910
+ ...Role.newRoleState(),
870
911
  // earned items players show (`earned.js`, v1.53)
871
912
  ...Earned.newEarnedState(),
872
913
  // emotes, seats and sounds (`idle.js`, v1.6)
@@ -961,6 +1002,7 @@ function makeContext(h) {
961
1002
  station: (id, spec) => Observe.station(h, id, spec),
962
1003
  dwell: (playerId, id) => Observe.dwell(h, playerId, id),
963
1004
  hold(playerId, at, facingDeg) {
1005
+ if (Vehicle.riding(h, playerId)) {Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));}
964
1006
  const body = h.sim?.players.get(playerId);
965
1007
  if (!body) {
966
1008
  return;
@@ -972,6 +1014,8 @@ function makeContext(h) {
972
1014
  placeAt(h, playerId, point, facing);
973
1015
  },
974
1016
  release(playerId) {
1017
+ if (Vehicle.riding(h, playerId)) {Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));}
1018
+ if (h.held.get(playerId)?.ground) {Idle.stand(h, playerId);}
975
1019
  h.held.delete(playerId);
976
1020
  },
977
1021
  setHud(spec, playerId) {
@@ -1020,6 +1064,8 @@ function makeContext(h) {
1020
1064
  friendBests: (key, options) => friendBests(h, key, options, userIdOf),
1021
1065
  wear: (playerId, spec) => wear(h, playerId, spec),
1022
1066
  tryOn: (playerId, spec) => Wear.tryOn(h, playerId, spec),
1067
+ role: (playerId, spec) => Role.role(h, playerId, spec),
1068
+ roleOf: (playerId) => Role.roleOf(h, playerId),
1023
1069
  wearing: (playerId) => Wear.wearing(h, playerId),
1024
1070
  unlock: (playerId, itemId) => {
1025
1071
  const entry = h.players.get(playerId);
@@ -1034,6 +1080,9 @@ function makeContext(h) {
1034
1080
  unlocksOf: (userIds) => Earned.unlocksOf(platformHub(h), userIds, (err) => refused(h, 'unlocks', err), h),
1035
1081
  earned: (playerId) => Earned.earnedOf(h, playerId),
1036
1082
  tune: (playerId, spec) => Actors.tune(h, playerId, spec),
1083
+ drive: (id, car, at) => Vehicle.drive(h, id, car, at, (pid, point, face) => placeAt(h, pid, point, face)),
1084
+ ride: (id, driver, seat) => Vehicle.ride(h, id, driver, seat, (pid, point, face) => placeAt(h, pid, point, face)),
1085
+ vehicle: (id) => Vehicle.vehicle(h, id),
1037
1086
  spawn: (fromActorId, at) => Actors.spawn(h, fromActorId, at, h.engine),
1038
1087
  pose: (actorId) => Actors.pose(h, actorId),
1039
1088
  reset: (actorId, at) => Actors.reset(h, actorId, at, h.engine),
@@ -1041,12 +1090,16 @@ function makeContext(h) {
1041
1090
  // `to` limits the words to those players; for them they replace the
1042
1091
  // label everyone else sees until they expire or are cleared the same way.
1043
1092
  label: (actorId, text, options) => setLabel(h, isSceneActor(h, actorId) ? actorId : null, text, options, false),
1093
+ // v1.156: whether this player's app cannot go through doors (no `hub.go`);
1094
+ // a deck counting its own pads leaves them out, as `hub.pad` does.
1095
+ noTrips: (playerId) => h.noTrips.has(playerId),
1044
1096
  npc: (actorId) => h.npcs.handle(actorId),
1045
1097
  npcs: () => h.npcs.list(),
1046
1098
  preferNpc: (playerId, npcId) => h.npcs.prefer(playerId, npcId),
1047
1099
  result: (playerId, value) => report(h, playerId, value),
1048
1100
  drop: (playerId) => Grab.drop(h, playerId),
1049
1101
  emote: (playerId, id) => Idle.emote(h, playerId, id),
1102
+ ...(h.place.idle?.expression ? { emotesFor: (playerId, ids) => Idle.emotesFor(h, playerId, ids) } : {}),
1050
1103
  seat: (playerId) => Idle.seat(h, playerId),
1051
1104
  sound: (actorId, file, options) => Idle.sound(h, actorId, file, options),
1052
1105
  danceIdle: (actorId, options) => Idle.danceIdle(h, actorId, options),
@@ -1088,6 +1141,7 @@ function platformHub(h) {
1088
1141
  // the host has hub ops, the door is ghost's arrival and the result and avatar
1089
1142
  // are read from ghost (`readResults`). The hello's avatar and colour are
1090
1143
  // provisional until that read; colours also work with the manifest opt-in.
1144
+ // Optional `device` is the packed device class for arrival analytics only.
1091
1145
  function queuedResumeHello(h, playerId, known, data, synthetic, signUp, invitedAfresh) {
1092
1146
  if (!known?.arrived || signUp || invitedAfresh || h.resumeDeparting?.has(playerId) ||
1093
1147
  typeof h.hooks.resume !== 'function') {
@@ -1240,7 +1294,9 @@ function hello(h, player, data, synthetic = false) {
1240
1294
  // holds none of the cabinet cards it was sent (v1.7).
1241
1295
  if (data.again !== true) {
1242
1296
  replaySent(h, player.playerId, data.resume === true);
1297
+ Idle.joinedAfresh(h, player.playerId, data.resume === true);
1243
1298
  if (h.manifest.act === true) {Act.replay(h, player.playerId);}
1299
+ h.vehicleDeparting?.delete(player.playerId);
1244
1300
  h.npcs.replayPreferred(player.playerId, data.resume === true);
1245
1301
  Shot.joinedAfresh(h, player.playerId);
1246
1302
  Vis.joinedAfresh(h, player.playerId, userIdOf(h, player.playerId));
@@ -1264,6 +1320,7 @@ function hello(h, player, data, synthetic = false) {
1264
1320
  Friends.resend(h, player.playerId);
1265
1321
  // v1.28: nothing in a place that never sent a try-on to one player alone.
1266
1322
  Wear.joinedAfresh(h, player.playerId);
1323
+ if (Role.used(h) || h.roleAloneUsed) { Role.joinedAfresh(h, player.playerId); }
1267
1324
  // v1.53: likewise its earned items alone, only where someone has one.
1268
1325
  if (Earned.used(h)) {
1269
1326
  Earned.joinedAfresh(h, player.playerId);
@@ -1312,6 +1369,7 @@ function hello(h, player, data, synthetic = false) {
1312
1369
  read: progressState.readLifetime?.phase ?? (continuedProgress ? (known?.read === 'reading' ? 'want' : known?.read) : null) ?? (hub ? 'want' : 'done'),
1313
1370
  progressVersion: progressState.version,
1314
1371
  progressState,
1372
+ ...(known?.device !== undefined ? { device: known.device } : {}),
1315
1373
  ...(h.progressEnabled ? { progressReading: Boolean(progressState.locks.size || accountProgressBlocked(h, progressUser) || (!resumeBeforeProgressRead && progressUser && canReadProgress(h) && typeof h.session?.storage?.playthrough === 'function')) } : {}),
1316
1374
  ...(resumeBeforeProgressRead ? { progressRefreshPending: true } : {}),
1317
1375
  hello: true,
@@ -1339,6 +1397,7 @@ function hello(h, player, data, synthetic = false) {
1339
1397
  ...(last?.ended === true || known?.endAgain === true ? { endAgain: true } : {}),
1340
1398
  ...(resumes && known?.arrived && known.ended && data.resume === true ? { endReplayPending: true } : {}),
1341
1399
  };
1400
+ if (Number.isSafeInteger(data.device) && data.device > 0 && data.device < 2 ** 29) {entry.device = data.device;}
1342
1401
  if (signedUp) {
1343
1402
  signUp.avatarRev = entry.avatarRev;
1344
1403
  signUp.colorRev = entry.colorRev;
@@ -1482,6 +1541,7 @@ async function refreshProgress(h, playerId) {
1482
1541
  delete current.endAgain;
1483
1542
  delete current.endReplayPending;
1484
1543
  Wear.forget(h, id);
1544
+ Role.forget(h, id);
1485
1545
  Earned.forget(h, id);
1486
1546
  h.npcs.leave(id);
1487
1547
  h.hudMe.delete(id);
@@ -1671,6 +1731,7 @@ function reconcile(h) {
1671
1731
  }
1672
1732
  }
1673
1733
  }
1734
+ if (h.place.analytics === true) {Analytics.observe(h);}
1674
1735
  greetLate(h);
1675
1736
  }
1676
1737
 
@@ -1808,7 +1869,7 @@ function prepareResume(h, playerId, greet = true) {
1808
1869
  const present = body && h.session?.players.some((p) => p.playerId === playerId);
1809
1870
  const returning = present && (kept.awayAt !== undefined || body !== kept.body);
1810
1871
  if (!present) {
1811
- if (kept.awayAt === undefined && h.poseStore && !h.resumeDeparting.has(playerId)) {
1872
+ if (kept.awayAt === undefined && h.poseStore && !h.resumeDeparting.has(playerId) && !h.players.get(playerId)?.ended) {
1812
1873
  void h.poseStore.end(h.players.get(playerId)?.userId, kept, Date.now(), playerId);
1813
1874
  }
1814
1875
  kept.awayAt ??= Date.now();
@@ -1854,7 +1915,7 @@ function prepareResume(h, playerId, greet = true) {
1854
1915
  h.players.get(playerId)?.userId !== h.session.hub.owner) {
1855
1916
  placeGroup(h, [playerId]);
1856
1917
  } else {
1857
- moveBody(h, playerId, kept.at, kept.facing);
1918
+ restorePose(h, playerId, kept.at, kept.facing);
1858
1919
  }
1859
1920
  if (h.poseStore) { void h.poseStore.take(h.players.get(playerId)?.userId, playerId); }
1860
1921
  settle(h, playerId);
@@ -2108,6 +2169,7 @@ function restartRetainedAsFresh(h, player, entry, data, synthetic) {
2108
2169
  }
2109
2170
 
2110
2171
  function forget(h, playerId) {
2172
+ h.vehicleDeparting?.delete(playerId);
2111
2173
  h.padOccupancy?.selected.delete(playerId);
2112
2174
  const entry = h.players.get(playerId);
2113
2175
  // resumeKept may be the only remaining pose after the body disappears.
@@ -2131,6 +2193,7 @@ function forget(h, playerId) {
2131
2193
  console.warn(`[hub] leave hook failed: ${err?.message ?? err}`);
2132
2194
  }
2133
2195
  }
2196
+ Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
2134
2197
  DoorAnalytics.finish(h, playerId, 3);
2135
2198
  if (h.arrivalPoses) {
2136
2199
  h.arrivalPoses.leave(playerId, entry?.userId, entry?.arrived === true && !entry.ended && !poseDeparting);
@@ -2177,8 +2240,11 @@ function forget(h, playerId) {
2177
2240
  h.sentAvMe.delete(playerId);
2178
2241
  h.marks.delete(playerId);
2179
2242
  Wear.forget(h, playerId);
2243
+ Role.forget(h, playerId);
2180
2244
  Earned.forget(h, playerId);
2181
2245
  h.shut.delete(playerId);
2246
+ h.noTrips.delete(playerId);
2247
+ h.noTripsLabel.delete(playerId);
2182
2248
  h.jumpAt.delete(playerId);
2183
2249
  h.whereAt.delete(playerId);
2184
2250
  h.unstuckAt?.delete(playerId);
@@ -2223,7 +2289,7 @@ async function shutdown(h) {
2223
2289
  }
2224
2290
  for (const playerId of [...h.players.keys()]) {
2225
2291
  const kept = h.resumeKept?.get(playerId);
2226
- if (h.poseStore && kept && kept.awayAt === undefined && !h.resumeDeparting?.has(playerId)) {
2292
+ if (h.poseStore && kept && kept.awayAt === undefined && !h.resumeDeparting?.has(playerId) && !h.players.get(playerId)?.ended) {
2227
2293
  void h.poseStore.end(h.players.get(playerId)?.userId, kept, Date.now(), playerId);
2228
2294
  }
2229
2295
  forget(h, playerId);
@@ -2231,6 +2297,7 @@ async function shutdown(h) {
2231
2297
  if (Wear.tryOnUsed(h)) {
2232
2298
  Wear.endTries(h);
2233
2299
  }
2300
+ Role.end(h);
2234
2301
  let timer = null;
2235
2302
  await Promise.race([
2236
2303
  Promise.resolve()
@@ -2322,6 +2389,7 @@ function arrivals(h) {
2322
2389
  playerId,
2323
2390
  username: usernameOf(h, playerId),
2324
2391
  userId: entry.userId,
2392
+ device: entry.device ?? 0,
2325
2393
  ...(h.place.anonymousEntry === true ? { identityUserId: entry.identityUserId ?? null } : {}),
2326
2394
  ...(entry.signUp ? { signedUpFrom: entry.signUp.carry.playerId } : {}),
2327
2395
  from: entry.from,
@@ -2362,7 +2430,7 @@ function arrivals(h) {
2362
2430
  const pose = entry?.arrivalPose;
2363
2431
  if (entry) {delete entry.arrivalPose;}
2364
2432
  if (pose && pose.userId === arrivalPoseUserId(h, playerId) && !entry?.ended && !entry?.near && !h.resumeDeparting.has(playerId)) {
2365
- moveBody(h, playerId, pose.at, pose.facing);
2433
+ restorePose(h, playerId, pose.at, pose.facing);
2366
2434
  settle(h, playerId);
2367
2435
  }
2368
2436
  }
@@ -2374,7 +2442,7 @@ function arrivals(h) {
2374
2442
  if (houseResume(h) && h.session?.hub?.owner && entry?.userId !== h.session.hub.owner) {delete entry.coldPose;}
2375
2443
  if (entry?.coldPose && entry.invited && entry.near) {delete entry.coldPose;}
2376
2444
  if (entry?.coldPose) {
2377
- moveBody(h, playerId, entry.coldPose.at, entry.coldPose.facing);
2445
+ restorePose(h, playerId, entry.coldPose.at, entry.coldPose.facing);
2378
2446
  settle(h, playerId);
2379
2447
  delete entry.coldPose;
2380
2448
  }
@@ -2439,14 +2507,93 @@ function placeGroup(h, playerIds) {
2439
2507
  }
2440
2508
  // Facing f looks along (sin f, cos f); the row runs across it.
2441
2509
  const across = { x: Math.cos(facing), z: -Math.sin(facing) };
2510
+ const radius = bodySize(h)?.radius ?? BODY_RADIUS_M;
2511
+ const occupied = othersAt(h, playerIds);
2442
2512
  const n = playerIds.length;
2443
- playerIds.forEach((playerId, i) => {
2513
+ const slots = playerIds.map((_, i) => {
2444
2514
  const offset = (i - (n - 1) / 2) * arrival.spread;
2445
- const at = { x: t.x + across.x * offset, y: Math.max(t.y ?? 1, 1.2), z: t.z + across.z * offset };
2446
- placeAt(h, playerId, { ...at, y: standingY(h, at) }, facing);
2515
+ return { x: t.x + across.x * offset, y: Math.max(t.y ?? 1, 1.2), z: t.z + across.z * offset };
2516
+ });
2517
+ // Where earlier members of this batch were put, and which of them moved: a
2518
+ // moved member may sit on a later authored slot, which must then move too.
2519
+ const assigned = [];
2520
+ const moved = [];
2521
+ playerIds.forEach((playerId, i) => {
2522
+ const at = slots[i];
2523
+ // A lone door visitor may find the owner still at the arrival (a House
2524
+ // visit from People carries no `near`), and two solid bodies on one spot
2525
+ // wedge. Only authored-floor places step off an occupied slot: a town or
2526
+ // ground-backed game keeps the spawn WORLD already showed (Oct 17, the
2527
+ // ring's later correction glided a joiner 1.1 m), and empty rows keep
2528
+ // their authored placement.
2529
+ const alternate = h.noGround === true && [...occupied, ...moved].some((p) => Math.hypot(p.x - at.x, p.z - at.z) < 2 * radius)
2530
+ ? freeArrivalSlot(h, at, across, Math.max(arrival.spread, 2 * radius + 0.1), radius, [...occupied, ...assigned, ...slots.slice(i + 1)], true) : null;
2531
+ const spot = alternate ?? { ...at, y: standingY(h, at) };
2532
+ assigned.push(spot);
2533
+ if (alternate) {moved.push(alternate);}
2534
+ placeAt(h, playerId, spot, facing);
2447
2535
  });
2448
2536
  }
2449
2537
 
2538
+ // Every other body in the place where it stands now, arrived or not: a body
2539
+ // waiting for its group or held is as solid as one that arrived.
2540
+ function othersAt(h, except) {
2541
+ return [...h.sim.players.entries()].filter(([id]) => !except.includes(id)).map(([, body]) => body.at);
2542
+ }
2543
+
2544
+ // A stored pose (an arrival pose, a durable resumePose, a retained visit)
2545
+ // puts a returning player back where they stood, but someone may stand there
2546
+ // now. On an authored-floor place one closer than two radii steps off along
2547
+ // the row across their facing, else takes the arrival (Oct 19 QA: a guest's
2548
+ // stored House pose was restored 0.42 m from the owner, and they wedged).
2549
+ function restorePose(h, playerId, at, facing) {
2550
+ const radius = bodySize(h)?.radius ?? BODY_RADIUS_M;
2551
+ const others = othersAt(h, [playerId]);
2552
+ if (h.noGround !== true || !others.some((p) => Math.hypot(p.x - at.x, p.z - at.z) < 2 * radius)) {
2553
+ moveBody(h, playerId, at, facing);
2554
+ return;
2555
+ }
2556
+ const across = { x: Math.cos(facing ?? 0), z: -Math.sin(facing ?? 0) };
2557
+ const spot = freeArrivalSlot(h, at, across, 2 * radius + 0.1, radius, others, true);
2558
+ if (spot) {
2559
+ moveBody(h, playerId, spot, facing);
2560
+ } else {
2561
+ placeGroup(h, [playerId]);
2562
+ }
2563
+ // A hold the player kept across the drop would put them back on the
2564
+ // occupied spot next tick: it follows them to where they now stand.
2565
+ const hold = h.held.get(playerId);
2566
+ const now = h.sim.players.get(playerId)?.at;
2567
+ if (hold && now) {
2568
+ h.held.set(playerId, { ...hold, at: { ...now }, facing: h.sim.players.get(playerId).facing });
2569
+ }
2570
+ }
2571
+
2572
+ // `around`: when the row has no free slot, also try the eight compass
2573
+ // directions at the same steps (a narrow floor may run across the row).
2574
+ function freeArrivalSlot(h, at, across, step, radius, occupied, around = false) {
2575
+ // The legacy envelope intersects authored floors under shorter players.
2576
+ const size = (h.noGround === true ? bodySize(h) : null) ?? { radius: BODY_RADIUS_M, halfHeight: BODY_HALF_M };
2577
+ const dirs = [[across.x, across.z], [-across.x, -across.z]];
2578
+ if (around) {
2579
+ for (let i = 0; i < 8; i += 1) {dirs.push([Math.cos(i * Math.PI / 4), Math.sin(i * Math.PI / 4)]);}
2580
+ }
2581
+ for (const [rows, from] of around ? [[2, 0], [dirs.length, 2]] : [[2, 0]]) {
2582
+ for (let k = 1; k <= 6; k += 1) {
2583
+ for (let d = from; d < rows; d += 1) {
2584
+ const [dx, dz] = dirs[d];
2585
+ const candidate = { x: at.x + dx * k * step, y: at.y, z: at.z + dz * k * step };
2586
+ candidate.y = standingY(h, candidate);
2587
+ if (!occupied.some((p) => Math.hypot(p.x - candidate.x, p.z - candidate.z) < 2 * radius) &&
2588
+ spotClear(h, candidate, size) && padAt(h, candidate, radius) === null) {
2589
+ return candidate;
2590
+ }
2591
+ }
2592
+ }
2593
+ }
2594
+ return null;
2595
+ }
2596
+
2450
2597
  // A player who jumped to a friend stands beside them, facing them, when the
2451
2598
  // friend is in this session, a block hides neither from the other, and a spot
2452
2599
  // beside them is clear (no solid actor there; on a scene with no ground, a
@@ -2495,7 +2642,9 @@ function placeBeside(h, playerId, otherId, used = new Map()) {
2495
2642
  [-Math.sin(f), -Math.cos(f)],
2496
2643
  [Math.sin(f), Math.cos(f)],
2497
2644
  ];
2498
- const taken = used.get(otherId) ?? [];
2645
+ // On an authored floor a spot keeps clear of every other body too, not only
2646
+ // of this batch's spots: two solid bodies closer than two radii wedge.
2647
+ const taken = [...(used.get(otherId) ?? []), ...(h.noGround === true ? othersAt(h, [playerId]) : [])];
2499
2648
  // Never on or at the edge of a door's pad, theirs included (v1.19): a pad
2500
2649
  // takes whoever stands on it into its game, and nobody goes into a game
2501
2650
  // they did not choose. Beside a friend on a pad is a step or two further
@@ -2505,8 +2654,7 @@ function placeBeside(h, playerId, otherId, used = new Map()) {
2505
2654
  .map(([dx, dz]) => ({ x: other.at.x + dx * NEAR_STEP_M * step, y: other.at.y, z: other.at.z + dz * NEAR_STEP_M * step }))
2506
2655
  .find((at) => !taken.some((t) => Math.hypot(t.x - at.x, t.z - at.z) < 2 * size.radius) && spotClear(h, at, size) && padAt(h, at, size.radius) === null);
2507
2656
  if (spot) {
2508
- taken.push(spot);
2509
- used.set(otherId, taken);
2657
+ used.set(otherId, [...(used.get(otherId) ?? []), spot]);
2510
2658
  placeAt(h, playerId, spot, Math.atan2(other.at.x - spot.x, other.at.z - spot.z));
2511
2659
  return true;
2512
2660
  }
@@ -2527,45 +2675,28 @@ function padAt(h, at, margin) {
2527
2675
  return null;
2528
2676
  }
2529
2677
 
2530
- // Whether a standing body fits at `at`: no solid scene actor overlaps it, and
2531
- // on a scene with no ground (`fallY`) a solid's top is under its feet.
2678
+ // Whether a standing body fits at `at`: no solid overlaps it -- a scene actor
2679
+ // or a spawned copy (a House's placed furniture), at its live pose -- and on
2680
+ // a scene with no ground (`fallY`) a solid's top is under its feet.
2532
2681
  function spotClear(h, at, { radius, halfHeight }) {
2533
2682
  let supported = h.noGround !== true;
2534
- for (const actor of h.actors) {
2535
- const c = actor.components;
2536
- const t = c.Transform;
2537
- const shape = c.Shape;
2538
- // Solid as physics reads it: a Solid component or a solid Shape.
2539
- if (!(c.Solid || shape?.solid === true) || !t || !shape) {
2540
- continue;
2541
- }
2542
- const half = shape.kind === 'sphere' ? (shape.radius ?? 0.5) : (shape.height ?? 1) / 2;
2543
- const top = (t.y ?? 0) + half;
2544
- const bottom = (t.y ?? 0) - half;
2545
- const inside = footprintHas(shape, t, at, radius);
2683
+ for (const { shape, pose } of solids(h)) {
2684
+ // A tilted solid is judged by its enclosing sphere, as standingY does.
2685
+ const bound = pose.upright ? null : boundingRadius(shape);
2686
+ const half = bound ?? (shape.kind === 'sphere' ? (shape.radius ?? 0.5) : (shape.height ?? 1) / 2);
2687
+ const top = pose.y + half;
2688
+ const bottom = pose.y - half;
2689
+ const inside = bound === null ? poseFootprintHas(shape, pose, at, radius) : !(bound > 0) || Math.hypot(at.x - pose.x, at.z - pose.z) <= bound + radius;
2546
2690
  if (inside && top > at.y - halfHeight + 0.05 && bottom < at.y + halfHeight) {
2547
2691
  return false;
2548
2692
  }
2549
- if (!supported && footprintHas(shape, t, at, 0) && Math.abs(top - (at.y - halfHeight)) < 0.6) {
2693
+ if (!supported && bound === null && poseFootprintHas(shape, pose, at, 0) && Math.abs(top - (at.y - halfHeight)) < 0.6) {
2550
2694
  supported = true;
2551
2695
  }
2552
2696
  }
2553
2697
  return supported;
2554
2698
  }
2555
2699
 
2556
- // Whether a point lies within a shape's footprint, grown by `pad`.
2557
- function footprintHas(shape, t, at, pad) {
2558
- const dx = at.x - t.x;
2559
- const dz = at.z - t.z;
2560
- if (shape.kind === 'box') {
2561
- const r = ((t.rotationY ?? 0) * Math.PI) / 180;
2562
- const lx = dx * Math.cos(r) - dz * Math.sin(r);
2563
- const lz = dx * Math.sin(r) + dz * Math.cos(r);
2564
- return Math.abs(lx) <= (shape.width ?? 1) / 2 + pad && Math.abs(lz) <= (shape.depth ?? 1) / 2 + pad;
2565
- }
2566
- return Math.hypot(dx, dz) <= (shape.radius ?? 0.5) + pad;
2567
- }
2568
-
2569
2700
  // Move a body. One placed before the joiner's WORLD snapshot is where that
2570
2701
  // snapshot starts them; a later one reaches the client as a clamp.
2571
2702
  function placeAt(h, playerId, at, facing) {
@@ -2738,6 +2869,7 @@ function report(h, playerId, value) {
2738
2869
  }
2739
2870
 
2740
2871
  function end(h, playerId, why) {
2872
+ Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
2741
2873
  if (h.place.analyticsRounds !== 'authored') {DoorAnalytics.finish(h, playerId);}
2742
2874
  const entry = h.players.get(playerId);
2743
2875
  if (entry) {
@@ -2747,6 +2879,14 @@ function end(h, playerId, why) {
2747
2879
  entry.endWhy = why;
2748
2880
  }
2749
2881
  }
2882
+ // A visit the place ended is over, like a kit trip (sendGo): a drop on the
2883
+ // way out keeps no durable pose to come back to. A House front-door leave
2884
+ // was stored on the door and restored there, which ended the next visit at
2885
+ // once (Oct 19 QA). Result places that resume (v1.72) keep their end.
2886
+ if (h.poseStore) {
2887
+ h.resumeDeparting?.add(playerId);
2888
+ void h.poseStore.clear(entry?.userId, playerId);
2889
+ }
2750
2890
  h.held.delete(playerId);
2751
2891
  Shot.stopHolding(h, playerId);
2752
2892
  h.session?.send(playerId, { k: 'hub-end', why });
@@ -2846,7 +2986,7 @@ function houseVisit(h, player, data) {
2846
2986
  Idle.stand(h, playerId);
2847
2987
  }
2848
2988
  if (!door || h.held.has(playerId) || now - (h.jumpAt.get(playerId) ?? 0) < JUMP_EVERY_MS ||
2849
- isShut(h, playerId, door.id) || !membersOf(h, [playerId]).size) {
2989
+ cannotGo(h, playerId, door.id) || !membersOf(h, [playerId]).size) {
2850
2990
  return;
2851
2991
  }
2852
2992
  h.jumpAt.set(playerId, now);
@@ -3262,6 +3402,8 @@ function deckDoorPlace(h, props, deck) {
3262
3402
  // All outgoing travel paths retire the lease after sending the command.
3263
3403
  function sendGo(h, playerId, msg) {
3264
3404
  if (h.session?.send) {
3405
+ Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
3406
+ if (h.cars) {(h.vehicleDeparting ??= new Set()).add(playerId);}
3265
3407
  h.session.send(playerId, msg);
3266
3408
  Shot.stopHolding(h, playerId);
3267
3409
  // An explicit kit trip ends the visit rather than retaining it for a drop.
@@ -3278,7 +3420,7 @@ function sendGo(h, playerId, msg) {
3278
3420
  // join). In dev the destination is a named session whose key names the place;
3279
3421
  // the door table makes this a host command and the instance ghost's.
3280
3422
  function go(h, door, playerIds, { instance } = {}) {
3281
- const going = (playerIds ?? []).filter((playerId) => !isShut(h, playerId, door));
3423
+ const going = (playerIds ?? []).filter((playerId) => !cannotGo(h, playerId, door));
3282
3424
  if (going.length < (playerIds ?? []).length) {
3283
3425
  if (!going.length) {
3284
3426
  return null;
@@ -3458,12 +3600,13 @@ function gather(h, door, playerIds) {
3458
3600
  unshut(h, playerId);
3459
3601
  }
3460
3602
  }
3603
+ noTripsLabels(h, door, on);
3461
3604
  const hub = platformHub(h);
3462
3605
  // Ghost holds no pad for a cabinet (v1.7): it is not a pad door.
3463
3606
  if (!hub || Cabinets.isClassic(h, door) || Cabinets.cabinetDoorIds(h).has(door) || isLayerDoor(h, door)) {
3464
3607
  return;
3465
3608
  }
3466
- const users = travelersOf(h, [...on].filter((playerId) => !isShut(h, playerId, door)));
3609
+ const users = travelersOf(h, [...on].filter((playerId) => !cannotGo(h, playerId, door)));
3467
3610
  const members = [...users.keys()].sort();
3468
3611
  let pad = h.pads.get(door);
3469
3612
  if (pad?.firing) {
@@ -3514,6 +3657,8 @@ function doorShut(h, player, data) {
3514
3657
  }
3515
3658
  h.resumeDeparting?.delete(playerId);
3516
3659
  h.actDeparting?.delete(playerId);
3660
+ // A failed trip lets them drive and ride again (v1.160).
3661
+ h.vehicleDeparting?.delete(playerId);
3517
3662
  unshut(h, playerId);
3518
3663
  if (h.padDoors.has(found.id) && !h.padDoors.get(found.id).has(playerId)) {
3519
3664
  // Already stepped off while the trip was failing.
@@ -3536,6 +3681,56 @@ function isShut(h, playerId, door) {
3536
3681
  return false;
3537
3682
  }
3538
3683
 
3684
+ // v1.156: the client's word that its app has no `hub.go` (released iOS Castle
3685
+ // 1.150 and 1.151 have no hub commands at all), so no door can take this
3686
+ // player anywhere: they are left out of every pad and `hub.go` here for as
3687
+ // long as they stay, rather than counting toward a countdown whose trip their
3688
+ // app turns back. A pad they stand on tells them, to them alone. A connected
3689
+ // player's own word only; it can only ever take its sender out.
3690
+ function noTrips(h, session, player) {
3691
+ const playerId = player?.playerId;
3692
+ if (!playerId || !session?.players.some((p) => p.playerId === playerId) || h.noTrips.has(playerId)) {
3693
+ return;
3694
+ }
3695
+ h.noTrips.add(playerId);
3696
+ console.log(`[hub] ${playerId}'s app has no door trips`);
3697
+ }
3698
+
3699
+ // Whether a door must leave this player out: their app cannot go through
3700
+ // doors, or this one stayed shut for them.
3701
+ function cannotGo(h, playerId, door) {
3702
+ return h.noTrips.has(playerId) || isShut(h, playerId, door);
3703
+ }
3704
+
3705
+ // The private 'Update Castle to play' on a door, for each player without door
3706
+ // trips that the deck says stands on its pad; cleared when they step off.
3707
+ function noTripsLabels(h, door, on) {
3708
+ if (!h.noTrips.size && !h.noTripsLabel.size) {
3709
+ return;
3710
+ }
3711
+ for (const [playerId, entry] of h.noTripsLabel) {
3712
+ if (entry.door === door && !on.has(playerId)) {
3713
+ h.noTripsLabel.delete(playerId);
3714
+ setLabel(h, entry.actor, null, { to: [playerId] }, false);
3715
+ }
3716
+ }
3717
+ for (const playerId of on) {
3718
+ if (!h.noTrips.has(playerId) || h.noTripsLabel.get(playerId)?.door === door) {
3719
+ continue;
3720
+ }
3721
+ const found = doors(h).find((d) => d.id === door);
3722
+ if (!found) {
3723
+ return;
3724
+ }
3725
+ const was = h.noTripsLabel.get(playerId);
3726
+ if (was) {
3727
+ setLabel(h, was.actor, null, { to: [playerId] }, false);
3728
+ }
3729
+ h.noTripsLabel.set(playerId, { door, actor: found.actor });
3730
+ setLabel(h, found.actor, NO_TRIPS_LABEL, { to: [playerId], style: 'sign' }, false);
3731
+ }
3732
+ }
3733
+
3539
3734
  function unshut(h, playerId) {
3540
3735
  const entry = h.shut.get(playerId);
3541
3736
  if (entry) {
@@ -3590,11 +3785,16 @@ function padFired(h, door, pad, users, fired) {
3590
3785
  }
3591
3786
  const found = doors(h).find((d) => d.id === door);
3592
3787
  const group = Array.isArray(fired) ? fired : [];
3593
- // The group is ghost's; anyone of it still here goes, on the pad now or not.
3788
+ // The group is ghost's; anyone of it still here goes, on the pad now or not,
3789
+ // but a player whose app has turned out to have no door trips since (v1.156).
3594
3790
  const here = travelersOf(h, h.session?.players.map((p) => p.playerId));
3595
- tellWent(h, group.map((userId) => users.get(userId) ?? here.get(userId)).filter(Boolean), door);
3596
- for (const userId of group) {
3791
+ const going = (userId) => {
3597
3792
  const playerId = users.get(userId) ?? here.get(userId);
3793
+ return playerId && !h.noTrips.has(playerId) ? playerId : null;
3794
+ };
3795
+ tellWent(h, group.map(going).filter(Boolean), door);
3796
+ for (const userId of group) {
3797
+ const playerId = going(userId);
3598
3798
  if (playerId) {
3599
3799
  sendGo(h, playerId, {
3600
3800
  k: 'hub-go',
@@ -4472,3 +4672,15 @@ function identityUserIdOf(h, playerId) {
4472
4672
  function usernameOf(h, playerId) {
4473
4673
  return h.session?.players.find((p) => p.playerId === playerId)?.username ?? 'player';
4474
4674
  }
4675
+
4676
+ // Roles (v1.157) use try-on's whole-block latch: never-called places have
4677
+ // no key; the last role sends one empty delta, and snapshots omit empties.
4678
+ function rolesForJoin(h) {
4679
+ const roles = Role.rolesOf(h, blockedPairs(h));
4680
+ return Object.keys(roles).length ? { hubRole: roles } : {};
4681
+ }
4682
+
4683
+ function latchRoles(h, out) {
4684
+ const roles = Role.rolesOf(h, blockedPairs(h));
4685
+ if (Object.keys(roles).length || h.sent.has('hubRole')) { latch(h, 'hubRole', roles, out); }
4686
+ }