castle-web-cli 0.4.240 → 0.4.242

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 (42) hide show
  1. package/dist/bundle.d.ts +9 -1
  2. package/dist/bundle.js +214 -25
  3. package/dist/init.js +1 -1
  4. package/dist/multiplayerDoc.d.ts +1 -1
  5. package/dist/multiplayerDoc.js +2 -0
  6. package/dist/platformDoc.js +3 -3
  7. package/dist/playPagePolicy.js +7 -6
  8. package/dist/roomLogs.d.ts +1 -0
  9. package/dist/roomLogs.js +30 -6
  10. package/dist/save-deck.js +20 -3
  11. package/kits/base/castle.json +1 -1
  12. package/kits/base/sdk/README.md +7 -0
  13. package/kits/base/sdk/context.d.ts +5 -0
  14. package/kits/base/sdk/debugConsole.d.ts +1 -0
  15. package/kits/base/sdk/debugConsole.js +87 -14
  16. package/kits/base/sdk/runtime.js +5 -4
  17. package/kits/hub-game/code/client/chrome.js +8 -4
  18. package/kits/hub-game/code/client/padCues.js +11 -7
  19. package/kits/hub-game/code/client/padReadability.js +3 -3
  20. package/kits/hub-game/code/client/visibility.js +14 -4
  21. package/kits/hub-game/code/server/hub.js +146 -30
  22. package/kits/hub-game/code/server/players.js +6 -1
  23. package/kits/hub-game/code/server/standing.js +7 -3
  24. package/kits/hub-game/code/systems/hub.js +11 -3
  25. package/kits/hub-game/docs/contract.md +25 -4
  26. package/kits/hub-game/scripts/test-ballot.mjs +1 -1
  27. package/kits/hub-game/scripts/test-hub-trip.mjs +24 -0
  28. package/kits/hub-game/scripts/test-pad-cues.mjs +39 -0
  29. package/kits/hub-game/scripts/test-placeat-server.mjs +259 -6
  30. package/kits/hub-game/scripts/test-rehello.mjs +5 -3
  31. package/kits/hub-game/scripts/test-standing.mjs +135 -2
  32. package/kits/hub-game/scripts/test-stuck.mjs +5 -1
  33. package/kits/hub-game/scripts/test-visibility.mjs +54 -0
  34. package/kits/multiplayer-3d/castle.json +1 -1
  35. package/kits/multiplayer-3d/code/client/resumeGate.js +18 -1
  36. package/kits/multiplayer-3d/code/systems/multiplayer.js +41 -7
  37. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +226 -0
  38. package/kits/physics-3d/castle.json +1 -1
  39. package/kits/physics-3d/package.json +1 -1
  40. package/kits/physics-3d/scripts/test-coaxial-escape.mjs +176 -0
  41. package/kits/physics-3d/systems/physics3d.js +8 -0
  42. package/package.json +1 -1
@@ -150,6 +150,14 @@ const USER_ID = /^\d{1,20}$/;
150
150
  // A scene with implicit ground needs it too: that finite floor has an edge.
151
151
  const DEFAULT_FALL_Y = -20;
152
152
 
153
+ // Half the side of the server's ground slab: `ground.half` clamped to 1..200,
154
+ // else 100 (multiplayer-3d world.js `colliderHalf`, whose rule this repeats:
155
+ // that function is not exported).
156
+ function groundHalf(setting) {
157
+ const half = setting?.half;
158
+ return typeof half === 'number' && Number.isFinite(half) ? Math.min(200, Math.max(1, half)) : 100;
159
+ }
160
+
153
161
  function hasHook(deckHooks, placeHooks, name) {
154
162
  return typeof deckHooks?.[name] === 'function' || Object.values(placeHooks ?? {}).some((hooks) => typeof hooks?.[name] === 'function');
155
163
  }
@@ -308,6 +316,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
308
316
  delete h.ctx.menu;
309
317
  }
310
318
  h.noGround = sceneGround(h.place.scene)?.none === true;
319
+ h.groundHalf = h.noGround ? 0 : groundHalf(sceneGround(h.place.scene));
311
320
  h.fallY = h.place.fallY ?? DEFAULT_FALL_Y;
312
321
  console.log(`[hub] place ${id} (${source}): ${h.place.scene}`);
313
322
  return h.place.scene;
@@ -319,6 +328,25 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
319
328
  return h.sim === sim && h.place ? standingY(h, at) : at.y;
320
329
  },
321
330
 
331
+ // v1.218: a body admitted with no pose (players.js puts it on the scene
332
+ // spawn, `at`) where another body stands, at the spawn or at the slot its
333
+ // lone arrival would take, starts where that arrival will put it instead,
334
+ // before its WORLD goes out: that snapshot is then the one placement its
335
+ // client makes, at once. That is the arrival slot when it is free, else
336
+ // the free spot beside it the arrival would step off to (`loneSlot`, the
337
+ // search `placeGroup` makes). Null when neither is taken (the arrival
338
+ // places it as before), or when nowhere is free (it shares the spawn, as
339
+ // before v1.218, and the arrival row is its only way off).
340
+ joinSpot(sim, playerId, at) {
341
+ if (h.sim !== sim || !h.place) {return null;}
342
+ const others = othersAt(h, [playerId]);
343
+ const slot = loneSlot(h);
344
+ if (!others.some((p) => takes(h, p, at) || takes(h, p, slot.standing))) {return null;}
345
+ const spot = others.some((p) => takes(h, p, slot.standing)) ? slot.stepOff(others) : slot.standing;
346
+ if (spot) {h.joinedOff.set(playerId, { ...spot });}
347
+ return spot;
348
+ },
349
+
322
350
  ready(sim) {
323
351
  h.sim = sim;
324
352
  h.actors = Scene.readScene(sim.scenePath);
@@ -396,9 +424,10 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
396
424
  typeof data.visible !== 'boolean' || !Number.isFinite(data.at) || data.at < 0) {
397
425
  return;
398
426
  }
399
- if (entry.visibility && (data.at < entry.visibility.at || data.visible === entry.visibility.visible)) {
427
+ if (entry.visibility && (data.at < entry.visibility.at || (data.visible === entry.visibility.visible && !entry.visibilityRejoined))) {
400
428
  return;
401
429
  }
430
+ delete entry.visibilityRejoined;
402
431
  entry.visibility = { visible: data.visible, at: data.at };
403
432
  entry.visibilityPending = true;
404
433
  notifyVisibility(h, player.playerId);
@@ -931,6 +960,9 @@ function newState(manifest, savedDeckId) {
931
960
  whereAt: new Map(),
932
961
  // playerId -> { at, facing, until }: bodies kept where a jump put them (`settle`)
933
962
  settling: new Map(),
963
+ // playerId -> where `joinSpot` put a body that found the spawn taken
964
+ // (v1.218): its WORLD starts it there, and its arrival keeps it there.
965
+ joinedOff: new Map(),
934
966
  // playerId -> { at, body, until }: a place's `hub.placeAt` waiting for its
935
967
  // client to report from the spot (`stalePose`)
936
968
  placed: new Map(),
@@ -1518,7 +1550,9 @@ function hello(h, player, data, synthetic = false) {
1518
1550
  !accountProgressBlocked(h, progressUser);
1519
1551
  const entry = {
1520
1552
  // Who this is, kept for `leave`: by then the session has forgotten them.
1521
- ...(h.place.visibility === true && known?.visibility ? { visibility: known.visibility, visibilityPending: known.visibilityPending } : {}),
1553
+ // v1.219: a rejoin's first signal is taken even when it repeats the kept
1554
+ // value: the client may have sent its change into the socket that died.
1555
+ ...(h.place.visibility === true && known?.visibility ? { visibility: known.visibility, visibilityPending: known.visibilityPending, ...(data.again !== true ? { visibilityRejoined: true } : known.visibilityRejoined ? { visibilityRejoined: true } : {}) } : {}),
1522
1556
  userId: progressUser,
1523
1557
  ...((known || poseBack) && claimedPose ? { arrivalPose: { ...claimedPose, userId: poseOwner } } : {}),
1524
1558
  username: usernameOf(h, player.playerId),
@@ -2589,6 +2623,7 @@ function forget(h, playerId) {
2589
2623
  h.unstuckAt?.delete(playerId);
2590
2624
  h.unstuckAskAt?.delete(playerId);
2591
2625
  h.settling.delete(playerId);
2626
+ h.joinedOff.delete(playerId);
2592
2627
  h.placed.delete(playerId);
2593
2628
  Grab.forget(h, playerId);
2594
2629
  if (h.manifest.act === true) {Act.forget(h, playerId);}
@@ -2878,8 +2913,8 @@ function arrivalPoint(h) {
2878
2913
  return actor?.components.Transform ?? h.sim?.spawn ?? { x: 0, y: 1, z: 0 };
2879
2914
  }
2880
2915
 
2881
- // A row at the arrival actor, facing the way the manifest says.
2882
- function placeGroup(h, playerIds) {
2916
+ // The arrival point, the way the row faces and the direction it runs.
2917
+ function arrivalRow(h) {
2883
2918
  const arrival = h.place.arrival;
2884
2919
  const t = arrivalPoint(h);
2885
2920
  let facing;
@@ -2891,29 +2926,93 @@ function placeGroup(h, playerIds) {
2891
2926
  facing = (t.rotationY ?? 0) * DEG;
2892
2927
  }
2893
2928
  // Facing f looks along (sin f, cos f); the row runs across it.
2894
- const across = { x: Math.cos(facing), z: -Math.sin(facing) };
2895
- const radius = bodySize(h)?.radius ?? BODY_RADIUS_M;
2896
- const occupied = othersAt(h, playerIds);
2897
- const n = playerIds.length;
2898
- const slots = playerIds.map((_, i) => {
2899
- const offset = (i - (n - 1) / 2) * arrival.spread;
2900
- return { x: t.x + across.x * offset, y: Math.max(t.y ?? 1, 1.2), z: t.z + across.z * offset };
2929
+ return { t, facing, across: { x: Math.cos(facing), z: -Math.sin(facing) } };
2930
+ }
2931
+
2932
+ // Whether a body standing at `p` takes the spot `at`: nearer than two radii
2933
+ // across the ground and overlapping it in height. A player on a floor above
2934
+ // or below takes nothing here (v1.218).
2935
+ function takes(h, p, at) {
2936
+ const size = bodySize(h) ?? { radius: BODY_RADIUS_M, halfHeight: BODY_HALF_M };
2937
+ return Math.hypot(p.x - at.x, p.z - at.z) < 2 * size.radius && Math.abs(p.y - at.y) < 2 * size.halfHeight;
2938
+ }
2939
+
2940
+ // The row's slots for `n` players: each authored (`at`, at least 1.2 m up)
2941
+ // and where a body stands there (`standing`), which is what occupancy is
2942
+ // judged at (v1.218: an elevated marker's raw height let an earlier member
2943
+ // stepping off take a later member's slot).
2944
+ function rowSlots(h, n) {
2945
+ const { t, across } = arrivalRow(h);
2946
+ const spread = h.place.arrival.spread;
2947
+ return Array.from({ length: n }, (_, i) => {
2948
+ const offset = (i - (n - 1) / 2) * spread;
2949
+ const at = { x: t.x + across.x * offset, y: Math.max(t.y ?? 1, 1.2), z: t.z + across.z * offset };
2950
+ return { at, standing: { ...at, y: standingY(h, at) } };
2901
2951
  });
2952
+ }
2953
+
2954
+ // Where a lone arrival goes (`placeGroup` with one player): the slot, or,
2955
+ // when `occupied` takes it, the free spot beside it (null when none is).
2956
+ // `joinSpot` asks the same, so the two cannot disagree.
2957
+ function loneSlot(h) {
2958
+ const [slot] = rowSlots(h, 1);
2959
+ return { ...slot, stepOff: (occupied) => stepOffSlot(h, slot.at, occupied) };
2960
+ }
2961
+
2962
+ function stepOffSlot(h, at, occupied) {
2963
+ const { across } = arrivalRow(h);
2964
+ const radius = bodySize(h)?.radius ?? BODY_RADIUS_M;
2965
+ return freeArrivalSlot(h, at, across, Math.max(h.place.arrival.spread, 2 * radius + 0.1), radius, occupied, true);
2966
+ }
2967
+
2968
+ // A row at the arrival actor, facing the way the manifest says.
2969
+ function placeGroup(h, ids) {
2970
+ const { t, facing, across } = arrivalRow(h);
2971
+ const occupied = othersAt(h, ids);
2972
+ const off = new Map(ids.filter((id) => h.joinedOff.has(id)).map((id) => [id, h.joinedOff.get(id)]));
2973
+ for (const id of ids) {h.joinedOff.delete(id);}
2974
+ // v1.218: one admitted beside a taken spawn (`joinSpot`) was put there by
2975
+ // its WORLD. Alone, it arrives where it stands while that is still free:
2976
+ // moving it now would reach its client as a clamp, eased a quarter of the
2977
+ // way per update, the glide v1.147 removed. (One whose spot was taken
2978
+ // since, or that moved, is placed as anyone is.)
2979
+ if (ids.length === 1 && off.has(ids[0])) {
2980
+ const body = h.sim.players.get(ids[0]);
2981
+ const kept = off.get(ids[0]);
2982
+ if (body && Math.hypot(body.at.x - kept.x, body.at.z - kept.z) <= HOLD_SLACK && !occupied.some((p) => takes(h, p, body.at))) {
2983
+ placeAt(h, ids[0], { ...body.at }, facing);
2984
+ return;
2985
+ }
2986
+ }
2987
+ // A group with a member admitted beside the spawn takes the row's slots in
2988
+ // the order its members stand along it, so nobody crosses the row.
2989
+ const along = (id) => {
2990
+ const at = h.sim.players.get(id)?.at;
2991
+ return at ? (at.x - t.x) * across.x + (at.z - t.z) * across.z : 0;
2992
+ };
2993
+ const playerIds = off.size ? [...ids].sort((a, b) => along(a) - along(b)) : ids;
2994
+ const slots = rowSlots(h, playerIds.length);
2902
2995
  // Where earlier members of this batch were put, and which of them moved: a
2903
2996
  // moved member may sit on a later authored slot, which must then move too.
2904
2997
  const assigned = [];
2905
2998
  const moved = [];
2906
2999
  playerIds.forEach((playerId, i) => {
2907
- const at = slots[i];
3000
+ const { at, standing } = slots[i];
2908
3001
  // A lone door visitor may find the owner still at the arrival (a House
2909
3002
  // visit from People carries no `near`), and two solid bodies on one spot
2910
- // wedge. Only authored-floor places step off an occupied slot: a town or
2911
- // ground-backed game keeps the spawn WORLD already showed (Oct 17, the
2912
- // ring's later correction glided a joiner 1.1 m), and empty rows keep
2913
- // their authored placement.
2914
- const alternate = h.noGround === true && [...occupied, ...moved].some((p) => Math.hypot(p.x - at.x, p.z - at.z) < 2 * radius)
2915
- ? freeArrivalSlot(h, at, across, Math.max(arrival.spread, 2 * radius + 0.1), radius, [...occupied, ...assigned, ...slots.slice(i + 1)], true) : null;
2916
- const spot = alternate ?? { ...at, y: standingY(h, at) };
3003
+ // wedge. Every place steps off an occupied slot (v1.218). Ground-backed
3004
+ // places (the Town) used to keep the spawn for everyone, so two lone
3005
+ // joiners stood on exactly the same point; each client's physics then
3006
+ // pressed its own capsule into the ground under the other's avatar and
3007
+ // ate every step until one left (Nov 17 Market check). The step-off is
3008
+ // one placement, not the ring's later 1.1 m glide that v1.147 removed
3009
+ // (Oct 17). Empty slots keep their authored placement.
3010
+ // When no spot beside it is free (`freeArrivalSlot` null) the slot
3011
+ // itself is used, shared, as before v1.218. Later members' slots are
3012
+ // held for them where they will stand, as every occupant is judged.
3013
+ const alternate = [...occupied, ...moved].some((p) => takes(h, p, standing))
3014
+ ? stepOffSlot(h, at, [...occupied, ...assigned, ...slots.slice(i + 1).map((slot) => slot.standing)]) : null;
3015
+ const spot = alternate ?? standing;
2917
3016
  assigned.push(spot);
2918
3017
  if (alternate) {moved.push(alternate);}
2919
3018
  placeAt(h, playerId, spot, facing);
@@ -2921,21 +3020,33 @@ function placeGroup(h, playerIds) {
2921
3020
  }
2922
3021
 
2923
3022
  // Every other body in the place where it stands now, arrived or not: a body
2924
- // waiting for its group or held is as solid as one that arrived.
3023
+ // waiting for its group or held is as solid as one that arrived. Not one whose
3024
+ // player has left the roster: real-time admits a joiner before it removes the
3025
+ // bodies of players who left that tick (v1.218), and those are going.
2925
3026
  function othersAt(h, except) {
2926
- return [...h.sim.players.entries()].filter(([id]) => !except.includes(id)).map(([, body]) => body.at);
3027
+ const roster = Array.isArray(h.session?.players) ? new Set(h.session.players.map((p) => p.playerId)) : null;
3028
+ return [...h.sim.players.entries()]
3029
+ .filter(([id]) => !except.includes(id) && (roster === null || roster.has(id)))
3030
+ .map(([, body]) => body.at);
2927
3031
  }
2928
3032
 
2929
3033
  // A stored pose (an arrival pose, a durable resumePose, a retained visit)
2930
3034
  // puts a returning player back where they stood, but someone may stand there
2931
- // now. On an authored-floor place one closer than two radii steps off along
2932
- // the row across their facing, else takes the arrival (Oct 19 QA: a guest's
2933
- // stored House pose was restored 0.42 m from the owner, and they wedged).
3035
+ // now. One closer than two radii steps off along the row across their
3036
+ // facing, else takes the arrival (Oct 19 QA: a guest's stored House pose was
3037
+ // restored 0.42 m from the owner, and they wedged). On every place since
3038
+ // v1.218, ground-backed ones too: two capsules on one spot wedge there as well
3039
+ // (Nov 17 Market check). A pose nobody stands on is restored exactly.
2934
3040
  function restorePose(h, playerId, at, facing) {
3041
+ const body = h.sim.players.get(playerId);
3042
+ const from = body ? { ...body.at } : null;
3043
+ // An arrival hook may already have placed them here; keep its stale-report guard.
3044
+ const guard = h.placed.get(playerId);
2935
3045
  const radius = bodySize(h)?.radius ?? BODY_RADIUS_M;
2936
3046
  const others = othersAt(h, [playerId]);
2937
- if (h.noGround !== true || !others.some((p) => Math.hypot(p.x - at.x, p.z - at.z) < 2 * radius)) {
3047
+ if (!others.some((p) => takes(h, p, at))) {
2938
3048
  moveBody(h, playerId, at, facing);
3049
+ guardPlacement(h, playerId, from, guard);
2939
3050
  return;
2940
3051
  }
2941
3052
  const across = { x: Math.cos(facing ?? 0), z: -Math.sin(facing ?? 0) };
@@ -2945,6 +3056,7 @@ function restorePose(h, playerId, at, facing) {
2945
3056
  } else {
2946
3057
  placeGroup(h, [playerId]);
2947
3058
  }
3059
+ guardPlacement(h, playerId, from, guard);
2948
3060
  // A hold the player kept across the drop would put them back on the
2949
3061
  // occupied spot next tick: it follows them to where they now stand.
2950
3062
  const hold = h.held.get(playerId);
@@ -2957,8 +3069,10 @@ function restorePose(h, playerId, at, facing) {
2957
3069
  // `around`: when the row has no free slot, also try the eight compass
2958
3070
  // directions at the same steps (a narrow floor may run across the row).
2959
3071
  function freeArrivalSlot(h, at, across, step, radius, occupied, around = false) {
2960
- // The legacy envelope intersects authored floors under shorter players.
2961
- const size = (h.noGround === true ? bodySize(h) : null) ?? { radius: BODY_RADIUS_M, halfHeight: BODY_HALF_M };
3072
+ // The place's own body, as its players are (v1.218: ground-backed places
3073
+ // used the larger legacy envelope, which intersects authored floors under
3074
+ // shorter players).
3075
+ const size = bodySize(h) ?? { radius: BODY_RADIUS_M, halfHeight: BODY_HALF_M };
2962
3076
  const dirs = [[across.x, across.z], [-across.x, -across.z]];
2963
3077
  if (around) {
2964
3078
  for (let i = 0; i < 8; i += 1) {dirs.push([Math.cos(i * Math.PI / 4), Math.sin(i * Math.PI / 4)]);}
@@ -2969,7 +3083,7 @@ function freeArrivalSlot(h, at, across, step, radius, occupied, around = false)
2969
3083
  const [dx, dz] = dirs[d];
2970
3084
  const candidate = { x: at.x + dx * k * step, y: at.y, z: at.z + dz * k * step };
2971
3085
  candidate.y = standingY(h, candidate);
2972
- if (!occupied.some((p) => Math.hypot(p.x - candidate.x, p.z - candidate.z) < 2 * radius) &&
3086
+ if (!occupied.some((p) => takes(h, p, candidate)) &&
2973
3087
  spotClear(h, candidate, size) && padAt(h, candidate, radius) === null) {
2974
3088
  return candidate;
2975
3089
  }
@@ -3067,7 +3181,9 @@ function padAt(h, at, margin) {
3067
3181
  // or a spawned copy (a House's placed furniture), at its live pose -- and on
3068
3182
  // a scene with no ground (`fallY`) a solid's top is under its feet.
3069
3183
  function spotClear(h, at, { radius, halfHeight }) {
3070
- let supported = h.noGround !== true;
3184
+ // The ground slab is finite (`ground.half`, 100 m by default): a spot past
3185
+ // its edge stands only on an authored solid (v1.218).
3186
+ let supported = h.noGround !== true && Math.abs(at.x) <= (h.groundHalf ?? Infinity) && Math.abs(at.z) <= (h.groundHalf ?? Infinity);
3071
3187
  for (const { shape, pose } of solids(h)) {
3072
3188
  // A tilted solid is judged by its enclosing sphere, as standingY does.
3073
3189
  const bound = pose.upright ? null : boundingRadius(shape);
@@ -3110,7 +3226,7 @@ function moveBody(h, playerId, at, facing) {
3110
3226
  body.body.setTranslation(body.at, true);
3111
3227
  // Any placement is where the player is now, not a `hub.placeAt` still
3112
3228
  // waiting for its client (a hold, an arrival, a car, a pose restore, at any
3113
- // distance; `hub.placeAt` arms its own again, `guardPlacement`).
3229
+ // distance; `hub.placeAt` and pose restores arm theirs again, `guardPlacement`).
3114
3230
  h.placed.delete(playerId);
3115
3231
  // A leave before the next server step stores where the body was put, not
3116
3232
  // where that step's predecessor recorded it (`rememberResumePoses`).
@@ -7,7 +7,8 @@
7
7
  // on the ring was followed by the arrival row back at the spawn, which the
8
8
  // client eased to as a correction: a glide just after the cover lifted (Oct
9
9
  // 17, live Town; v1.147). A player waits for their group where their client agrees
10
- // they are; the arrival row spreads a group out.
10
+ // they are; the arrival row spreads a group out. One who finds another body
11
+ // on the spawn starts beside it instead (v1.218, `hub.joinSpot`).
11
12
  import * as Players from '@imports/castle.multiplayer-3d/code/server/players.js';
12
13
  import { readPoint } from '@imports/castle.multiplayer-3d/code/server/limits.js';
13
14
 
@@ -32,6 +33,10 @@ export function hubPlayers(hub) {
32
33
  const player = sim.players.get(playerId);
33
34
  const at = { ...player.at, x: sim.spawn?.x ?? player.at.x, z: sim.spawn?.z ?? player.at.z };
34
35
  player.at = { ...at, y: hub.standingY?.(sim, at) ?? at.y };
36
+ // v1.218: unless another body stands there. Two capsules on exactly
37
+ // one spot wedge each client's own body into the ground under the
38
+ // other's avatar; beside it, this WORLD is still the one placement.
39
+ player.at = hub.joinSpot?.(sim, playerId, player.at) ?? player.at;
35
40
  player.body.setTranslation(player.at, true);
36
41
  }
37
42
  return result;
@@ -7,9 +7,13 @@ export function standingY(h, at) {
7
7
  return at.y;
8
8
  }
9
9
  const { radius, halfHeight } = size;
10
- let support = h.noGround !== true ? 0 : null;
10
+ // The ground slab is finite (`ground.half`): past its edge only an authored
11
+ // solid holds a body, as spotClear judges it (v1.218).
12
+ const half = h.groundHalf ?? Infinity;
13
+ const onGround = h.noGround !== true && Math.abs(at.x) <= half && Math.abs(at.z) <= half;
14
+ let support = onGround ? 0 : null;
11
15
  const spans = [];
12
- let centredSupport = h.noGround !== true;
16
+ let centredSupport = onGround;
13
17
  for (const { shape, pose, moving } of solids(h)) {
14
18
  if (pose.upright && (shape.kind === 'box' || shape.kind === 'cylinder')) {
15
19
  if (!footprintHas(shape, pose, at, radius)) {
@@ -43,7 +47,7 @@ export function standingY(h, at) {
43
47
  }
44
48
  // In a scene without ground, a rim beside the feet does not prove support
45
49
  // beneath them. Keep the old drop rather than lower over a hole.
46
- if (support === null || (h.noGround === true && !centredSupport)) {
50
+ if (support === null || (!onGround && !centredSupport)) {
47
51
  return at.y;
48
52
  }
49
53
  const y = support + halfHeight + 0.06;
@@ -646,7 +646,7 @@ class HubSystem {
646
646
  }
647
647
  if (Hub.hub.place?.visibility === true || this.visibility) {
648
648
  this.visibility ??= makeVisibility();
649
- this.visibility.sync(mp.net, this.sceneKey, Hub.hub.place?.visibility === true && !this.trip);
649
+ this.visibility.sync(mp.net, this.sceneKey, Hub.hub.place?.visibility === true && !this.trip, this.admitEpoch ?? 0);
650
650
  }
651
651
  const held = Hub.hub.held.has(mp.net?.selfId?.());
652
652
  const fallY = activeFallY(Hub.hub.place?.fallY, held, Boolean(this.trip));
@@ -1748,6 +1748,7 @@ class HubSystem {
1748
1748
  // cover, and what the page holds is the place as it was before they left:
1749
1749
  // the way back starts under the trip's cover, with no door beat over it.
1750
1750
  const covered = mp.returning?.() === true;
1751
+ const placeTitle = Hub.hub.place?.title;
1751
1752
  Hub.clear();
1752
1753
  if (inGame && scene.persistent.hubTickets.length) {
1753
1754
  this.toast = { text: 'The game ended', until: performance.now() + TOAST_MS };
@@ -1760,8 +1761,14 @@ class HubSystem {
1760
1761
  } else if (!inGame && !refused && mp.target?.mode === 'hub') {
1761
1762
  console.warn('[hub-door] this place ended under a hub join behind a door: leaving by its way back');
1762
1763
  const title = scene.persistent.hubTickets.at(-1)?.title;
1764
+ // Seen on coming back from away, the place most likely ended because it
1765
+ // stood empty past its reconnect window (an owner's House left alone),
1766
+ // not because a new version was saved: say what the player can know.
1767
+ const ended = covered
1768
+ ? `${placeTitle || 'This place'} closed while you were away.`
1769
+ : 'This place was updated.';
1763
1770
  this.toast = {
1764
- text: title ? `This place was updated. Back to ${title}…` : 'This place was updated. Going back…',
1771
+ text: title ? `${ended} Back to ${title}…` : `${ended} Going back…`,
1765
1772
  until: performance.now() + TOAST_MS,
1766
1773
  };
1767
1774
  this.back(scene, { covered });
@@ -4339,8 +4346,9 @@ class HubSystem {
4339
4346
  this.padReadabilityScope = { data: scene.data, place: Hub.hub.place.id,
4340
4347
  context: engine.hubPadContext, ring: engine.hubPadRing, spawn: engine.hubSpawnRing };
4341
4348
  }
4349
+ const selfId = scene.multiplayer?.net?.selfId?.();
4342
4350
  this.padReadability.frame(scene.actors, Hub.hub.hidden, local?.components.Transform, Boolean(this.trip),
4343
- this.carded || this.decor?.opened() === true);
4351
+ this.carded || this.decor?.opened() === true, selfId != null && Hub.hub.guests?.has?.(selfId) === true);
4344
4352
  }
4345
4353
 
4346
4354
  // A town's world labels under `hub.labels: "near"` (v1.43): the plate and
@@ -378,6 +378,9 @@ Back; nothing is reported and nothing is granted. Web hosts only.
378
378
  whole board (cover, title, label, every row) and a tap on the board, or
379
379
  walking away, closes it; a cabinet with no score draws no chip. A place
380
380
  draws none of it and ships no client code for it. The size rules are in §12.
381
+ An open board (v1.217) is drawn opaque and over every plate and area label:
382
+ the pad caption (`engine.hubPadContext`) is hidden while it is open, and a
383
+ world label under it is covered, never seen through it. The chip is as before.
381
384
  - On the dev serve there is no ghost, so no board: a cabinet is inert, and a
382
385
  place says so on its label. `{ k: 'hub-dev-classic' }` (§12), honoured only
383
386
  by a dev session, gives every cabinet door a stand-in board so the card and
@@ -538,7 +541,13 @@ suppressed. The chip fits within 94vw and its personal line ellipsizes.
538
541
  A connection that comes back under a new player id (a drop past the place's
539
542
  hold, such as 180 s backgrounded) is not an arrival the player made: its
540
543
  `hub-arrived` leaves the camera's yaw and the avatar's facing as they were.
541
- - A late joiner arrives the same way, alone.
544
+ - A late joiner arrives the same way, alone. Two bodies never start on one
545
+ spot (v1.218): a joiner with no pose who finds the spawn or its arrival
546
+ slot taken starts where its arrival puts it, in its first WORLD; a row
547
+ slot or a stored pose being restored that another body on the roster takes
548
+ (nearer than two radii, overlapping it in height) is stepped off along the
549
+ row, else the eight compass directions, on every place (before, only on
550
+ authored floors). A free slot or pose is used exactly.
542
551
  - **A line on leaving (v1.52).** `hub.leaving(playerId, text)` says what is waiting
543
552
  next visit: on Back, a game's end or a door out of the place (not a classic
544
553
  cabinet), the latest line is captured under the trip cover's title and,
@@ -712,7 +721,11 @@ suppressed. The chip fits within 94vw and its personal line ellipsizes.
712
721
  server stopped): a game is left as before ("The game ended", then its way
713
722
  back); any other place reached through a door (the host's trail holds the
714
723
  trip) is left by its way back at once, with a line saying it was updated
715
- ("This place was updated. Back to <the place left>…"), and is entered again
724
+ ("This place was updated. Back to <the place left>…"), or, when the ending
725
+ is seen as the player comes back from away (`multiplayer.returning()`), that
726
+ it closed while they were away (v1.220; "<this place's title> closed while you
727
+ were away. Back to <the place left>…"; an owner's House left empty past its
728
+ reconnect window ends this way, nothing was saved), and is entered again
716
729
  through its door, which acquires the new version and its content. A join
717
730
  cannot be made again from inside such a place: its handoff is spent, and
718
731
  only a door's acquisition names the release to mount. The way back is asked
@@ -2524,7 +2537,9 @@ movement over 5 cm or a cue/visibility change, without frame allocations.
2524
2537
  - `engine.hubPadContext: true`: one noninteractive chrome caption shows the
2525
2538
  active title at 16 px, wrapping to at most two lines with ellipsis and the
2526
2539
  full accessible title. A nearby door pad adds “Step on to join” at 13 px;
2527
- explicit cues and standing players get no secondary line. It yields to
2540
+ explicit cues and standing players get no secondary line. For a guest (a
2541
+ `hub.guests` id: signed out or an anonymous visitor) a cabinet's pad says
2542
+ “Sign in to play” instead, near it or on it (v1.217). It yields to
2528
2543
  final chrome surfaces, the avatar, joystick and host corners, and is omitted
2529
2544
  without room. Panels, sheets, chat and travel hide it. It dispatches nothing
2530
2545
  and leaves Talk, invites and actions alone.
@@ -3674,7 +3689,10 @@ the deck's arrival hook. The kit calls the optional server hook
3674
3689
  The sender identity comes from the session; a payload cannot name another player.
3675
3690
  Malformed, duplicate-state and older-timestamp messages are ignored. `at` is
3676
3691
  untrusted metadata, never server simulation time or proof of elapsed time.
3677
- A place may pause its own guidance clocks while hidden and restore its UI on
3692
+ After any reconnect (v1.219) the client sends its current state again, and
3693
+ the server delivers a retained rejoin's first signal even when it repeats the
3694
+ kept value, so a change sent into a socket that died unseen is not lost and a
3695
+ place never keeps a stale hidden or visible. A place may pause its own guidance clocks while hidden and restore its UI on
3678
3696
  visible. This does not itself reconnect, arrive, leave or change progression;
3679
3697
  the existing `resume` hook remains independent.
3680
3698
 
@@ -5294,6 +5312,9 @@ a deck written before them remains valid.
5294
5312
 
5295
5313
  | date | change |
5296
5314
  | --- | --- |
5315
+ | 2026-11-18 (v1.220) | §"A place replaced under its players" copy: when the ending is seen as the player comes back from away (`multiplayer.returning()`), the line is "<this place's title> closed while you were away. Back to <the place left>…" ("This place closed while you were away…" with no title) instead of "This place was updated", which was not true for an owner's House left empty past its reconnect window. A player who was present still sees the updated line. Copy only: no key, API or wire change. |
5316
+ | 2026-11-18 (v1.219) | §12 page visibility after a rejoin: a client whose connection is not up forgets the state it last sent and sends its current state once it is connected again (a send into a socket that died unseen, as on an app switch, no longer leaves the server holding a stale hidden); the server takes a rejoin's first `hub-visibility` even when it repeats the kept value, then coalesces as before. An avatar-change hello is not a rejoin. No new key or wire field. |
5317
+ | 2026-11-17 (v1.218) | Kit-internal, server only, no deck-facing key or API and no wire change: §5 two bodies never start on one spot. A body admitted with no pose where another body takes the scene spawn or the slot its lone arrival would take starts where that arrival will put it (the arrival slot if free, else the free spot beside it; one helper decides both) before its WORLD goes out, so that WORLD is the one placement its client makes, at once; arriving alone it stays there while the spot is still free, and a group with such a member takes the row's slots in the order its members stand along it. An arrival slot (an arrival, and the arrival a fall or a Stuck? unstick puts a player at) or stored pose (cold `resumePose`, arrival pose, retained visit) that another body takes is likewise stepped off on every place, not only on authored floors (`ground.none: true`); a free slot or pose is used exactly. A body takes a spot when it is nearer than two radii and overlaps it in height (one on a floor above or below does not), and only while its player is on the roster (real-time admits a joiner before it removes the bodies of players who left that tick). A group row's later slots are held where a body would stand in them. The search uses the place's own body size and treats a spot past the ground slab's edge (`ground.half`, 100 m by default) as unsupported unless an authored solid holds it; when every candidate fails the slot is shared, as before. Ground-backed places (the Town) kept the spawn for everyone, so two lone joiners stood on exactly the same point; on each client the two capsules were coaxial, Rapier pushed the local one into the ground under the other's avatar, and it could not walk until one left (Nov 17 Market check, reproduced locally). A stepped-off cold restore still reaches its client as the restore always has. Tests: `test-placeat-server` stepoff, arrivalFree and arrivalTaken (WORLD before hello, reports and corrections on: the client moves once), restoreFree, restoreOccupied; `test-standing` slab edge, floors, a leaver on the same tick and an elevated row, `test-rehello` and `test-stuck` updated; physics-3d `test-coaxial-escape`. |
5297
5318
  | 2026-11-10 | `hub.loadingCover` copy and timing: a return's cover (backgrounded 30 s or more, or a dropped connection, after the first load lifted) is plain black, with no title, words or spinner, while hidden and for its first 2.5 s after the page shows; then it says "Reconnecting…" with the spinner. The first load keeps the deck title. The multiplayer-3d kit's return cover is quiet for the same 2.5 s. Most returns are back sooner (measured 2.1-2.4 s past a 180 s app switch). No wire change. Within `hub.contract: 1`. |
5298
5319
  | 2026-11-10 | Kit-internal, no deck-facing key or API: a connection that comes back under a new player id on the same page (a drop past the place's hold, such as 180 s backgrounded) keeps the camera yaw and the avatar's facing through the new session's `hub-arrived`, instead of turning to the arrival facing (the Town turned every such return to its spawn bearing). A trip's arrival, the first join and an arrival on another connection face as before. Within `hub.contract: 1`. |
5299
5320
  | 2026-11-05 | Kit-internal, no deck-facing key or API: a frame stall is not an away (amends v1.169's rule). The multiplayer resume gate also arms on frames that stopped for over 1 s on a visible page with the socket connected, as a low-memory phone's do while it loads a place. A `hub-go` or tagged `hub-end` met under such a gate now counts as met online, and the trip or end goes as it always did. It still counts as met while away when the connection dropped during the away, the transport is not connected, the page is or was hidden since the away began, or the away has lasted 5 s (`STALL_AWAY_MS`, the multiplayer kit's own line between a frame hitch and an away). The first room split's `hub.go(nux)`, sent about 4 s after the join inside the loading window, was dropped on such phones as 'fired while offline', and the Town's 45 s wait then kept the player in the Town (repro on a moto e22, Nov 5). Limit: an app switch under 5 s on a page that fires no `visibilitychange` and keeps its socket counts as online. Within `hub.contract: 1`. |
@@ -963,7 +963,7 @@ for (const back of [true, false]) {
963
963
  'const pickerFree = idle && place !== null && !this.talk.talking() && !this.carded;',
964
964
  'scene.data?.engine?.hubInviteRail !== true || Hub.hub.place !== place || Boolean(place.result) || this.talk.talking() || this.carded ||',
965
965
  // Optional pad readability only reads the card state to hide its caption.
966
- 'this.carded || this.decor?.opened() === true);',
966
+ 'this.carded || this.decor?.opened() === true, selfId != null && Hub.hub.guests?.has?.(selfId) === true);',
967
967
  'if (this.ballot) {',
968
968
  'this.ballot.dispose();',
969
969
  'this.ballot = null;',
@@ -960,10 +960,34 @@ await test('a place behind a door whose server is replaced under a player: left
960
960
  system.lastNet = closedNet();
961
961
  system.watchSession(scene, scene.multiplayer);
962
962
  assert.ok(system.trip, `${place.title}: on its way back`);
963
+ assert.equal(system.toast.text, place.result
964
+ ? 'The game ended'
965
+ : `${place.title} closed while you were away. Back to Town…`);
963
966
  system.stepTrip(scene, scene.multiplayer, null, performance.now());
964
967
  assert.equal(covers[0], 1, `${place.title}: the first cover drawn is fully down`);
965
968
  await flush();
966
969
  }
970
+ // An owner's House torn down while they were away (empty past its reconnect
971
+ // window): the line says it closed, not that it was updated; with no title
972
+ // or no ticket it still reads true.
973
+ for (const [place, tickets, text] of [
974
+ [{ title: 'House' }, undefined, 'House closed while you were away. Back to Town…'],
975
+ [{ title: null }, undefined, 'This place closed while you were away. Back to Town…'],
976
+ [{ title: 'House' }, [], 'House closed while you were away. Going back…'],
977
+ ]) {
978
+ const { system, scene } = setup();
979
+ scene.multiplayer = { ...mpStub(scene), net: null, returning: () => true };
980
+ scene.multiplayer.target = { mode: 'hub', handoff: { sessionId: 'house-1' } };
981
+ scene.persistent.hubDepth = 1;
982
+ scene.persistent.hubTickets = tickets ?? [{ scene: 'scenes/main.scene', title: 'Town', door: 'home', hub: true, join: { mode: 'public' } }];
983
+ HubState.hub.place = place;
984
+ answers.back = handoff();
985
+ system.lastNet = closedNet();
986
+ system.watchSession(scene, scene.multiplayer);
987
+ assert.equal(system.toast.text, text);
988
+ assert.ok(system.trip, 'on its way back');
989
+ await flush();
990
+ }
967
991
  // Not returning: the beat plays, and the cover comes down over it.
968
992
  {
969
993
  const { system, scene } = setup();
@@ -80,6 +80,22 @@ assert.equal(padContextText({ cue: named, on: true }).secondary, '');
80
80
  assert.equal(padContextText({ cue: { ...named, door: false }, on: false }).secondary, '');
81
81
  assert.equal(padContextText({ cue: { ...named, title: undefined }, on: true }), null);
82
82
  assert.equal(padContextText(null), null);
83
+ // v1.217: a guest at a cabinet's pad is told to sign in, near it or on it.
84
+ const cabDoor = actor('cab-actor', { HubDoor: { id: 'cab', title: 'Daily Chicken', kind: 'cabinet' } });
85
+ const cabPad = actor('cab-pad', { Transform: { x: 0, y: 0.1, z: 0 }, HubPad: { door: 'cab', radius: 0.85 } });
86
+ const [cabCue] = cues([cabPad, cabDoor]);
87
+ assert.equal(cabCue.cabinet, true);
88
+ assert.equal(cabCue.title, 'Daily Chicken');
89
+ assert.equal(cues([a, door])[0].cabinet, false, 'an ordinary door is not a cabinet');
90
+ assert.equal(padContextText({ cue: cabCue, on: false }).secondary, 'Step on to join', 'a signed-in player is invited as before');
91
+ assert.equal(padContextText({ cue: cabCue, on: false }, true).secondary, 'Sign in to play');
92
+ assert.equal(padContextText({ cue: cabCue, on: true }, true).secondary, 'Sign in to play');
93
+ assert.equal(padContextText({ cue: named, on: false }, true).secondary, 'Step on to join', 'a guest at an ordinary door is invited as before');
94
+ const kindTracker = makePadCueTracker();
95
+ assert.equal(kindTracker.frame([cabPad, cabDoor], new Set(), body(0)).cue.cabinet, true);
96
+ cabDoor.components.HubDoor.kind = undefined;
97
+ assert.equal(kindTracker.frame([cabPad, cabDoor], new Set(), body(0)).cue.cabinet, false, 'a door kind edit is seen without a new actor');
98
+ cabDoor.components.HubDoor.kind = 'cabinet';
83
99
 
84
100
  // Actual enable gate: even accessing options would create client resources.
85
101
  const forbidden = new Proxy({}, { get() {throw new Error('disabled path touched a resource');} });
@@ -251,6 +267,29 @@ chrome.safeSurface('invite-dialog', panel, 'card');
251
267
  chrome.setPadContext(text);
252
268
  assert.equal(caption.style.visibility, 'hidden', 'any registered open panel hides the caption');
253
269
  chrome.safeSurface('invite-dialog', null);
270
+ // v1.217: an open cabinet board hides the caption and is opaque; the chip
271
+ // does neither.
272
+ {
273
+ const cab = dom.made.find((n) => n.dataset.hub === 'cabinet');
274
+ cab.size = { w: 204, h: 275 };
275
+ const item = { id: 'cab', rev: 1, card: { title: 'Batting day', label: 'Daily kills', top: [{ username: 'bo', score: 12 }] }, x: 300, y: 300, opacity: 1 };
276
+ chrome.setCabinet(item, () => null);
277
+ assert.equal(cab.dataset.drawn, 'chip');
278
+ chrome.setPadContext(text);
279
+ assert.equal(caption.style.visibility, '', 'a chip leaves the caption alone');
280
+ assert.equal(cab.style.background, 'rgba(18,14,24,0.92)', 'the chip keeps its paint');
281
+ cab.handlers.pointerdown({ stopPropagation() {} });
282
+ chrome.setCabinet(item, () => null);
283
+ assert.equal(cab.dataset.drawn, 'board');
284
+ chrome.setPadContext(text);
285
+ assert.equal(caption.style.visibility, 'hidden', 'an open board hides the plate');
286
+ assert.equal(cab.style.background, 'rgb(18,14,24)', 'an open board is opaque: no label shows through');
287
+ cab.handlers.pointerdown({ stopPropagation() {} });
288
+ chrome.setCabinet(item, () => null);
289
+ chrome.setPadContext(text);
290
+ assert.equal(caption.style.visibility, '', 'closing the board brings the plate back');
291
+ chrome.setCabinet(null, () => null);
292
+ }
254
293
  // Exact phone viewports use the shared final-rectangle placement, including
255
294
  // action rails, joystick space, HUD and both host-reserved corners.
256
295
  const overlaps = (a, b) => a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;