castle-web-cli 0.4.238 → 0.4.240
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.
- package/dist/agent.js +5 -1
- package/dist/api.d.ts +20 -0
- package/dist/api.js +57 -0
- package/dist/bundle.d.ts +38 -1
- package/dist/bundle.js +309 -13
- package/dist/castle-host/host.js +218 -11
- package/dist/castleJson.d.ts +10 -0
- package/dist/castleJson.js +46 -2
- package/dist/check.js +5 -2
- package/dist/devSessionServer.js +4 -1
- package/dist/devSessionStorage.d.ts +1 -0
- package/dist/devSessionStorage.js +32 -7
- package/dist/importOrder.d.ts +2 -0
- package/dist/importOrder.js +29 -0
- package/dist/index.js +22 -3
- package/dist/init.js +24 -2
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +4 -2
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +12 -3
- package/dist/resetLeaderboards.d.ts +8 -1
- package/dist/resetLeaderboards.js +43 -8
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.d.ts +32 -2
- package/dist/save-deck.js +240 -39
- package/kits/base/CLAUDE.md +2 -1
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +240 -8
- package/kits/base/sdk/analytics.d.ts +8 -0
- package/kits/base/sdk/analytics.js +92 -0
- package/kits/base/sdk/castle.d.ts +8 -2
- package/kits/base/sdk/castle.js +3 -0
- package/kits/base/sdk/commands.d.ts +79 -0
- package/kits/base/sdk/commands.js +1 -0
- package/kits/base/sdk/debugConsole.d.ts +17 -0
- package/kits/base/sdk/debugConsole.js +154 -0
- package/kits/base/sdk/experiments.js +24 -1
- package/kits/base/sdk/hostRetry.d.ts +7 -0
- package/kits/base/sdk/hostRetry.js +57 -0
- package/kits/base/sdk/hub.d.ts +20 -2
- package/kits/base/sdk/hub.js +99 -13
- package/kits/base/sdk/multiplayer.d.ts +2 -0
- package/kits/base/sdk/multiplayer.js +198 -26
- package/kits/base/sdk/reconnectBudget.d.ts +6 -0
- package/kits/base/sdk/reconnectBudget.js +41 -1
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- package/kits/base/sdk/runtime.js +36 -19
- package/kits/base/sdk/server/hub.d.ts +19 -0
- package/kits/base/sdk/server/hub.js +12 -0
- package/kits/base/sdk/server/platformHandle.d.ts +1 -0
- package/kits/base/sdk/server/wrapper.d.ts +1 -1
- package/kits/base/sdk/server/wrapper.js +26 -1
- package/kits/base/sdk/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -1
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +35 -0
- package/kits/hub-game/CLAUDE.md +66 -19
- package/kits/hub-game/castle.json +4 -4
- package/kits/hub-game/code/client/act.js +9 -6
- package/kits/hub-game/code/client/actCore.js +26 -6
- package/kits/hub-game/code/client/actGateLog.js +36 -0
- package/kits/hub-game/code/client/actionOverflow.js +29 -8
- package/kits/hub-game/code/client/actionRailSurface.js +186 -0
- package/kits/hub-game/code/client/actionRailTree.js +173 -0
- package/kits/hub-game/code/client/askSurface.js +85 -0
- package/kits/hub-game/code/client/askTree.js +51 -0
- package/kits/hub-game/code/client/attention.js +31 -6
- package/kits/hub-game/code/client/ballot.js +42 -5
- package/kits/hub-game/code/client/ballotSurface.js +115 -0
- package/kits/hub-game/code/client/ballotTree.js +180 -0
- package/kits/hub-game/code/client/catchingUp.js +19 -0
- package/kits/hub-game/code/client/celebrate.js +66 -0
- package/kits/hub-game/code/client/chrome.js +474 -53
- package/kits/hub-game/code/client/companion.js +93 -23
- package/kits/hub-game/code/client/companionDress.js +1 -1
- package/kits/hub-game/code/client/cornerSurface.js +106 -0
- package/kits/hub-game/code/client/cornerTree.js +83 -0
- package/kits/hub-game/code/client/decor.js +20 -11
- package/kits/hub-game/code/client/deviceStorage.js +121 -0
- package/kits/hub-game/code/client/disguise.js +23 -0
- package/kits/hub-game/code/client/disguiseDraw.js +87 -0
- package/kits/hub-game/code/client/dockSurface.js +206 -0
- package/kits/hub-game/code/client/dockTree.js +232 -0
- package/kits/hub-game/code/client/earned.js +29 -0
- package/kits/hub-game/code/client/emoteSurface.js +188 -0
- package/kits/hub-game/code/client/emoteTree.js +264 -0
- package/kits/hub-game/code/client/farAvatars.js +4 -3
- package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
- package/kits/hub-game/code/client/grab.js +121 -50
- package/kits/hub-game/code/client/holdShow.js +19 -0
- package/kits/hub-game/code/client/hookLayer.js +96 -12
- package/kits/hub-game/code/client/hubControls.js +7 -1
- package/kits/hub-game/code/client/hudSurface.js +11 -3
- package/kits/hub-game/code/client/hudTree.js +7 -4
- package/kits/hub-game/code/client/idle.js +21 -3
- package/kits/hub-game/code/client/invites.js +24 -3
- package/kits/hub-game/code/client/keys.js +15 -0
- package/kits/hub-game/code/client/labelsNear.js +8 -1
- package/kits/hub-game/code/client/layoutCache.js +57 -8
- package/kits/hub-game/code/client/loadingCover.js +53 -4
- package/kits/hub-game/code/client/menuIcons.js +15 -0
- package/kits/hub-game/code/client/menuRows.js +8 -2
- package/kits/hub-game/code/client/menuSurface.js +102 -0
- package/kits/hub-game/code/client/menuTree.js +135 -0
- package/kits/hub-game/code/client/modelLook.js +41 -0
- package/kits/hub-game/code/client/pickerSurface.js +152 -0
- package/kits/hub-game/code/client/pickerTree.js +163 -0
- package/kits/hub-game/code/client/pushVisit.js +4 -2
- package/kits/hub-game/code/client/quality.js +188 -29
- package/kits/hub-game/code/client/qualityEntry.js +10 -1
- package/kits/hub-game/code/client/quickChatSurface.js +222 -0
- package/kits/hub-game/code/client/quickChatTree.js +201 -0
- package/kits/hub-game/code/client/rehello.js +75 -0
- package/kits/hub-game/code/client/renderVisibility.js +17 -0
- package/kits/hub-game/code/client/replay.js +118 -0
- package/kits/hub-game/code/client/role.js +3 -0
- package/kits/hub-game/code/client/safeLayout.js +441 -56
- package/kits/hub-game/code/client/safeStyle.js +13 -10
- package/kits/hub-game/code/client/say.js +2 -0
- package/kits/hub-game/code/client/soundSurface.js +77 -0
- package/kits/hub-game/code/client/soundTree.js +74 -0
- package/kits/hub-game/code/client/soundscape.js +12 -9
- package/kits/hub-game/code/client/soundscapeCues.js +1 -1
- package/kits/hub-game/code/client/state.js +67 -1
- package/kits/hub-game/code/client/stuckSurface.js +76 -0
- package/kits/hub-game/code/client/stuckTree.js +67 -0
- package/kits/hub-game/code/client/talk.js +42 -12
- package/kits/hub-game/code/client/talkTree.js +4 -2
- package/kits/hub-game/code/client/textAskSurface.js +147 -0
- package/kits/hub-game/code/client/textAskTree.js +67 -0
- package/kits/hub-game/code/client/tiers.js +252 -27
- package/kits/hub-game/code/client/together.js +4 -1
- package/kits/hub-game/code/client/uiDom.js +86 -8
- package/kits/hub-game/code/client/uiTree.js +33 -4
- package/kits/hub-game/code/client/vehicle.js +75 -52
- package/kits/hub-game/code/client/weakestTier.js +75 -31
- package/kits/hub-game/code/client/wear.js +159 -5
- package/kits/hub-game/code/client/worldLabels.js +215 -26
- package/kits/hub-game/code/companionSpec.js +4 -2
- package/kits/hub-game/code/server/act.js +3 -0
- package/kits/hub-game/code/server/actGate.js +83 -0
- package/kits/hub-game/code/server/actions.js +71 -15
- package/kits/hub-game/code/server/actors.js +20 -5
- package/kits/hub-game/code/server/analytics.js +40 -15
- package/kits/hub-game/code/server/ask.js +39 -3
- package/kits/hub-game/code/server/ballot.js +167 -4
- package/kits/hub-game/code/server/celebrate.js +64 -0
- package/kits/hub-game/code/server/companion.js +17 -2
- package/kits/hub-game/code/server/decor.js +11 -2
- package/kits/hub-game/code/server/disguise.js +63 -0
- package/kits/hub-game/code/server/doorAnalytics.js +2 -5
- package/kits/hub-game/code/server/earned.js +6 -2
- package/kits/hub-game/code/server/friendBests.js +13 -4
- package/kits/hub-game/code/server/friendsAmong.js +67 -8
- package/kits/hub-game/code/server/grab.js +12 -2
- package/kits/hub-game/code/server/heldOffers.js +142 -0
- package/kits/hub-game/code/server/holdShow.js +98 -0
- package/kits/hub-game/code/server/hub.js +854 -45
- package/kits/hub-game/code/server/idle.js +110 -9
- package/kits/hub-game/code/server/index.js +9 -0
- package/kits/hub-game/code/server/labels.js +13 -3
- package/kits/hub-game/code/server/loadAbandon.js +2 -5
- package/kits/hub-game/code/server/manifest.js +94 -6
- package/kits/hub-game/code/server/menu.js +26 -3
- package/kits/hub-game/code/server/npcs.js +55 -9
- package/kits/hub-game/code/server/observe.js +67 -6
- package/kits/hub-game/code/server/players.js +8 -1
- package/kits/hub-game/code/server/replay.js +135 -0
- package/kits/hub-game/code/server/storageLimit.js +4 -1
- package/kits/hub-game/code/server/townDay.js +74 -0
- package/kits/hub-game/code/server/trackQueue.js +29 -0
- package/kits/hub-game/code/server/vehicle.js +3 -0
- package/kits/hub-game/code/server/vis.js +26 -4
- package/kits/hub-game/code/server/wallet.js +677 -0
- package/kits/hub-game/code/server/wear.js +13 -3
- package/kits/hub-game/code/server/writerLease.js +191 -0
- package/kits/hub-game/code/shared/act.js +1 -1
- package/kits/hub-game/code/shared/expression.js +6 -0
- package/kits/hub-game/code/shared/replay.js +37 -0
- package/kits/hub-game/code/systems/hub.js +437 -57
- package/kits/hub-game/docs/analytics.md +20 -3
- package/kits/hub-game/docs/contract.md +942 -99
- package/kits/hub-game/docs/home-pieces.md +5 -6
- package/kits/hub-game/docs/observed-progress.md +49 -1
- package/kits/hub-game/docs/vehicle-preset.md +23 -0
- package/kits/hub-game/index.html +1 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
- package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
- package/kits/hub-game/models/hats/cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/captain.pxmodel +3 -3
- package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
- package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
- package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
- package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
- package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
- package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
- package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
- package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
- package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
- package/kits/hub-game/models/hats/straw.pxmodel +3 -3
- package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
- package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
- package/kits/hub-game/models/hats/witch.pxmodel +3 -3
- package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
- package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
- package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
- package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
- package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
- package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
- package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
- package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
- package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
- package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
- package/kits/hub-game/package-lock.json +3 -3
- package/kits/hub-game/package.json +4 -3
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
- package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
- package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
- package/kits/hub-game/scripts/gen-hats.mjs +1 -1
- package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
- package/kits/hub-game/scripts/pack.mjs +89 -23
- package/kits/hub-game/scripts/test-act-client.mjs +5 -0
- package/kits/hub-game/scripts/test-act-core.mjs +32 -0
- package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
- package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
- package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
- package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
- package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
- package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
- package/kits/hub-game/scripts/test-actions.mjs +24 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -0
- package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-analytics.mjs +80 -1
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
- package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
- package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
- package/kits/hub-game/scripts/test-attention.mjs +43 -1
- package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
- package/kits/hub-game/scripts/test-ballot.mjs +420 -3
- package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
- package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
- package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
- package/kits/hub-game/scripts/test-chat.mjs +73 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
- package/kits/hub-game/scripts/test-companion.mjs +110 -3
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
- package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
- package/kits/hub-game/scripts/test-decor.mjs +27 -0
- package/kits/hub-game/scripts/test-device-class.mjs +4 -1
- package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
- package/kits/hub-game/scripts/test-disguise.mjs +176 -0
- package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
- package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
- package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
- package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
- package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
- package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
- package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
- package/kits/hub-game/scripts/test-grab.mjs +10 -1
- package/kits/hub-game/scripts/test-hats.mjs +28 -0
- package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
- package/kits/hub-game/scripts/test-high-only.mjs +3 -3
- package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
- package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
- package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +147 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +260 -5
- package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
- package/kits/hub-game/scripts/test-idle.mjs +160 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
- package/kits/hub-game/scripts/test-labels.mjs +11 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
- package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
- package/kits/hub-game/scripts/test-manifest.mjs +27 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +55 -6
- package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
- package/kits/hub-game/scripts/test-npcs.mjs +128 -0
- package/kits/hub-game/scripts/test-observed.mjs +171 -3
- package/kits/hub-game/scripts/test-pack.mjs +166 -0
- package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
- package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
- package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
- package/kits/hub-game/scripts/test-quality.mjs +312 -9
- package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
- package/kits/hub-game/scripts/test-rehello.mjs +237 -0
- package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
- package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
- package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
- package/kits/hub-game/scripts/test-replay.mjs +178 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
- package/kits/hub-game/scripts/test-resync.mjs +13 -0
- package/kits/hub-game/scripts/test-role-client.mjs +10 -3
- package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
- package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
- package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
- package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
- package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
- package/kits/hub-game/scripts/test-stuck.mjs +31 -0
- package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
- package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
- package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
- package/kits/hub-game/scripts/test-tiers.mjs +453 -3
- package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
- package/kits/hub-game/scripts/test-together.mjs +11 -0
- package/kits/hub-game/scripts/test-town-day.mjs +90 -0
- package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
- package/kits/hub-game/scripts/test-try-on.mjs +39 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
- package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +77 -1
- package/kits/hub-game/scripts/test-vis.mjs +145 -0
- package/kits/hub-game/scripts/test-wallet.mjs +650 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
- package/kits/hub-game/scripts/test-world-labels.mjs +380 -0
- package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
- package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
- package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
- package/kits/hub-game/tools/hubScene/export.mjs +6 -5
- package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +48 -2
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +21 -3
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
- package/kits/multiplayer-3d/code/server/ownership.js +25 -6
- package/kits/multiplayer-3d/code/server/world.js +19 -4
- package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
- package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
- package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +10 -2
- package/kits/physics-3d/CLAUDE.md +14 -0
- package/kits/physics-3d/behaviors/Player.jsx +39 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-model-cache.md +109 -0
- package/kits/physics-3d/docs/engine-player.md +76 -0
- package/kits/physics-3d/docs/engine-skip-work.md +16 -0
- package/kits/physics-3d/docs/pxmodel-format.md +5 -1
- package/kits/physics-3d/engine3d/gait.js +16 -8
- package/kits/physics-3d/engine3d/groundsize.js +23 -0
- package/kits/physics-3d/engine3d/kithooks.js +50 -0
- package/kits/physics-3d/engine3d/look.js +110 -17
- package/kits/physics-3d/engine3d/lookbake.js +19 -1
- package/kits/physics-3d/engine3d/materialpresets.js +3 -2
- package/kits/physics-3d/engine3d/modelcache.js +280 -0
- package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
- package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
- package/kits/physics-3d/engine3d/modelrefs.js +13 -0
- package/kits/physics-3d/engine3d/optimize.js +20 -9
- package/kits/physics-3d/engine3d/playerRun.js +26 -1
- package/kits/physics-3d/engine3d/pxmodel.js +7 -3
- package/kits/physics-3d/engine3d/templatecache.js +722 -0
- package/kits/physics-3d/engine3d/world3d.js +211 -17
- package/kits/physics-3d/package-lock.json +1 -1
- package/kits/physics-3d/package.json +2 -1
- package/kits/physics-3d/play/behaviors/Player.js +43 -3
- package/kits/physics-3d/scripts/render.mjs +56 -8
- package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
- package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
- package/kits/physics-3d/scripts/test-gait.mjs +53 -9
- package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
- package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
- package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
- package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
- package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
- package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
- package/kits/physics-3d/systems/physics3d.js +51 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +3 -0
- package/package.json +2 -2
- package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
|
@@ -22,15 +22,21 @@ import * as Blocks from './blocks.js';
|
|
|
22
22
|
import * as Cabinets from './cabinets.js';
|
|
23
23
|
import * as Grab from './grab.js';
|
|
24
24
|
import * as Act from './act.js';
|
|
25
|
+
import * as ActGate from './actGate.js';
|
|
25
26
|
import * as Idle from './idle.js';
|
|
26
27
|
import * as Vehicle from './vehicle.js';
|
|
28
|
+
import * as Disguise from './disguise.js';
|
|
29
|
+
import * as TownDay from './townDay.js';
|
|
30
|
+
import * as Replay from './replay.js';
|
|
27
31
|
import * as Decor from './decor.js';
|
|
28
32
|
import * as Actions from './actions.js';
|
|
29
33
|
import * as Invites from './invites.js';
|
|
30
34
|
import * as Companion from './companion.js';
|
|
31
35
|
import * as Ask from './ask.js';
|
|
32
36
|
import * as Menu from './menu.js';
|
|
37
|
+
import * as HeldOffers from './heldOffers.js';
|
|
33
38
|
import * as Cues from './cues.js';
|
|
39
|
+
import * as Celebrate from './celebrate.js';
|
|
34
40
|
import * as Shot from './shot.js';
|
|
35
41
|
import * as Vis from './vis.js';
|
|
36
42
|
import * as Yours from './yours.js';
|
|
@@ -44,13 +50,16 @@ import * as Say from './say.js';
|
|
|
44
50
|
import * as Ballot from './ballot.js';
|
|
45
51
|
import * as Wear from './wear.js';
|
|
46
52
|
import * as Role from './role.js';
|
|
53
|
+
import * as HoldShow from './holdShow.js';
|
|
47
54
|
import * as Earned from './earned.js';
|
|
48
55
|
import * as Analytics from './analytics.js';
|
|
49
56
|
import * as DoorAnalytics from './doorAnalytics.js';
|
|
50
57
|
import * as LoadAbandon from './loadAbandon.js';
|
|
51
58
|
import * as ResumePose from './resumePose.js';
|
|
59
|
+
import * as WriterLease from './writerLease.js';
|
|
52
60
|
import * as ArrivalPose from './arrivalPose.js';
|
|
53
61
|
import * as Observe from './observe.js';
|
|
62
|
+
import * as Wallet from './wallet.js';
|
|
54
63
|
import { makeAnonymousEntry } from './anonymousEntry.js';
|
|
55
64
|
import { doorPoint } from '../client/doorFrame.js';
|
|
56
65
|
|
|
@@ -198,17 +207,30 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
198
207
|
...(manifest.act === true || Object.values(manifest.places).some(place => place.resumeArrivalPose === true) ? {
|
|
199
208
|
departed(session, player) {
|
|
200
209
|
if (h.manifest.act === true) {Act.forget(h, player.playerId);}
|
|
210
|
+
if (h.place?.actGateLog === true) {ActGate.forget(h, player.playerId, userIdOf(h, player.playerId));}
|
|
201
211
|
if (h.place?.resumeArrivalPose !== true || !h.sim || !h.players.has(player.playerId)) {return;}
|
|
202
212
|
h.session = session;
|
|
203
213
|
forget(h, player.playerId);
|
|
204
214
|
},
|
|
205
215
|
} : {}),
|
|
216
|
+
// v1.163: a transport leave ends a player's recording and ghosts at once,
|
|
217
|
+
// even when real-time keeps the body for a rejoin before the next tick.
|
|
218
|
+
// Nothing is held or sent for a player who never had either.
|
|
219
|
+
replayDeparted(session, player) {
|
|
220
|
+
if (h.recordings?.has(player.playerId) || h.replays?.has(player.playerId)) {Replay.forget(h, player.playerId);}
|
|
221
|
+
},
|
|
206
222
|
// v1.138: load-abandoned connections follow the transport's own join,
|
|
207
223
|
// leave and tick (`index.js`), which run before the simulation exists.
|
|
208
|
-
...(manifest.places[Manifest.MAIN_PLACE]?.loadTelemetry === true ? {
|
|
209
|
-
transportJoin(session, player) {
|
|
210
|
-
|
|
211
|
-
|
|
224
|
+
...(manifest.places[Manifest.MAIN_PLACE]?.loadTelemetry === true || Object.values(manifest.places).some(place => place.writerLease === true) ? {
|
|
225
|
+
transportJoin(session, player) {
|
|
226
|
+
if (manifest.places[Manifest.MAIN_PLACE]?.loadTelemetry === true) {LoadAbandon.join(h, session, player?.playerId);}
|
|
227
|
+
syncWriterVisits(h);
|
|
228
|
+
},
|
|
229
|
+
transportLeave(session, player) {
|
|
230
|
+
if (manifest.places[Manifest.MAIN_PLACE]?.loadTelemetry === true) {LoadAbandon.leave(h, player?.playerId);}
|
|
231
|
+
syncWriterVisits(h);
|
|
232
|
+
},
|
|
233
|
+
transportTick() {if (manifest.places[Manifest.MAIN_PLACE]?.loadTelemetry === true) {LoadAbandon.tick(h);}},
|
|
212
234
|
} : {}),
|
|
213
235
|
persist: false,
|
|
214
236
|
poseEvery,
|
|
@@ -216,12 +238,16 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
216
238
|
|
|
217
239
|
sceneFor(session) {
|
|
218
240
|
const previousSession = h.session;
|
|
241
|
+
if (previousSession && previousSession !== session) {Replay.end(h);}
|
|
219
242
|
h.session = session;
|
|
220
243
|
const { id, source } = Place.resolvePlace(session, manifest);
|
|
221
244
|
if (h.manifest.act === true && (h.placeId !== id || previousSession !== session)) {delete h.actPlayers;}
|
|
245
|
+
if (h.placeId !== id || previousSession !== session) {Celebrate.clear(h);}
|
|
222
246
|
h.placeId = id;
|
|
223
247
|
h.place = manifest.places[id];
|
|
224
248
|
h.hooks = placeHooks[id] ?? deckHooks;
|
|
249
|
+
h.writerLease ??= WriterLease.create(session, h.place.writerLease === true);
|
|
250
|
+
syncWriterVisits(h);
|
|
225
251
|
if (h.place.anonymousEntry === true) {
|
|
226
252
|
h.anonymousEntry ??= makeAnonymousEntry();
|
|
227
253
|
} else {
|
|
@@ -264,10 +290,12 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
264
290
|
h.ctx.companion = (playerId, spec) => Companion.set(h, playerId, spec);
|
|
265
291
|
h.ctx.companionDress = true;
|
|
266
292
|
h.ctx.companionPose = true;
|
|
293
|
+
h.ctx.companionShown = true;
|
|
267
294
|
} else {
|
|
268
295
|
delete h.ctx.companion;
|
|
269
296
|
delete h.ctx.companionDress;
|
|
270
297
|
delete h.ctx.companionPose;
|
|
298
|
+
delete h.ctx.companionShown;
|
|
271
299
|
}
|
|
272
300
|
if (h.place.ask === true) {
|
|
273
301
|
h.ctx.ask = (playerId, spec) => Ask.set(h, playerId, spec);
|
|
@@ -294,9 +322,17 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
294
322
|
ready(sim) {
|
|
295
323
|
h.sim = sim;
|
|
296
324
|
h.actors = Scene.readScene(sim.scenePath);
|
|
325
|
+
const marked = new Set((Scene.sceneOptions?.(sim.scenePath)?.actors ?? []).filter((actor) => actor.decor === true).map((actor) => actor.id));
|
|
326
|
+
const decor = new Set(h.actors.filter((actor) => marked.has(actor.id) && classify(actor.components) === 'decor').map((actor) => actor.id));
|
|
297
327
|
if (h.manifest.quality) {
|
|
298
|
-
|
|
299
|
-
|
|
328
|
+
h.qualityDecor = decor;
|
|
329
|
+
delete h.doorDecor;
|
|
330
|
+
} else {
|
|
331
|
+
// v1.197: a deck with no quality block of its own (a game behind a
|
|
332
|
+
// Town's door) names its decor templates apart, in `hubDecorTpl`, so
|
|
333
|
+
// the Town's Low cap can count their copies; an older client ignores it.
|
|
334
|
+
delete h.qualityDecor;
|
|
335
|
+
h.doorDecor = decor.size ? decor : null;
|
|
300
336
|
}
|
|
301
337
|
if (Scene.sceneOptions?.(sim.scenePath)?.engine?.hubPadOccupancy === true) {
|
|
302
338
|
h.padOccupancy = makePadOccupancy(h.actors);
|
|
@@ -330,6 +366,9 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
330
366
|
// read when the player gets a body.
|
|
331
367
|
message(session, player, data) {
|
|
332
368
|
h.session ??= session;
|
|
369
|
+
// v1.179: a keepAway place notes an account change on a player id the
|
|
370
|
+
// moment any of their messages shows it (a hello among them).
|
|
371
|
+
if (h.place?.ballot?.keepAway === true && h.ballotSeen) {Ballot.observe(h, ballotDeps(h), player?.playerId);}
|
|
333
372
|
if (h.place?.fpsTelemetry && data?.k === 'hub-fps') {Analytics.fps(h, session, player, data); return;}
|
|
334
373
|
if (h.place?.loadTelemetry === true && data?.k === 'hub-load') {LoadAbandon.message(h, session, player, data); return;}
|
|
335
374
|
|
|
@@ -374,9 +413,25 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
374
413
|
noTrips(h, session, player);
|
|
375
414
|
return;
|
|
376
415
|
}
|
|
416
|
+
// v1.169: said once, and touches no progress; a stay that comes during a
|
|
417
|
+
// progress read waits for it (`stay`), as one before arrival does.
|
|
418
|
+
if (data?.k === 'hub-stay') {
|
|
419
|
+
stay(h, player, data);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
// v1.173: consumed by the kit in every place, never the place's hook;
|
|
423
|
+
// touches no progress, so it is heard during a progress read too.
|
|
424
|
+
if (data?.k === 'hub-back') {
|
|
425
|
+
backOut(h, player);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
377
428
|
// A reset check is in flight. Old client actions must not recreate the
|
|
378
429
|
// player's deleted progress before the deck has reloaded it.
|
|
379
|
-
|
|
430
|
+
// v1.204: what touches no progress is heard during the read too.
|
|
431
|
+
if (h.players.get(player?.playerId)?.progressReading && !progressFree(h, data)) {
|
|
432
|
+
droppedDuringProgress(h, player.playerId);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
380
435
|
if (data?.k === 'hub-shut') {
|
|
381
436
|
doorShut(h, player, data);
|
|
382
437
|
return;
|
|
@@ -414,7 +469,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
414
469
|
// v1.68: only a place that declares `ballot` knows the message; in any
|
|
415
470
|
// other it goes on to the place's own hooks, as it always did.
|
|
416
471
|
if (h.place?.ballot && data?.k === 'hub-ballot') {
|
|
417
|
-
Ballot.message(h, player, data, h.place.ballot.lines);
|
|
472
|
+
Ballot.message(h, player, data, h.place.ballot.lines, h.place.ballot.keepAway === true ? ballotDeps(h) : undefined);
|
|
418
473
|
return;
|
|
419
474
|
}
|
|
420
475
|
if (data?.k === 'hub-dev-classic') {
|
|
@@ -440,6 +495,11 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
440
495
|
Menu.message(h, player?.playerId, data);
|
|
441
496
|
return;
|
|
442
497
|
}
|
|
498
|
+
// v1.203: advisory only, a stdout line and nothing else.
|
|
499
|
+
if (h.place?.actGateLog === true && data?.k === 'hub-gate') {
|
|
500
|
+
ActGate.message(h, player, data, userIdOf(h, player?.playerId));
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
443
503
|
if (h.manifest.act === true && (data?.k === 'hub-act' || data?.k === 'hub-act-hold')) {
|
|
444
504
|
Act.message(h, player, data, placeAt);
|
|
445
505
|
return;
|
|
@@ -478,8 +538,11 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
478
538
|
logStats(h);
|
|
479
539
|
const dt = h.lastPlaceAt === null ? 0 : Math.min(0.25, (sim.timeMs - h.lastPlaceAt) / 1000);
|
|
480
540
|
h.lastPlaceAt = sim.timeMs;
|
|
541
|
+
Replay.tick(h);
|
|
481
542
|
reconcile(h);
|
|
482
543
|
if (Role.used(h)) { Role.prune(h); }
|
|
544
|
+
if (h.holdShowUsed) { HoldShow.prune(h); }
|
|
545
|
+
if (h.disguiseUsed) {Disguise.prune(h);}
|
|
483
546
|
Friends.tick(h, friendUserIdOf);
|
|
484
547
|
// v1.28: a try-on on a player who went before saying hello goes too.
|
|
485
548
|
if (Wear.tryOnUsed(h)) {
|
|
@@ -491,6 +554,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
491
554
|
}
|
|
492
555
|
retryProgress(h);
|
|
493
556
|
readResults(h);
|
|
557
|
+
releaseSignUpHolds(h);
|
|
494
558
|
arrivals(h);
|
|
495
559
|
if (h.place.visibility === true) {notifyVisibility(h);}
|
|
496
560
|
Vehicle.tick(h, (id, at, face) => placeAt(h, id, at, face));
|
|
@@ -518,7 +582,10 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
518
582
|
// replacement cancels the queued preparation before either hook runs.
|
|
519
583
|
cancelChangedResumeIdentity(h);
|
|
520
584
|
const resumeDeferred = notifyResumes(h, true);
|
|
585
|
+
Replay.tick(h);
|
|
521
586
|
h.hooks.step?.(h.ctx, dt);
|
|
587
|
+
Celebrate.tick(h);
|
|
588
|
+
liftStayHolds(h);
|
|
522
589
|
rememberResumePoses(h);
|
|
523
590
|
if (h.arrivalPoses) {
|
|
524
591
|
for (const [id, entry] of h.players) {
|
|
@@ -536,8 +603,10 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
536
603
|
h.renewShots?.();
|
|
537
604
|
Actors.flushTints(h);
|
|
538
605
|
sendHudOverrides(h);
|
|
539
|
-
// v1.68: nothing in a place that has never shown a choice card.
|
|
540
|
-
|
|
606
|
+
// v1.68: nothing in a place that has never shown a choice card. v1.179:
|
|
607
|
+
// a `ballot.keepAway` place also notes who is here with whom from the
|
|
608
|
+
// start, so a later card can keep an away player's face.
|
|
609
|
+
if (h.ballotState || h.place.ballot?.keepAway === true) {
|
|
541
610
|
Ballot.send(h, ballotDeps(h));
|
|
542
611
|
}
|
|
543
612
|
Actors.applyTunes(h, h.engine?.maxSpeed?.() ?? 12);
|
|
@@ -550,6 +619,8 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
550
619
|
}
|
|
551
620
|
Party.tick(partyDeps(h));
|
|
552
621
|
Wear.sendOverrides(h, blockedPairs(h));
|
|
622
|
+
// v1.183: seats, emotes and holds of a hidden pair, to each who may see them.
|
|
623
|
+
Idle.sendAlone(h, blockedPairs(h));
|
|
553
624
|
// v1.53 earned items: nothing in a place where nobody shows one.
|
|
554
625
|
if (Earned.used(h)) {
|
|
555
626
|
Earned.sendOverrides(h, blockedPairs(h));
|
|
@@ -559,6 +630,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
559
630
|
Wear.sendTryOverrides(h, blockedPairs(h));
|
|
560
631
|
}
|
|
561
632
|
if (Role.used(h)) { Role.sendOverrides(h, blockedPairs(h)); }
|
|
633
|
+
if (h.holdShowUsed) { HoldShow.sendOverrides(h, blockedPairs(h)); }
|
|
562
634
|
// Cabinet cards (v1.7): nothing in a place with no classic door.
|
|
563
635
|
Cabinets.send(h, (playerId) => namesOf(h, blockedPairs(h)?.get(playerId) ?? []));
|
|
564
636
|
notifyResumes(h, false, resumeDeferred);
|
|
@@ -623,6 +695,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
623
695
|
},
|
|
624
696
|
|
|
625
697
|
allowPlayerPose: (id) => !Vehicle.riding(h, id),
|
|
698
|
+
stalePose: (sim, id, point) => stalePose(h, sim, id, point),
|
|
626
699
|
shutdown: () => shutdown(h),
|
|
627
700
|
|
|
628
701
|
join() {
|
|
@@ -637,25 +710,30 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
637
710
|
...avatarColorsForJoin(h),
|
|
638
711
|
...wearingForJoin(h),
|
|
639
712
|
...(h.place.companion === true && h.companionUsed ? { hubGlow: Companion.glowOf(h) } : {}),
|
|
713
|
+
...(h.place.companion === true && h.companionShownUsed ? { hubChirp: Companion.chirpOf(h) } : {}),
|
|
640
714
|
// v1.53, only once someone here shows an earned item.
|
|
641
715
|
...(h.earned.size > 0 ? earnedForJoin(h) : {}),
|
|
642
716
|
hud: hudForAll(h),
|
|
643
717
|
hidden: [...h.hidden],
|
|
644
|
-
held:
|
|
718
|
+
held: Idle.heldShared(h, blockedPairs(h)),
|
|
645
719
|
labels: labelsForAll(h),
|
|
646
720
|
tints: Actors.tintsOf(h),
|
|
647
721
|
marks: Actors.marksOf(h),
|
|
648
722
|
hubDoors: doorList(h),
|
|
649
723
|
spawned: Actors.spawnedOf(h),
|
|
650
724
|
spawnTemplates: Actors.templatesOf(h),
|
|
725
|
+
// v1.197, only while a copy of a decor template is alive.
|
|
726
|
+
...(Actors.doorDecorOf(h).length ? { hubDecorTpl: Actors.doorDecorOf(h) } : {}),
|
|
651
727
|
// v1.6, only in a place that turns idle play on.
|
|
652
|
-
...Idle.fields(h),
|
|
728
|
+
...Idle.fields(h, blockedPairs(h)),
|
|
653
729
|
...Vehicle.fields(h),
|
|
730
|
+
...Disguise.fields(h),
|
|
654
731
|
// v1.27, only once the place keeps an object for a player.
|
|
655
732
|
...(h.keptFor.size > 0 ? { hubKept: Grab.keptOf(h) } : {}),
|
|
656
733
|
// v1.28, only while the place shows a try-on on someone.
|
|
657
734
|
...(h.trying.size > 0 ? tryingForJoin(h) : {}),
|
|
658
735
|
...(h.roles.size > 0 ? rolesForJoin(h) : {}),
|
|
736
|
+
...(h.holdShowUsed ? { hubHoldShow: HoldShow.fields(h, blockedPairs(h)) } : {}),
|
|
659
737
|
// v1.33, only a town of a deck with `hub.stuck`.
|
|
660
738
|
...(stuckHere(h) ? { hubStuck: { to: arrivalName(h), ...(hasUnstick(h) ? { hook: true } : {}) } } : {}),
|
|
661
739
|
};
|
|
@@ -673,23 +751,31 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
673
751
|
if (h.place.companion === true && h.companionUsed) {
|
|
674
752
|
latch(h, 'hubGlow', Companion.glowOf(h), out);
|
|
675
753
|
}
|
|
754
|
+
if (h.place.companion === true && h.companionShownUsed) {
|
|
755
|
+
latch(h, 'hubChirp', Companion.chirpOf(h), out);
|
|
756
|
+
}
|
|
676
757
|
// v1.53: nothing until someone shows an earned item, then each change.
|
|
677
758
|
if (h.earned.size > 0 || h.sent.has('hubEarned')) {
|
|
678
759
|
latchEarned(h, out);
|
|
679
760
|
}
|
|
680
761
|
latch(h, 'hud', hudForAll(h), out);
|
|
681
762
|
latch(h, 'hidden', [...h.hidden], out);
|
|
682
|
-
latch(h, 'held',
|
|
763
|
+
latch(h, 'held', Idle.heldShared(h, blockedPairs(h)), out);
|
|
683
764
|
latch(h, 'labels', labelsForAll(h), out);
|
|
684
765
|
latch(h, 'tints', Actors.tintsOf(h), out);
|
|
685
766
|
latch(h, 'marks', Actors.marksOf(h), out);
|
|
686
767
|
latch(h, 'hubDoors', doorList(h), out);
|
|
687
768
|
latch(h, 'spawnTemplates', Actors.templatesOf(h), out);
|
|
769
|
+
// v1.197: nothing until a decor template has a copy, then each change.
|
|
770
|
+
if (Actors.doorDecorOf(h).length || h.sent.has('hubDecorTpl')) {
|
|
771
|
+
latch(h, 'hubDecorTpl', Actors.doorDecorOf(h), out);
|
|
772
|
+
}
|
|
688
773
|
latch(h, 'spawned', Actors.spawnedOf(h), out);
|
|
689
|
-
for (const [field, value] of Object.entries(Idle.fields(h))) {
|
|
774
|
+
for (const [field, value] of Object.entries(Idle.fields(h, blockedPairs(h)))) {
|
|
690
775
|
latch(h, field, value, out);
|
|
691
776
|
}
|
|
692
777
|
if (h.cars?.size || h.sent.has('hubCars')) {latch(h, 'hubCars', Vehicle.fields(h).hubCars ?? {}, out);}
|
|
778
|
+
if (h.disguiseUsed || h.sent.has('hubDisguise')) {latch(h, 'hubDisguise', Disguise.fields(h).hubDisguise, out);}
|
|
693
779
|
// v1.27 `hub.keepFor`: nothing until something is kept, then each change.
|
|
694
780
|
if (h.keptFor.size > 0 || h.sent.has('hubKept')) {
|
|
695
781
|
latch(h, 'hubKept', Grab.keptOf(h), out);
|
|
@@ -699,6 +785,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
699
785
|
latchTrying(h, out);
|
|
700
786
|
}
|
|
701
787
|
if (h.roles.size > 0 || h.sent.has('hubRole')) { latchRoles(h, out); }
|
|
788
|
+
if (h.holdShowUsed) { latch(h, 'hubHoldShow', HoldShow.fields(h, blockedPairs(h)), out); }
|
|
702
789
|
return Object.keys(out).length ? out : null;
|
|
703
790
|
},
|
|
704
791
|
|
|
@@ -844,6 +931,9 @@ function newState(manifest, savedDeckId) {
|
|
|
844
931
|
whereAt: new Map(),
|
|
845
932
|
// playerId -> { at, facing, until }: bodies kept where a jump put them (`settle`)
|
|
846
933
|
settling: new Map(),
|
|
934
|
+
// playerId -> { at, body, until }: a place's `hub.placeAt` waiting for its
|
|
935
|
+
// client to report from the spot (`stalePose`)
|
|
936
|
+
placed: new Map(),
|
|
847
937
|
// `logStats`: when the window began, the CPU reading then, ticks since
|
|
848
938
|
stats: { at: null, cpu: null, ticks: 0 },
|
|
849
939
|
// playerId -> { avatar, clientAvatar, from, fromDeckId, party, carry, read,
|
|
@@ -908,6 +998,8 @@ function newState(manifest, savedDeckId) {
|
|
|
908
998
|
// what players wear on their avatars (`wear.js`, v1.4)
|
|
909
999
|
...Wear.newWearState(),
|
|
910
1000
|
...Role.newRoleState(),
|
|
1001
|
+
...HoldShow.newHoldShowState(),
|
|
1002
|
+
...Disguise.newDisguiseState(),
|
|
911
1003
|
// earned items players show (`earned.js`, v1.53)
|
|
912
1004
|
...Earned.newEarnedState(),
|
|
913
1005
|
// emotes, seats and sounds (`idle.js`, v1.6)
|
|
@@ -920,10 +1012,25 @@ function newState(manifest, savedDeckId) {
|
|
|
920
1012
|
...Say.newSayState(),
|
|
921
1013
|
};
|
|
922
1014
|
h.ctx = makeContext(h);
|
|
1015
|
+
if (manifest.holdShow === true) {
|
|
1016
|
+
h.ctx.holdShow = (id, spec) => HoldShow.holdShow(h, id, spec);
|
|
1017
|
+
h.ctx.holdShowing = (id) => HoldShow.holdShowing(h, id);
|
|
1018
|
+
}
|
|
923
1019
|
// v1.68: `hub.ballot` only in a deck that declares the card in some place.
|
|
924
1020
|
if (manifest.ballot) {
|
|
925
1021
|
h.ctx.ballot = (playerIds, spec) => Ballot.ballot(h, playerIds, spec);
|
|
926
1022
|
}
|
|
1023
|
+
// v1.185: `hub.wallet` only in a deck that declares one.
|
|
1024
|
+
if (manifest.wallet) {
|
|
1025
|
+
h.wallet = Wallet.createWallet({
|
|
1026
|
+
...manifest.wallet,
|
|
1027
|
+
storage: () => h.session?.storage ?? null,
|
|
1028
|
+
identify: (playerId) => walletIdentity(h, playerId),
|
|
1029
|
+
// A lost writer lease stops this instance's wallet writes too.
|
|
1030
|
+
fence: (userId) => h.writerLease?.api.fence(userId) ?? Promise.resolve(),
|
|
1031
|
+
});
|
|
1032
|
+
h.ctx.wallet = h.wallet.api;
|
|
1033
|
+
}
|
|
927
1034
|
h.npcLabel = (actorId, text, options) => setLabel(h, isSceneActor(h, actorId) ? actorId : null, text, options, true);
|
|
928
1035
|
h.blockedPairs = () => blockedPairs(h);
|
|
929
1036
|
h.npcs = makeNpcs(h);
|
|
@@ -933,6 +1040,9 @@ function newState(manifest, savedDeckId) {
|
|
|
933
1040
|
// The `hub` every deck hook is handed.
|
|
934
1041
|
function makeContext(h) {
|
|
935
1042
|
return {
|
|
1043
|
+
get saves() {
|
|
1044
|
+
return h.writerLease?.api;
|
|
1045
|
+
},
|
|
936
1046
|
get push() {
|
|
937
1047
|
return h.place?.push?.version === 1 ? h.session?.hub?.push : undefined;
|
|
938
1048
|
},
|
|
@@ -947,6 +1057,20 @@ function makeContext(h) {
|
|
|
947
1057
|
const userId = userIdOf(h, playerId);
|
|
948
1058
|
return userId ? h.progressGenerations.get(userId) ?? null : null;
|
|
949
1059
|
},
|
|
1060
|
+
// v1.195: the `resetFences` a place passes to `session.storage.
|
|
1061
|
+
// conditionalWrite` for one or two players here, one per account, from
|
|
1062
|
+
// the markers observed above; null when any is unknown.
|
|
1063
|
+
resetFences(playerIds) {
|
|
1064
|
+
if (!Array.isArray(playerIds) || playerIds.length < 1 || playerIds.length > 2) { return null; }
|
|
1065
|
+
const fences = [];
|
|
1066
|
+
for (const playerId of playerIds) {
|
|
1067
|
+
const userId = userIdOf(h, playerId);
|
|
1068
|
+
const resetGeneration = userId ? h.progressGenerations.get(userId) : undefined;
|
|
1069
|
+
if (!userId || !/^[1-9]\d{0,19}$/.test(userId) || !Number.isSafeInteger(resetGeneration) || resetGeneration < 0 || resetGeneration > 2147483647) { return null; }
|
|
1070
|
+
if (!fences.some((fence) => fence.playerId === userId)) { fences.push({ playerId: userId, resetGeneration }); }
|
|
1071
|
+
}
|
|
1072
|
+
return fences;
|
|
1073
|
+
},
|
|
950
1074
|
progressPending(userId) {
|
|
951
1075
|
return [...h.players.values()].some((entry) => entry.progressReading && (userId === undefined || String(entry.userId) === String(userId)));
|
|
952
1076
|
},
|
|
@@ -967,6 +1091,7 @@ function makeContext(h) {
|
|
|
967
1091
|
return h.sim?.timeMs ?? 0;
|
|
968
1092
|
},
|
|
969
1093
|
goalPositions: true,
|
|
1094
|
+
goalSelf: true,
|
|
970
1095
|
players() {
|
|
971
1096
|
const out = [];
|
|
972
1097
|
for (const [playerId, body] of h.sim?.players ?? []) {
|
|
@@ -995,13 +1120,19 @@ function makeContext(h) {
|
|
|
995
1120
|
signUp.chosenPose = { ...at, facing };
|
|
996
1121
|
if (h.held.get(playerId)?.waiting) {h.held.delete(playerId);}
|
|
997
1122
|
}
|
|
998
|
-
|
|
1123
|
+
const body = h.sim?.players.get(playerId);
|
|
1124
|
+
const from = body ? { ...body.at } : null;
|
|
1125
|
+
const guard = h.placed.get(playerId);
|
|
1126
|
+
placeAt(h, playerId, at, facing);
|
|
1127
|
+
guardPlacement(h, playerId, from, guard);
|
|
999
1128
|
},
|
|
1000
1129
|
// v1.141 observed progress (`docs/observed-progress.md`).
|
|
1001
1130
|
observed: (playerId) => Observe.observed(h, playerId),
|
|
1002
1131
|
station: (id, spec) => Observe.station(h, id, spec),
|
|
1003
1132
|
dwell: (playerId, id) => Observe.dwell(h, playerId, id),
|
|
1004
|
-
|
|
1133
|
+
// v1.190: `{ turnCamera: true }` turns the held player's own avatar to
|
|
1134
|
+
// the held facing now and again at `release`, the way `hub-jumped` does.
|
|
1135
|
+
hold(playerId, at, facingDeg, options) {
|
|
1005
1136
|
if (Vehicle.riding(h, playerId)) {Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));}
|
|
1006
1137
|
const body = h.sim?.players.get(playerId);
|
|
1007
1138
|
if (!body) {
|
|
@@ -1009,14 +1140,18 @@ function makeContext(h) {
|
|
|
1009
1140
|
}
|
|
1010
1141
|
const point = at ? { ...at } : { ...body.at };
|
|
1011
1142
|
const facing = facingDeg === undefined ? body.facing : facingDeg * DEG;
|
|
1012
|
-
|
|
1143
|
+
const turnCamera = options?.turnCamera === true && Number.isFinite(facing);
|
|
1144
|
+
h.held.set(playerId, turnCamera ? { at: point, facing, turnCamera } : { at: point, facing });
|
|
1013
1145
|
Grab.stilled(h, playerId);
|
|
1014
1146
|
placeAt(h, playerId, point, facing);
|
|
1147
|
+
if (turnCamera) {h.session?.send(playerId, { k: 'hub-hold-face', facing });}
|
|
1015
1148
|
},
|
|
1016
1149
|
release(playerId) {
|
|
1017
1150
|
if (Vehicle.riding(h, playerId)) {Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));}
|
|
1018
|
-
|
|
1151
|
+
const held = h.held.get(playerId);
|
|
1152
|
+
if (held?.ground) {Idle.stand(h, playerId);}
|
|
1019
1153
|
h.held.delete(playerId);
|
|
1154
|
+
if (held?.turnCamera) {h.session?.send(playerId, { k: 'hub-hold-face', facing: held.facing });}
|
|
1020
1155
|
},
|
|
1021
1156
|
setHud(spec, playerId) {
|
|
1022
1157
|
const clean = cleanHud(spec);
|
|
@@ -1083,7 +1218,15 @@ function makeContext(h) {
|
|
|
1083
1218
|
drive: (id, car, at) => Vehicle.drive(h, id, car, at, (pid, point, face) => placeAt(h, pid, point, face)),
|
|
1084
1219
|
ride: (id, driver, seat) => Vehicle.ride(h, id, driver, seat, (pid, point, face) => placeAt(h, pid, point, face)),
|
|
1085
1220
|
vehicle: (id) => Vehicle.vehicle(h, id),
|
|
1086
|
-
|
|
1221
|
+
disguise: (id, spec) => Disguise.disguise(h, id, spec),
|
|
1222
|
+
disguised: (id) => Disguise.disguised(h, id),
|
|
1223
|
+
// v1.200: the Town's day (LA midnight), for a game's dailies and streaks.
|
|
1224
|
+
townDay: (nowMs) => TownDay.townDay(nowMs),
|
|
1225
|
+
townDayStart: (day) => TownDay.townDayStart(day),
|
|
1226
|
+
townDayFrom: (stored, nowMs) => TownDay.townDayFrom(stored, nowMs),
|
|
1227
|
+
record: (id, op) => Replay.record(h, id, op),
|
|
1228
|
+
replay: (id, slot, spec) => Replay.replay(h, id, slot, spec),
|
|
1229
|
+
spawn: (fromActorId, at, options) => Actors.spawn(h, fromActorId, at, h.engine, options),
|
|
1087
1230
|
pose: (actorId) => Actors.pose(h, actorId),
|
|
1088
1231
|
reset: (actorId, at) => Actors.reset(h, actorId, at, h.engine),
|
|
1089
1232
|
despawn: (actorId) => Actors.despawn(h, actorId, h.engine),
|
|
@@ -1101,16 +1244,31 @@ function makeContext(h) {
|
|
|
1101
1244
|
emote: (playerId, id) => Idle.emote(h, playerId, id),
|
|
1102
1245
|
...(h.place.idle?.expression ? { emotesFor: (playerId, ids) => Idle.emotesFor(h, playerId, ids) } : {}),
|
|
1103
1246
|
seat: (playerId) => Idle.seat(h, playerId),
|
|
1247
|
+
sitOn: (playerId, seatId) => Idle.sitOn(h, placeAt, playerId, seatId),
|
|
1104
1248
|
sound: (actorId, file, options) => Idle.sound(h, actorId, file, options),
|
|
1105
1249
|
danceIdle: (actorId, options) => Idle.danceIdle(h, actorId, options),
|
|
1106
1250
|
cue: (target, name) => Cues.cue(h, target, name),
|
|
1251
|
+
// The method itself advertises the optional capability; no public field.
|
|
1252
|
+
get celebrate() {
|
|
1253
|
+
return !h.place.result && h.placeId === Manifest.MAIN_PLACE ? (id, spec) => Celebrate.celebrate(h, id, spec, userIdOf) : undefined;
|
|
1254
|
+
},
|
|
1107
1255
|
shot: (playerId, value) => Shot.shot(h, playerId, value),
|
|
1108
1256
|
holding: (playerId) => Grab.holding(h, playerId),
|
|
1109
1257
|
keepFor: (actorId, playerId) => Grab.keepFor(h, actorId, playerId),
|
|
1110
|
-
|
|
1258
|
+
// v1.169: `{ door }` names one player's own door (an action the place
|
|
1259
|
+
// runs when they walk into it); an end their own Act or action press
|
|
1260
|
+
// makes is tagged by the kit itself (`h.acting`).
|
|
1261
|
+
end(playerIds, options) {
|
|
1111
1262
|
const ids = playerIds ?? [...(h.sim?.players.keys() ?? [])];
|
|
1263
|
+
// Only a list of exactly one player is ever a door: the named one, or
|
|
1264
|
+
// the player whose press is running. Everyone, or several, never is.
|
|
1265
|
+
const one = playerIds && ids.length === 1 ? ids[0] : null;
|
|
1266
|
+
const door = one !== null && doorTag(options?.door) ? options.door :
|
|
1267
|
+
one !== null && h.acting?.playerId === one ? h.acting.id : null;
|
|
1268
|
+
// An end for everyone is no one's door, players already let go included.
|
|
1269
|
+
if (!playerIds) {h.stayable?.clear();}
|
|
1112
1270
|
for (const playerId of ids) {
|
|
1113
|
-
end(h, playerId, 'end');
|
|
1271
|
+
end(h, playerId, 'end', door);
|
|
1114
1272
|
}
|
|
1115
1273
|
},
|
|
1116
1274
|
go: (door, playerIds, options) => go(h, door, playerIds, options),
|
|
@@ -1161,6 +1319,11 @@ function queuedResumeHello(h, playerId, known, data, synthetic, signUp, invitedA
|
|
|
1161
1319
|
}
|
|
1162
1320
|
|
|
1163
1321
|
function hello(h, player, data, synthetic = false) {
|
|
1322
|
+
if (data.again !== true) {Replay.forget(h, player.playerId); h.replayDeparting?.delete(player.playerId);}
|
|
1323
|
+
// v1.173: a Back mark belongs to the account that pressed Back.
|
|
1324
|
+
if (h.backing?.has(player.playerId) && h.backing.get(player.playerId).userId !== (userIdOf(h, player.playerId) ?? null)) {
|
|
1325
|
+
h.backing.delete(player.playerId);
|
|
1326
|
+
}
|
|
1164
1327
|
const prepared = prepareResume(h, player.playerId, false);
|
|
1165
1328
|
if (prepared === 'handled') {
|
|
1166
1329
|
return;
|
|
@@ -1301,6 +1464,10 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1301
1464
|
Shot.joinedAfresh(h, player.playerId);
|
|
1302
1465
|
Vis.joinedAfresh(h, player.playerId, userIdOf(h, player.playerId));
|
|
1303
1466
|
Decor.joinedAfresh(h, player.playerId);
|
|
1467
|
+
// v1.180: the owner back on the visit's body lets held offers go again.
|
|
1468
|
+
if (HeldOffers.on(h)) {
|
|
1469
|
+
HeldOffers.replay(h, player.playerId);
|
|
1470
|
+
}
|
|
1304
1471
|
if (h.place.actions === true) {
|
|
1305
1472
|
Actions.joinedAfresh(h, player.playerId);
|
|
1306
1473
|
}
|
|
@@ -1318,9 +1485,10 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1318
1485
|
}
|
|
1319
1486
|
Cabinets.forget(h, player.playerId);
|
|
1320
1487
|
Friends.resend(h, player.playerId);
|
|
1321
|
-
// v1.28: nothing in a place that never sent a try-on to one player alone.
|
|
1488
|
+
// v1.28: nothing in a place that never sent a try-on or wearable to one player alone.
|
|
1322
1489
|
Wear.joinedAfresh(h, player.playerId);
|
|
1323
1490
|
if (Role.used(h) || h.roleAloneUsed) { Role.joinedAfresh(h, player.playerId); }
|
|
1491
|
+
HoldShow.joinedAfresh(h, player.playerId);
|
|
1324
1492
|
// v1.53: likewise its earned items alone, only where someone has one.
|
|
1325
1493
|
if (Earned.used(h)) {
|
|
1326
1494
|
Earned.joinedAfresh(h, player.playerId);
|
|
@@ -1330,6 +1498,9 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1330
1498
|
h.session?.send(player.playerId, { k: 'hub-leaving', text: h.leaving.get(player.playerId) });
|
|
1331
1499
|
}
|
|
1332
1500
|
}
|
|
1501
|
+
// Replacement forgets may resync this account's progress flags. Finish
|
|
1502
|
+
// them before registering the new entry and its required initial read.
|
|
1503
|
+
syncWriterVisits(h);
|
|
1333
1504
|
const progressUser = userIdOf(h, player.playerId) ?? known?.userId ?? null;
|
|
1334
1505
|
let progressState = h.progressStates.get(player.playerId);
|
|
1335
1506
|
if (!progressState || progressState.userId !== progressUser) {
|
|
@@ -1369,6 +1540,7 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1369
1540
|
read: progressState.readLifetime?.phase ?? (continuedProgress ? (known?.read === 'reading' ? 'want' : known?.read) : null) ?? (hub ? 'want' : 'done'),
|
|
1370
1541
|
progressVersion: progressState.version,
|
|
1371
1542
|
progressState,
|
|
1543
|
+
...(known?.protection ? { protection: { ...known.protection, sent: false } } : {}),
|
|
1372
1544
|
...(known?.device !== undefined ? { device: known.device } : {}),
|
|
1373
1545
|
...(h.progressEnabled ? { progressReading: Boolean(progressState.locks.size || accountProgressBlocked(h, progressUser) || (!resumeBeforeProgressRead && progressUser && canReadProgress(h) && typeof h.session?.storage?.playthrough === 'function')) } : {}),
|
|
1374
1546
|
...(resumeBeforeProgressRead ? { progressRefreshPending: true } : {}),
|
|
@@ -1391,6 +1563,8 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1391
1563
|
historyFrom: known?.historyFrom ?? null,
|
|
1392
1564
|
...(h.manifest.yourGames ? { hearts: known?.hearts ?? [], yoursKey: data.again === true ? known?.yoursKey : null } : {}),
|
|
1393
1565
|
ended: known?.ended ?? (last ? last.ended === true : false),
|
|
1566
|
+
// v1.169: a door end is still the player's own door across a hello (the
|
|
1567
|
+
// resume hello comes before their hub-stay).
|
|
1394
1568
|
// v1.72 (I2, I3): only in a resume place, and only once known.
|
|
1395
1569
|
...(resumes && (known?.visitAt ?? last?.visitAt) !== undefined ? { visitAt: known?.visitAt ?? last.visitAt } : {}),
|
|
1396
1570
|
...(resumes && (known?.endWhy ?? last?.endWhy) !== undefined ? { endWhy: known?.endWhy ?? last.endWhy } : {}),
|
|
@@ -1403,6 +1577,12 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1403
1577
|
signUp.colorRev = entry.colorRev;
|
|
1404
1578
|
}
|
|
1405
1579
|
h.players.set(player.playerId, entry);
|
|
1580
|
+
// v1.180: a fresh hello, its entry rebuilt for whoever is on the row,
|
|
1581
|
+
// lifts an ownership block and stamps the hold calls while away land under.
|
|
1582
|
+
if (HeldOffers.on(h) && data.again !== true) {
|
|
1583
|
+
HeldOffers.hello(h, player.playerId);
|
|
1584
|
+
}
|
|
1585
|
+
takeStayable(h, player.playerId, entry, known, data);
|
|
1406
1586
|
if (h.poseStore && !signedUp && !known?.hello && entry.userId) {
|
|
1407
1587
|
// The new socket may say hello before reconciliation observed the old one
|
|
1408
1588
|
// disappear. End only an absent socket belonging to this same account.
|
|
@@ -1413,7 +1593,12 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1413
1593
|
entry.poseReading = true;
|
|
1414
1594
|
void h.poseStore.take(entry.userId, player.playerId).then((pose) => {
|
|
1415
1595
|
const current = h.players.get(player.playerId);
|
|
1416
|
-
if (!current || current.progressState !== entry.progressState || h.resumeDeparting?.has(player.playerId)) {
|
|
1596
|
+
if (!current || current.progressState !== entry.progressState || h.resumeDeparting?.has(player.playerId)) {
|
|
1597
|
+
// A discarded read still ends the wait: arrivals hold the whole
|
|
1598
|
+
// group while any entry reads its pose.
|
|
1599
|
+
if (current === entry) {current.poseReading = false;}
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1417
1602
|
current.coldPose = pose;
|
|
1418
1603
|
current.poseReading = false;
|
|
1419
1604
|
});
|
|
@@ -1494,7 +1679,10 @@ async function refreshProgress(h, playerId) {
|
|
|
1494
1679
|
const newer = Number.isSafeInteger(generation) && generation > (h.progressGenerations.get(userId) ?? 0);
|
|
1495
1680
|
const sameUser = [...h.players].filter(([id]) => userIdOf(h, id) === userId);
|
|
1496
1681
|
const retryFailed = sameUser.some(([, current]) => current.progressState.failure && current.progressState.appliedGeneration < generation);
|
|
1497
|
-
|
|
1682
|
+
// A retry of a failed hook reruns only the ids not yet at this generation:
|
|
1683
|
+
// a sibling whose hook succeeded keeps its side effects once.
|
|
1684
|
+
const targets = newer ? sameUser.filter(([, current]) => current.progressState.resetting?.generation !== generation)
|
|
1685
|
+
: retryFailed ? sameUser.filter(([, current]) => current.progressState.appliedGeneration < generation && current.progressState.resetting?.generation !== generation)
|
|
1498
1686
|
: Number.isSafeInteger(generation) && generation > 0
|
|
1499
1687
|
? sameUser.filter(([, current]) => current.progressState.appliedGeneration < generation && current.progressState.resetting?.generation !== generation)
|
|
1500
1688
|
: [];
|
|
@@ -1516,6 +1704,7 @@ async function refreshProgress(h, playerId) {
|
|
|
1516
1704
|
const targetState = current.progressState;
|
|
1517
1705
|
targetState.markerKnown = true;
|
|
1518
1706
|
targetState.markerBypass = false;
|
|
1707
|
+
delete current.progressReleased;
|
|
1519
1708
|
if (targetState.resetting && targetState.resetting.generation < generation) {
|
|
1520
1709
|
unlock(id, targetState, targetState.resetting);
|
|
1521
1710
|
}
|
|
@@ -1542,7 +1731,9 @@ async function refreshProgress(h, playerId) {
|
|
|
1542
1731
|
delete current.endReplayPending;
|
|
1543
1732
|
Wear.forget(h, id);
|
|
1544
1733
|
Role.forget(h, id);
|
|
1734
|
+
HoldShow.forget(h, id);
|
|
1545
1735
|
Earned.forget(h, id);
|
|
1736
|
+
h.wallet?.reset(userId);
|
|
1546
1737
|
h.npcs.leave(id);
|
|
1547
1738
|
h.hudMe.delete(id);
|
|
1548
1739
|
h.labelsMe.delete(id);
|
|
@@ -1563,11 +1754,16 @@ async function refreshProgress(h, playerId) {
|
|
|
1563
1754
|
await h.hooks.progressReset?.(h.ctx, id, generation, { arrived: current.arrived });
|
|
1564
1755
|
if (h.progressStates.get(id) === targetState && targetState.resetting === reset && h.progressGenerations.get(userId) === generation) {
|
|
1565
1756
|
targetState.appliedGeneration = generation;
|
|
1757
|
+
targetState.hookFailures = 0;
|
|
1566
1758
|
}
|
|
1567
1759
|
} catch {
|
|
1568
1760
|
if (h.progressStates.get(id) === targetState && targetState.resetting === reset && h.progressGenerations.get(userId) === generation) {
|
|
1569
1761
|
targetState.failure = reset;
|
|
1570
1762
|
failed = true;
|
|
1763
|
+
// v1.204: a failed hook is retried on the read's own cadence,
|
|
1764
|
+
// not only at a new hello.
|
|
1765
|
+
targetState.hookFailures = (targetState.hookFailures ?? 0) + 1;
|
|
1766
|
+
targetState.markerRetryAt = Date.now() + Math.min(PROGRESS_RETRY_MS * 2 ** (targetState.hookFailures - 1), PROGRESS_RETRY_MAX_MS);
|
|
1571
1767
|
}
|
|
1572
1768
|
if (!h.progressHookWarned) {
|
|
1573
1769
|
h.progressHookWarned = true;
|
|
@@ -1591,6 +1787,11 @@ async function refreshProgress(h, playerId) {
|
|
|
1591
1787
|
if (h.progressRequests.get(playerId) === request && h.players.get(playerId) === entry) {
|
|
1592
1788
|
if (!state.readFailure) {
|
|
1593
1789
|
state.readFailure = {};
|
|
1790
|
+
// A release let the arrival through, not a failure found after it:
|
|
1791
|
+
// an arrived id takes the ordinary failure protection again.
|
|
1792
|
+
for (const current of h.players.values()) {
|
|
1793
|
+
if (current.arrived && current.userId === state.userId) { delete current.progressReleased; }
|
|
1794
|
+
}
|
|
1594
1795
|
lock(playerId, state, state.readFailure);
|
|
1595
1796
|
}
|
|
1596
1797
|
state.readFailures = (state.readFailures ?? 0) + 1;
|
|
@@ -1621,11 +1822,17 @@ function syncProgressUser(h, userId) {
|
|
|
1621
1822
|
const blocked = accountProgressBlocked(h, userId);
|
|
1622
1823
|
for (const [id, entry] of h.players) {
|
|
1623
1824
|
if (entry.userId === userId) {
|
|
1624
|
-
|
|
1825
|
+
const reading = Boolean((entry.progressState.locks.size && !entry.progressState.markerBypass) || blocked);
|
|
1826
|
+
// A released arrival stays released until this episode settles; a
|
|
1827
|
+
// newer reset clears the release where it starts (`refreshProgress`).
|
|
1828
|
+
if (!reading) { delete entry.progressReleased; }
|
|
1829
|
+
entry.progressReading = reading && !entry.progressReleased;
|
|
1830
|
+
noteProtection(h, id, entry);
|
|
1625
1831
|
if (!entry.progressReading && !entry.progressRefreshPending && entry.endReplayPending) {
|
|
1626
1832
|
delete entry.endReplayPending;
|
|
1627
1833
|
endAgain(h, id);
|
|
1628
1834
|
}
|
|
1835
|
+
stayAfterProgress(h, id);
|
|
1629
1836
|
}
|
|
1630
1837
|
}
|
|
1631
1838
|
}
|
|
@@ -1637,7 +1844,7 @@ function retryProgress(h) {
|
|
|
1637
1844
|
const now = Date.now();
|
|
1638
1845
|
for (const [id, entry] of h.players) {
|
|
1639
1846
|
const state = entry.progressState;
|
|
1640
|
-
if (!state || (state.markerKnown && !state.readFailure)) { continue; }
|
|
1847
|
+
if (!state || (state.markerKnown && !state.readFailure && !state.failure)) { continue; }
|
|
1641
1848
|
if (!state.markerKnown && !state.markerBypass && now - state.markerStartedAt >= PROGRESS_ARRIVAL_WAIT_MS) {
|
|
1642
1849
|
state.markerBypass = true;
|
|
1643
1850
|
console.warn('[hub] progress reset marker unavailable; allowing arrival while retrying');
|
|
@@ -1645,6 +1852,108 @@ function retryProgress(h) {
|
|
|
1645
1852
|
}
|
|
1646
1853
|
if (now >= (state.markerRetryAt ?? Infinity)) { void refreshProgress(h, id); }
|
|
1647
1854
|
}
|
|
1855
|
+
releaseProgressHolds(h, now);
|
|
1856
|
+
for (const [id, entry] of h.players) {
|
|
1857
|
+
if (entry.protection) { noteProtection(h, id, entry, now); }
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
// v1.204: the messages the kit handles itself that write no progress (chat,
|
|
1862
|
+
// party, emotes, seats, travel, where, unstick, the gate log), heard while
|
|
1863
|
+
// an arrived player's progress is read. hub-go carries no progress, and the
|
|
1864
|
+
// destination reads its own marker. Everything else, the place's own hooks
|
|
1865
|
+
// included, waits and is refused visibly (`hub-progress`).
|
|
1866
|
+
function progressFree(h, data) {
|
|
1867
|
+
switch (data?.k) {
|
|
1868
|
+
case 'hub-shut': case 'hub-door-jump': case 'hub-house-visit': case 'hub-where': case 'hub-goto':
|
|
1869
|
+
case 'hub-say': case 'hub-party': case 'hub-dev-classic': case 'hub-emote': case 'hub-stand':
|
|
1870
|
+
return true;
|
|
1871
|
+
case 'hub-unstick': return Boolean(h.manifest.stuck);
|
|
1872
|
+
case 'hub-gate': return h.place?.actGateLog === true;
|
|
1873
|
+
case 'hub-horn': return Boolean(h.cars);
|
|
1874
|
+
case 'hub-sit-here': return Boolean(h.place.idle?.expression);
|
|
1875
|
+
case 'hub-sit': return h.manifest.act !== true;
|
|
1876
|
+
default: return false;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
// An arrived player's action is never dropped silently. A spell of progress
|
|
1881
|
+
// protection on an arrived player is logged on, and then off, once it drops
|
|
1882
|
+
// a message, comes from a failure or reset, or lasts a second; a quick
|
|
1883
|
+
// successful reread stays quiet.
|
|
1884
|
+
const PROTECTION_LOG_MS = 1000;
|
|
1885
|
+
// Past this the client's line says to re-enter, and it is logged once; the
|
|
1886
|
+
// protection itself holds until a read or the reset hook succeeds.
|
|
1887
|
+
const PROTECTION_PAST_MS = 30_000;
|
|
1888
|
+
|
|
1889
|
+
function noteProtection(h, id, entry, now = Date.now()) {
|
|
1890
|
+
if (!entry.arrived || !entry.progressReading) {
|
|
1891
|
+
if (entry.protection) { protectionOff(h, id, entry, ''); }
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
const reason = progressHoldReason(h, entry.userId);
|
|
1895
|
+
entry.protection ??= { since: now, reason, dropped: 0, logged: false };
|
|
1896
|
+
const spell = entry.protection;
|
|
1897
|
+
if (reason !== 'progress-read') { spell.reason = reason; }
|
|
1898
|
+
// v1.204: the client hears at once, so its controls never offer what the
|
|
1899
|
+
// server would refuse.
|
|
1900
|
+
if (!spell.sent) {
|
|
1901
|
+
spell.sent = true;
|
|
1902
|
+
h.session?.send(id, { k: 'hub-progress', catching: true });
|
|
1903
|
+
}
|
|
1904
|
+
if (!spell.logged && (spell.dropped || spell.reason !== 'progress-read' || now - spell.since >= PROTECTION_LOG_MS)) {
|
|
1905
|
+
spell.logged = true;
|
|
1906
|
+
console.warn(`[hub] progress protection on: ${id} (user ${entry.userId ?? 'guest'}) ${spell.reason}`);
|
|
1907
|
+
}
|
|
1908
|
+
if (!spell.past && now - spell.since >= PROTECTION_PAST_MS) {
|
|
1909
|
+
spell.past = true;
|
|
1910
|
+
console.warn(`[hub] progress protection past 30 s: ${id} (user ${entry.userId ?? 'guest'}) ${spell.reason}`);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
function protectionOff(h, id, entry, why) {
|
|
1915
|
+
const spell = entry.protection;
|
|
1916
|
+
delete entry.protection;
|
|
1917
|
+
if (spell.sent && !why) { h.session?.send(id, { k: 'hub-progress', catching: false }); }
|
|
1918
|
+
// One that settled between ticks after the second still says it was on.
|
|
1919
|
+
if (!spell.logged && Date.now() - spell.since >= PROTECTION_LOG_MS) {
|
|
1920
|
+
spell.logged = true;
|
|
1921
|
+
console.warn(`[hub] progress protection on: ${id} (user ${entry.userId ?? 'guest'}) ${spell.reason}`);
|
|
1922
|
+
}
|
|
1923
|
+
if (spell.logged) {
|
|
1924
|
+
console.warn(`[hub] progress protection off: ${id} (user ${entry.userId ?? 'guest'}) ${spell.reason} after ${Date.now() - spell.since} ms, ${spell.dropped} dropped${why}`);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
function droppedDuringProgress(h, id) {
|
|
1929
|
+
const entry = h.players.get(id);
|
|
1930
|
+
if (!entry?.arrived) { return; }
|
|
1931
|
+
noteProtection(h, id, entry);
|
|
1932
|
+
if (!entry.protection) { return; }
|
|
1933
|
+
entry.protection.dropped += 1;
|
|
1934
|
+
noteProtection(h, id, entry);
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
// No progress state holds an arrival past the same five seconds: a known
|
|
1938
|
+
// marker whose read hangs or keeps failing, and a reset hook that threw or
|
|
1939
|
+
// has not settled, let a player not yet arrived go once, logged with why.
|
|
1940
|
+
// The read and its retries carry on behind; only a newer reset locks again.
|
|
1941
|
+
function releaseProgressHolds(h, now) {
|
|
1942
|
+
for (const entry of h.players.values()) {
|
|
1943
|
+
if (!entry.hello || entry.arrived || !entry.progressReading || entry.progressReleased) { continue; }
|
|
1944
|
+
if (now - Math.max(entry.helloAt, entry.progressState?.markerStartedAt ?? 0) < PROGRESS_ARRIVAL_WAIT_MS) { continue; }
|
|
1945
|
+
entry.progressReleased = true;
|
|
1946
|
+
console.warn(`[hub] arrival hold released after 5 s: ${progressHoldReason(h, entry.userId)}`);
|
|
1947
|
+
syncProgressUser(h, entry.userId);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
function progressHoldReason(h, userId) {
|
|
1952
|
+
const states = [...h.progressStates.values()].filter((state) => state.userId === userId);
|
|
1953
|
+
if (states.some((state) => state.failure)) { return 'progress-reset-failed'; }
|
|
1954
|
+
if (states.some((state) => state.resetting)) { return 'progress-reset'; }
|
|
1955
|
+
if (states.some((state) => state.readFailure)) { return 'progress-read-failed'; }
|
|
1956
|
+
return 'progress-read';
|
|
1648
1957
|
}
|
|
1649
1958
|
|
|
1650
1959
|
// An unsaved local serve has no deck Store or platform reset marker. Its SDK
|
|
@@ -1677,11 +1986,20 @@ function outcomeOrNone(outcome) {
|
|
|
1677
1986
|
return outcome === undefined || outcome === null || Manifest.OUTCOMES.includes(outcome);
|
|
1678
1987
|
}
|
|
1679
1988
|
|
|
1989
|
+
// Storage-capable transport identities, including dev guests, own the lease.
|
|
1990
|
+
// A fresh connection may replace a lost account's held visits only when no
|
|
1991
|
+
// other connection here shares it. Finalize their authored state before join.
|
|
1992
|
+
function syncWriterVisits(h) {
|
|
1993
|
+
if (!h.writerLease?.api.enabled) { return; }
|
|
1994
|
+
h.writerLease.sync((h.session?.players ?? []).map(p => [p.playerId, userIdOf(h, p.playerId)]).filter(([, userId]) => userId !== null), h.players.keys(), playerId => forget(h, playerId));
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1680
1997
|
// Forget players the session no longer has, telling the deck first: its
|
|
1681
1998
|
// `leave` hook runs while the player is still known, so it may report their
|
|
1682
1999
|
// result for the visit (the host takes one for a player who has just left)
|
|
1683
2000
|
// and save their progress under the user id it is handed (v1.2).
|
|
1684
2001
|
function reconcile(h) {
|
|
2002
|
+
syncWriterVisits(h);
|
|
1685
2003
|
// v1.145: before any private channel below can send to a changed account.
|
|
1686
2004
|
if (h.place.resumePose === true && h.place.resumeVisibility !== true) {
|
|
1687
2005
|
clearChangedHeldIdentity(h);
|
|
@@ -1705,6 +2023,10 @@ function reconcile(h) {
|
|
|
1705
2023
|
}
|
|
1706
2024
|
Vis.prune(h);
|
|
1707
2025
|
Decor.prune(h);
|
|
2026
|
+
// v1.180: every hold is checked each tick, before the offers it keeps.
|
|
2027
|
+
if (HeldOffers.on(h)) {
|
|
2028
|
+
HeldOffers.prune(h);
|
|
2029
|
+
}
|
|
1708
2030
|
if (h.place.actions === true) {
|
|
1709
2031
|
Actions.prune(h);
|
|
1710
2032
|
}
|
|
@@ -1868,6 +2190,10 @@ function prepareResume(h, playerId, greet = true) {
|
|
|
1868
2190
|
const body = h.sim?.players.get(playerId);
|
|
1869
2191
|
const present = body && h.session?.players.some((p) => p.playerId === playerId);
|
|
1870
2192
|
const returning = present && (kept.awayAt !== undefined || body !== kept.body);
|
|
2193
|
+
// v1.173: the drop a player's own Back led to is the visit's end.
|
|
2194
|
+
if (!present || returning) {
|
|
2195
|
+
backDropped(h, playerId);
|
|
2196
|
+
}
|
|
1871
2197
|
if (!present) {
|
|
1872
2198
|
if (kept.awayAt === undefined && h.poseStore && !h.resumeDeparting.has(playerId) && !h.players.get(playerId)?.ended) {
|
|
1873
2199
|
void h.poseStore.end(h.players.get(playerId)?.userId, kept, Date.now(), playerId);
|
|
@@ -2169,6 +2495,9 @@ function restartRetainedAsFresh(h, player, entry, data, synthetic) {
|
|
|
2169
2495
|
}
|
|
2170
2496
|
|
|
2171
2497
|
function forget(h, playerId) {
|
|
2498
|
+
parkStayable(h, playerId);
|
|
2499
|
+
Replay.forget(h, playerId);
|
|
2500
|
+
h.replayDeparting?.delete(playerId);
|
|
2172
2501
|
h.vehicleDeparting?.delete(playerId);
|
|
2173
2502
|
h.padOccupancy?.selected.delete(playerId);
|
|
2174
2503
|
const entry = h.players.get(playerId);
|
|
@@ -2178,6 +2507,8 @@ function forget(h, playerId) {
|
|
|
2178
2507
|
h.inviteAt?.delete(playerId);
|
|
2179
2508
|
h.resumePending?.delete(playerId);
|
|
2180
2509
|
h.resumeKept?.delete(playerId);
|
|
2510
|
+
if (!h.session?.players.some((p) => p.playerId === playerId)) {backDropped(h, playerId);}
|
|
2511
|
+
h.backing?.delete(playerId);
|
|
2181
2512
|
const poseDeparting = h.arrivalPoses && h.resumeDeparting?.has(playerId);
|
|
2182
2513
|
h.resumeDeparting?.delete(playerId);
|
|
2183
2514
|
if (entry?.arrived && h.place.analytics === true) {Analytics.leave(h, playerId);}
|
|
@@ -2194,6 +2525,7 @@ function forget(h, playerId) {
|
|
|
2194
2525
|
}
|
|
2195
2526
|
}
|
|
2196
2527
|
Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
|
|
2528
|
+
Disguise.forget(h, playerId);
|
|
2197
2529
|
DoorAnalytics.finish(h, playerId, 3);
|
|
2198
2530
|
if (h.arrivalPoses) {
|
|
2199
2531
|
h.arrivalPoses.leave(playerId, entry?.userId, entry?.arrived === true && !entry.ended && !poseDeparting);
|
|
@@ -2221,14 +2553,20 @@ function forget(h, playerId) {
|
|
|
2221
2553
|
if (h.ballotState) {
|
|
2222
2554
|
Ballot.forget(h, playerId);
|
|
2223
2555
|
}
|
|
2556
|
+
h.ballotSeen?.records.delete(playerId);
|
|
2224
2557
|
Friends.forget(h, playerId);
|
|
2225
2558
|
h.caps.delete(playerId);
|
|
2226
2559
|
h.capAt.delete(playerId);
|
|
2227
2560
|
h.playerCells.delete(playerId);
|
|
2561
|
+
if (entry?.protection) { protectionOff(h, playerId, entry, ' (left)'); }
|
|
2228
2562
|
h.players.delete(playerId);
|
|
2563
|
+
syncWriterVisits(h);
|
|
2229
2564
|
if (entry?.progressState) { entry.progressState.readLifetime = null; }
|
|
2230
2565
|
h.progressStates.delete(playerId);
|
|
2231
2566
|
syncProgressUser(h, entry?.userId);
|
|
2567
|
+
if (h.wallet && entry?.userId) {
|
|
2568
|
+
h.wallet.forget(entry.userId, (userId) => [...h.players.values()].some((other) => other.userId === userId));
|
|
2569
|
+
}
|
|
2232
2570
|
h.held.delete(playerId);
|
|
2233
2571
|
h.hudMe.delete(playerId);
|
|
2234
2572
|
h.sentHudMe.delete(playerId);
|
|
@@ -2241,6 +2579,7 @@ function forget(h, playerId) {
|
|
|
2241
2579
|
h.marks.delete(playerId);
|
|
2242
2580
|
Wear.forget(h, playerId);
|
|
2243
2581
|
Role.forget(h, playerId);
|
|
2582
|
+
HoldShow.forget(h, playerId);
|
|
2244
2583
|
Earned.forget(h, playerId);
|
|
2245
2584
|
h.shut.delete(playerId);
|
|
2246
2585
|
h.noTrips.delete(playerId);
|
|
@@ -2250,8 +2589,10 @@ function forget(h, playerId) {
|
|
|
2250
2589
|
h.unstuckAt?.delete(playerId);
|
|
2251
2590
|
h.unstuckAskAt?.delete(playerId);
|
|
2252
2591
|
h.settling.delete(playerId);
|
|
2592
|
+
h.placed.delete(playerId);
|
|
2253
2593
|
Grab.forget(h, playerId);
|
|
2254
2594
|
if (h.manifest.act === true) {Act.forget(h, playerId);}
|
|
2595
|
+
if (h.place?.actGateLog === true) {ActGate.forget(h, playerId, userIdOf(h, playerId));}
|
|
2255
2596
|
Idle.forget(h, playerId);
|
|
2256
2597
|
Decor.forget(h, playerId);
|
|
2257
2598
|
if (h.place.actions === true) {
|
|
@@ -2266,6 +2607,7 @@ function forget(h, playerId) {
|
|
|
2266
2607
|
if (h.place.menu === true) {
|
|
2267
2608
|
Menu.forget(h, playerId);
|
|
2268
2609
|
}
|
|
2610
|
+
HeldOffers.forget(h, playerId);
|
|
2269
2611
|
if (h.cueBudgets) {
|
|
2270
2612
|
h.cueBudgets.delete(`player:${playerId}`);
|
|
2271
2613
|
}
|
|
@@ -2283,8 +2625,17 @@ function forget(h, playerId) {
|
|
|
2283
2625
|
const SHUTDOWN_DRAIN_MS = 1500;
|
|
2284
2626
|
|
|
2285
2627
|
async function shutdown(h) {
|
|
2628
|
+
Replay.end(h);
|
|
2629
|
+
Celebrate.clear(h);
|
|
2630
|
+
if (h.recordings || h.replays) {h.replayClosed = true;}
|
|
2631
|
+
// A fresh Back is leaving even when no tick saw its drop: let it go before
|
|
2632
|
+
// anything below keeps a pose.
|
|
2633
|
+
for (const playerId of [...(h.backing?.keys() ?? [])]) {
|
|
2634
|
+
backDropped(h, playerId);
|
|
2635
|
+
}
|
|
2286
2636
|
h.arrivalPoses?.shutdown();
|
|
2287
2637
|
if (!h.sim) {
|
|
2638
|
+
h.writerLease?.shutdown();
|
|
2288
2639
|
return;
|
|
2289
2640
|
}
|
|
2290
2641
|
for (const playerId of [...h.players.keys()]) {
|
|
@@ -2298,12 +2649,15 @@ async function shutdown(h) {
|
|
|
2298
2649
|
Wear.endTries(h);
|
|
2299
2650
|
}
|
|
2300
2651
|
Role.end(h);
|
|
2652
|
+
HoldShow.end(h);
|
|
2653
|
+
Disguise.end(h);
|
|
2301
2654
|
let timer = null;
|
|
2302
2655
|
await Promise.race([
|
|
2303
2656
|
Promise.resolve()
|
|
2304
2657
|
.then(async () => {
|
|
2305
2658
|
await h.hooks.shutdown?.(h.ctx);
|
|
2306
2659
|
await h.poseStore?.drain();
|
|
2660
|
+
await h.wallet?.settled();
|
|
2307
2661
|
await Promise.all([...(h.friendBestHelpers?.values() ?? [])].map((helper) => helper.drain()));
|
|
2308
2662
|
})
|
|
2309
2663
|
.catch((err) => console.warn(`[hub] shutdown hook failed: ${err?.message ?? err}`)),
|
|
@@ -2312,6 +2666,7 @@ async function shutdown(h) {
|
|
|
2312
2666
|
}),
|
|
2313
2667
|
]);
|
|
2314
2668
|
clearTimeout(timer);
|
|
2669
|
+
h.writerLease?.shutdown();
|
|
2315
2670
|
}
|
|
2316
2671
|
|
|
2317
2672
|
// Signup carry invariant: ONE terminal function applies allowed guest state
|
|
@@ -2345,6 +2700,21 @@ function finishSignUp(h, playerId, signUp, cancel = false) {
|
|
|
2345
2700
|
}
|
|
2346
2701
|
}
|
|
2347
2702
|
|
|
2703
|
+
// A placed sign-up waits for its account read at most five seconds, then
|
|
2704
|
+
// arrives without it. The read still lands later, but cannot replace the
|
|
2705
|
+
// carried look: that stays the terminal function's alone.
|
|
2706
|
+
function releaseSignUpHolds(h) {
|
|
2707
|
+
const now = Date.now();
|
|
2708
|
+
for (const [playerId, entry] of h.players) {
|
|
2709
|
+
const signUp = entry.signUp;
|
|
2710
|
+
if (!signUp || signUp.finished || !signUp.arrivalSettled || signUp.readSettled || now - signUp.placedAt < PROGRESS_ARRIVAL_WAIT_MS) { continue; }
|
|
2711
|
+
signUp.readSettled = true;
|
|
2712
|
+
if (entry.progressState?.readLifetime) { entry.progressState.readLifetime.keepLook = true; }
|
|
2713
|
+
console.warn('[hub] arrival hold released after 5 s: signup-results');
|
|
2714
|
+
finishSignUp(h, playerId, signUp);
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2348
2718
|
// Players with a body who said hello and have not arrived, placed as groups
|
|
2349
2719
|
// at the arrival (contract §5). A group is everyone who said hello inside one
|
|
2350
2720
|
// window; it is placed when it has as many as its members said were coming,
|
|
@@ -2418,6 +2788,7 @@ function arrivals(h) {
|
|
|
2418
2788
|
if (!signUp) {continue;}
|
|
2419
2789
|
signUp.member = member;
|
|
2420
2790
|
signUp.arrivalSettled = true;
|
|
2791
|
+
signUp.placedAt = Date.now();
|
|
2421
2792
|
const body = h.sim.players.get(member.playerId);
|
|
2422
2793
|
h.held.set(member.playerId, { at: { ...body.at }, facing: body.facing, waiting: true });
|
|
2423
2794
|
finishSignUp(h, member.playerId, signUp);
|
|
@@ -2441,6 +2812,16 @@ function arrivals(h) {
|
|
|
2441
2812
|
const entry = h.players.get(playerId);
|
|
2442
2813
|
if (houseResume(h) && h.session?.hub?.owner && entry?.userId !== h.session.hub.owner) {delete entry.coldPose;}
|
|
2443
2814
|
if (entry?.coldPose && entry.invited && entry.near) {delete entry.coldPose;}
|
|
2815
|
+
// A player ghost placed through a door (a House's Back, a host's trip)
|
|
2816
|
+
// arrives at that door, not where an earlier visit was left standing.
|
|
2817
|
+
if (entry?.coldPose && platformHub(h)?.arrival(playerId)?.doorId) {delete entry.coldPose;}
|
|
2818
|
+
// Nor back onto a door's pad (v1.19's rule for every placement): a pose
|
|
2819
|
+
// stored as they left standing on one put them back on it, and the pad
|
|
2820
|
+
// took them into its game -- Oct 7, a late join into the Lantern Lot with
|
|
2821
|
+
// whoever was inside. They arrive where the arrival put them instead.
|
|
2822
|
+
// Nor beside one: a pose left within COLD_POSE_PAD_CLEAR_M of a pad's edge
|
|
2823
|
+
// is close enough that the first stick or a report's drift steps onto it.
|
|
2824
|
+
if (entry?.coldPose && padAt(h, entry.coldPose.at, COLD_POSE_PAD_CLEAR_M) !== null) {delete entry.coldPose;}
|
|
2444
2825
|
if (entry?.coldPose) {
|
|
2445
2826
|
restorePose(h, playerId, entry.coldPose.at, entry.coldPose.facing);
|
|
2446
2827
|
settle(h, playerId);
|
|
@@ -2469,6 +2850,10 @@ function arrivals(h) {
|
|
|
2469
2850
|
endAgain(h, playerId);
|
|
2470
2851
|
}
|
|
2471
2852
|
}
|
|
2853
|
+
// v1.169: a hub-stay that came before arrival, now that arrival has placed them.
|
|
2854
|
+
for (const { playerId } of group) {
|
|
2855
|
+
if (h.stayable?.get(playerId)?.requested && h.players.get(playerId)?.ended) {applyStay(h, playerId);}
|
|
2856
|
+
}
|
|
2472
2857
|
}
|
|
2473
2858
|
|
|
2474
2859
|
// v1.72 (I3): the end of a resume place's visit, again, to a client a drop
|
|
@@ -2664,6 +3049,9 @@ function placeBeside(h, playerId, otherId, used = new Map()) {
|
|
|
2664
3049
|
|
|
2665
3050
|
// The id of the pad actor a body at `at` stands on, or within `margin` of, or
|
|
2666
3051
|
// null. A pad takes a player whose middle is inside its radius.
|
|
3052
|
+
// How far from a pad's edge a restored cold pose must stand (resumePose).
|
|
3053
|
+
const COLD_POSE_PAD_CLEAR_M = 2.5;
|
|
3054
|
+
|
|
2667
3055
|
function padAt(h, at, margin) {
|
|
2668
3056
|
for (const actor of h.actors) {
|
|
2669
3057
|
const pad = actor.components.HubPad;
|
|
@@ -2720,6 +3108,89 @@ function moveBody(h, playerId, at, facing) {
|
|
|
2720
3108
|
}
|
|
2721
3109
|
body.clamped = true;
|
|
2722
3110
|
body.body.setTranslation(body.at, true);
|
|
3111
|
+
// Any placement is where the player is now, not a `hub.placeAt` still
|
|
3112
|
+
// waiting for its client (a hold, an arrival, a car, a pose restore, at any
|
|
3113
|
+
// distance; `hub.placeAt` arms its own again, `guardPlacement`).
|
|
3114
|
+
h.placed.delete(playerId);
|
|
3115
|
+
// A leave before the next server step stores where the body was put, not
|
|
3116
|
+
// where that step's predecessor recorded it (`rememberResumePoses`).
|
|
3117
|
+
const kept = h.resumeKept?.get(playerId);
|
|
3118
|
+
if (kept && kept.body === body && kept.awayAt === undefined) {
|
|
3119
|
+
kept.at = { ...body.at };
|
|
3120
|
+
kept.facing = body.facing;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
// A place's `hub.placeAt` wins over the move reports its client sent before
|
|
3125
|
+
// it heard of the placement. Those still name where the player stood, and
|
|
3126
|
+
// the movement clamp let each one pull the body a step back toward it; the
|
|
3127
|
+
// clamped row sent back then put the client there too, for good (up to
|
|
3128
|
+
// 1.2 m short, and a whole walk back on a client slow to hear). Such a report
|
|
3129
|
+
// is not taken at all (`stalePose`): the body stays put and every snapshot
|
|
3130
|
+
// keeps the correction. Anything a client that has applied the placement
|
|
3131
|
+
// could have sent is taken as usual, eased part of the way (the shipped
|
|
3132
|
+
// client eases a correction under 4 m a quarter of the way per row) and
|
|
3133
|
+
// walking on included, and the first one taken ends the wait: a socket keeps
|
|
3134
|
+
// order, so every report from before the placement reached the client has
|
|
3135
|
+
// come in by then. SETTLE_MAX_MS bounds a client that never hears.
|
|
3136
|
+
//
|
|
3137
|
+
// A placement within the movement slack of where the body stands (a place
|
|
3138
|
+
// that puts a player where they are, every tick) neither arms nor renews it,
|
|
3139
|
+
// and leaves an earlier one as it was.
|
|
3140
|
+
function guardPlacement(h, playerId, from, guard) {
|
|
3141
|
+
const body = h.sim?.players.get(playerId);
|
|
3142
|
+
if (!body || !from) {
|
|
3143
|
+
return;
|
|
3144
|
+
}
|
|
3145
|
+
if (Math.hypot(body.at.x - from.x, body.at.y - from.y, body.at.z - from.z) <= moveSlack(h)) {
|
|
3146
|
+
if (guard && guard.body === body) {h.placed.set(playerId, guard);}
|
|
3147
|
+
return;
|
|
3148
|
+
}
|
|
3149
|
+
h.placed.set(playerId, { at: { ...body.at }, from, body, placedAt: h.sim.timeMs, until: Date.now() + SETTLE_MAX_MS });
|
|
3150
|
+
}
|
|
3151
|
+
|
|
3152
|
+
// How long after a placement a report nearer the old pose is still taken for
|
|
3153
|
+
// one sent before the client heard of it. A slow phone's in-flight window:
|
|
3154
|
+
// probes of the old code put the body 2.4 to 9.6 m off with the client hearing
|
|
3155
|
+
// 50 to 300 ms late, and twice that covers a stall. After it only
|
|
3156
|
+
// reachability applies, since a player walking against the placement (put
|
|
3157
|
+
// 1.4 m back while walking on at 6 m/s) reports nearer the old pose for good.
|
|
3158
|
+
const STALE_FROM_MS = 500;
|
|
3159
|
+
|
|
3160
|
+
// The movement clamp's fixed slack (multiplayer-3d `MOVE_SLACK`).
|
|
3161
|
+
function moveSlack(h) {
|
|
3162
|
+
const slack = h.engine?.moveSlack?.();
|
|
3163
|
+
return Number.isFinite(slack) ? slack : 0.6;
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
// Whether a move report could not have come from a client that has applied
|
|
3167
|
+
// the placement: farther from the spot than the movement limit allows since
|
|
3168
|
+
// it, or, within STALE_FROM_MS of it, nearer where the player stood before it
|
|
3169
|
+
// than the spot by more than the slack.
|
|
3170
|
+
function stalePose(h, sim, playerId, point) {
|
|
3171
|
+
const placed = h.placed.get(playerId);
|
|
3172
|
+
if (!placed) {
|
|
3173
|
+
return false;
|
|
3174
|
+
}
|
|
3175
|
+
const body = sim.players.get(playerId);
|
|
3176
|
+
if (body !== placed.body || Date.now() >= placed.until) {
|
|
3177
|
+
h.placed.delete(playerId);
|
|
3178
|
+
return false;
|
|
3179
|
+
}
|
|
3180
|
+
if (!point) {
|
|
3181
|
+
return false;
|
|
3182
|
+
}
|
|
3183
|
+
const slack = moveSlack(h);
|
|
3184
|
+
const speed = Number.isFinite(body.maxSpeed) ? body.maxSpeed : h.engine?.maxSpeed?.() ?? 12;
|
|
3185
|
+
const toSpot = Math.hypot(point.x - placed.at.x, point.y - placed.at.y, point.z - placed.at.z);
|
|
3186
|
+
const toFrom = Math.hypot(point.x - placed.from.x, point.y - placed.from.y, point.z - placed.from.z);
|
|
3187
|
+
const since = Math.max(0, sim.timeMs - placed.placedAt);
|
|
3188
|
+
const reach = speed * since / 1000 + slack;
|
|
3189
|
+
if (toSpot > reach || (since < STALE_FROM_MS && toFrom + slack < toSpot)) {
|
|
3190
|
+
return true;
|
|
3191
|
+
}
|
|
3192
|
+
h.placed.delete(playerId);
|
|
3193
|
+
return false;
|
|
2723
3194
|
}
|
|
2724
3195
|
|
|
2725
3196
|
// After a jump (to a door's pad, beside a player) or an arrival (v1.40) the
|
|
@@ -2868,16 +3339,53 @@ function report(h, playerId, value) {
|
|
|
2868
3339
|
return true;
|
|
2869
3340
|
}
|
|
2870
3341
|
|
|
2871
|
-
|
|
3342
|
+
// v1.169: the id a player's own door end is tagged with, as Act's.
|
|
3343
|
+
function doorTag(value) {
|
|
3344
|
+
return typeof value === 'string' && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(value);
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
function end(h, playerId, why, door = null) {
|
|
3348
|
+
const known = h.players.get(playerId);
|
|
3349
|
+
// v1.169: a player's own door end (`door`) in a place without a result. One
|
|
3350
|
+
// their client cancelled (`hub-stay`) is held shut until they step off it,
|
|
3351
|
+
// and one already ended says nothing again.
|
|
3352
|
+
const tag = door && !h.place.result && known ? door : null;
|
|
3353
|
+
if (tag) {
|
|
3354
|
+
const hold = h.stayHolds?.get(playerId);
|
|
3355
|
+
if (hold?.door === tag) {
|
|
3356
|
+
hold.seen = true;
|
|
3357
|
+
return;
|
|
3358
|
+
}
|
|
3359
|
+
if (known.ended) {
|
|
3360
|
+
return;
|
|
3361
|
+
}
|
|
3362
|
+
}
|
|
3363
|
+
Replay.forget(h, playerId);
|
|
2872
3364
|
Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
|
|
3365
|
+
Disguise.forget(h, playerId);
|
|
2873
3366
|
if (h.place.analyticsRounds !== 'authored') {DoorAnalytics.finish(h, playerId);}
|
|
2874
3367
|
const entry = h.players.get(playerId);
|
|
3368
|
+
// v1.169: the player's stay record follows their latest end: their own door
|
|
3369
|
+
// makes one, any other end (a kick, a timer, everyone's) takes it away,
|
|
3370
|
+
// with or without an entry here.
|
|
3371
|
+
// Each tagged door end is numbered per player, monotonic for the session
|
|
3372
|
+
// (never reset by a forget or a hello), so a stay for an older end can
|
|
3373
|
+
// never match a newer record.
|
|
3374
|
+
let endNumber = null;
|
|
3375
|
+
if (tag) {
|
|
3376
|
+
endNumber = ((h.endNumbers ??= new Map()).get(playerId) ?? 0) + 1;
|
|
3377
|
+
h.endNumbers.set(playerId, endNumber);
|
|
3378
|
+
(h.stayable ??= new Map()).set(playerId, { door: tag, end: endNumber, userId: known.userId ?? null, at: null, facing: 0, until: null, requested: false });
|
|
3379
|
+
} else {
|
|
3380
|
+
h.stayable?.delete(playerId);
|
|
3381
|
+
}
|
|
2875
3382
|
if (entry) {
|
|
2876
3383
|
entry.ended = true;
|
|
2877
3384
|
// v1.72 (I3): kept to say it again on resume.
|
|
2878
3385
|
if (h.place.resume === true && h.place.result) {
|
|
2879
3386
|
entry.endWhy = why;
|
|
2880
3387
|
}
|
|
3388
|
+
if (entry.arrived && !h.place.result && h.place.analytics === true) {Analytics.ended(h, playerId);}
|
|
2881
3389
|
}
|
|
2882
3390
|
// A visit the place ended is over, like a kit trip (sendGo): a drop on the
|
|
2883
3391
|
// way out keeps no durable pose to come back to. A House front-door leave
|
|
@@ -2887,9 +3395,178 @@ function end(h, playerId, why) {
|
|
|
2887
3395
|
h.resumeDeparting?.add(playerId);
|
|
2888
3396
|
void h.poseStore.clear(entry?.userId, playerId);
|
|
2889
3397
|
}
|
|
3398
|
+
h.backing?.delete(playerId);
|
|
2890
3399
|
h.held.delete(playerId);
|
|
2891
3400
|
Shot.stopHolding(h, playerId);
|
|
2892
|
-
h.session?.send(playerId, { k: 'hub-end', why });
|
|
3401
|
+
h.session?.send(playerId, tag ? { k: 'hub-end', why, door: tag, end: endNumber } : { k: 'hub-end', why });
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
// v1.169: one stay record per player (`h.stayable`), the authority on whether
|
|
3405
|
+
// their end can be stayed: { door, userId, at, facing, until, requested }. It
|
|
3406
|
+
// exists exactly while their latest end was their own door end (`end`), until
|
|
3407
|
+
// they stay, a fresh visit's hello, or the resume window after they were let
|
|
3408
|
+
// go runs out. `at`/`facing`/`until` are set when the visit is let go
|
|
3409
|
+
// (`parkStayable`); `requested` is a hub-stay that came before arrival.
|
|
3410
|
+
function stayWindowMs(h) {
|
|
3411
|
+
return pinnedResume(h) ? h.session.hub.reconnectWindowMs :
|
|
3412
|
+
houseResume(h) ? RESUME_KEEP_MS : h.place.resumePose === true ? RESUME_POSE_MS : RESUME_KEEP_MS;
|
|
3413
|
+
}
|
|
3414
|
+
|
|
3415
|
+
// The client's word that it cancelled its own door end, taken while it was
|
|
3416
|
+
// offline, and stayed. Honoured only for the record's own account and a
|
|
3417
|
+
// player still ended; before arrival it waits for arrival (`arrivals`), so
|
|
3418
|
+
// nothing there moves the player after their pose is put back.
|
|
3419
|
+
function stay(h, player, data) {
|
|
3420
|
+
const playerId = player?.playerId;
|
|
3421
|
+
const end = data?.end;
|
|
3422
|
+
if (!Number.isSafeInteger(end) || end < 1 || !Object.keys(data).every((key) => key === 'k' || key === 'end') ||
|
|
3423
|
+
!h.session?.players.some((p) => p.playerId === playerId)) {
|
|
3424
|
+
return;
|
|
3425
|
+
}
|
|
3426
|
+
// A repeat of the stay already applied: acknowledged again (its first
|
|
3427
|
+
// answer may have been lost), changing nothing.
|
|
3428
|
+
if (h.stayedEnds?.get(playerId) === end) {
|
|
3429
|
+
h.session.send(playerId, { k: 'hub-stayed', end });
|
|
3430
|
+
return;
|
|
3431
|
+
}
|
|
3432
|
+
const record = h.stayable?.get(playerId);
|
|
3433
|
+
if (record?.end !== end) {
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
const entry = h.players.get(playerId);
|
|
3437
|
+
// Said before the session took the player back (their visit already let
|
|
3438
|
+
// go, their resume hello not yet heard): kept for their next arrival.
|
|
3439
|
+
if (record && !entry && record.at && h.session?.players.some((p) => p.playerId === playerId) &&
|
|
3440
|
+
(userIdOf(h, playerId) ?? null) === record.userId) {
|
|
3441
|
+
record.requested = true;
|
|
3442
|
+
return;
|
|
3443
|
+
}
|
|
3444
|
+
if (!record || !entry?.ended || h.place.result || (entry.userId ?? null) !== record.userId ||
|
|
3445
|
+
!h.session?.players.some((p) => p.playerId === playerId)) {
|
|
3446
|
+
return;
|
|
3447
|
+
}
|
|
3448
|
+
if (!entry.arrived || entry.progressReading) {
|
|
3449
|
+
record.requested = true;
|
|
3450
|
+
return;
|
|
3451
|
+
}
|
|
3452
|
+
applyStay(h, playerId);
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
// A stay that waited on a progress read, applied once the read lets an
|
|
3456
|
+
// arrived player act again (`syncProgressUser`).
|
|
3457
|
+
function stayAfterProgress(h, playerId) {
|
|
3458
|
+
const entry = h.players.get(playerId);
|
|
3459
|
+
if (entry?.arrived && !entry.progressReading && entry.ended && h.stayable?.get(playerId)?.requested) {
|
|
3460
|
+
applyStay(h, playerId);
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
// The visit goes on: prompts, chips, ask, decor and companion back, the pose
|
|
3465
|
+
// lease taken again, and on a replacement body the player put back where the
|
|
3466
|
+
// end left them (a House guest at its arrival, as a resume does). The door is
|
|
3467
|
+
// held shut for them until they step off it (`liftStayHolds`).
|
|
3468
|
+
function applyStay(h, playerId) {
|
|
3469
|
+
const record = h.stayable.get(playerId);
|
|
3470
|
+
const entry = h.players.get(playerId);
|
|
3471
|
+
// Every path here may run later than the word that asked (a progress read,
|
|
3472
|
+
// an arrival): the trusted roster's account now must still be the one the
|
|
3473
|
+
// end and the entry were for, or the record goes and nothing is undone. A
|
|
3474
|
+
// player briefly out of the roster keeps it, still asked for, until they
|
|
3475
|
+
// are back (the next stay, hello or arrival) or it ends the usual ways.
|
|
3476
|
+
if (!h.session?.players.some((p) => p.playerId === playerId)) {
|
|
3477
|
+
if (record) {record.requested = true;}
|
|
3478
|
+
return;
|
|
3479
|
+
}
|
|
3480
|
+
h.stayable.delete(playerId);
|
|
3481
|
+
if (!record || !entry || h.place.result || (entry.userId ?? null) !== record.userId || (userIdOf(h, playerId) ?? null) !== record.userId) {
|
|
3482
|
+
return;
|
|
3483
|
+
}
|
|
3484
|
+
entry.ended = false;
|
|
3485
|
+
delete entry.endAgain;
|
|
3486
|
+
delete entry.endWhy;
|
|
3487
|
+
if (h.place.analytics === true) {Analytics.stayed(h, playerId);}
|
|
3488
|
+
h.resumeDeparting?.delete(playerId);
|
|
3489
|
+
h.actDeparting?.delete(playerId);
|
|
3490
|
+
h.backing?.delete(playerId);
|
|
3491
|
+
(h.stayHolds ??= new Map()).set(playerId, { door: record.door, seen: true });
|
|
3492
|
+
(h.stayedEnds ??= new Map()).set(playerId, record.end);
|
|
3493
|
+
h.session?.send(playerId, { k: 'hub-stayed', end: record.end });
|
|
3494
|
+
if (h.poseStore && entry.userId) {void h.poseStore.take(entry.userId, playerId);}
|
|
3495
|
+
if (record.at && h.sim?.players.has(playerId)) {
|
|
3496
|
+
if (houseResume(h) && h.session?.hub?.owner && entry.userId !== h.session.hub.owner) {
|
|
3497
|
+
placeGroup(h, [playerId]);
|
|
3498
|
+
} else {
|
|
3499
|
+
restorePose(h, playerId, record.at, record.facing);
|
|
3500
|
+
}
|
|
3501
|
+
settle(h, playerId);
|
|
3502
|
+
}
|
|
3503
|
+
if (h.manifest.act === true) {Act.replay(h, playerId);}
|
|
3504
|
+
Decor.joinedAfresh(h, playerId);
|
|
3505
|
+
if (h.place.actions === true) {Actions.joinedAfresh(h, playerId);}
|
|
3506
|
+
if (h.place.companion === true) {Companion.joinedAfresh(h, playerId, userIdOf(h, playerId));}
|
|
3507
|
+
if (h.place.ask === true) {Ask.joinedAfresh(h, playerId);}
|
|
3508
|
+
}
|
|
3509
|
+
|
|
3510
|
+
// A door end lets the visit go at a drop (resumeDeparting): the record keeps
|
|
3511
|
+
// the pose the end left them at, for the resume window. Kept only for a
|
|
3512
|
+
// player still ended; a second let-go keeps the first pose and deadline.
|
|
3513
|
+
function parkStayable(h, playerId) {
|
|
3514
|
+
const record = h.stayable?.get(playerId);
|
|
3515
|
+
if (!record) {
|
|
3516
|
+
return;
|
|
3517
|
+
}
|
|
3518
|
+
const entry = h.players.get(playerId);
|
|
3519
|
+
const kept = h.resumeKept?.get(playerId);
|
|
3520
|
+
const body = h.sim?.players.get(playerId);
|
|
3521
|
+
const pose = kept?.at ? { at: kept.at, facing: kept.facing } : body?.at ? { at: body.at, facing: body.facing } : null;
|
|
3522
|
+
if (!entry?.ended || (!record.at && !pose)) {
|
|
3523
|
+
h.stayable.delete(playerId);
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
if (!record.at) {
|
|
3527
|
+
record.at = { ...pose.at };
|
|
3528
|
+
record.facing = pose.facing;
|
|
3529
|
+
record.until = Date.now() + stayWindowMs(h);
|
|
3530
|
+
}
|
|
3531
|
+
record.requested = false;
|
|
3532
|
+
}
|
|
3533
|
+
|
|
3534
|
+
// A fresh entry for a player who was let go: a resume hello under the same
|
|
3535
|
+
// account in time arrives still ended by that door; any other hello (a fresh
|
|
3536
|
+
// visit) drops the record.
|
|
3537
|
+
function takeStayable(h, playerId, entry, known, data) {
|
|
3538
|
+
const record = h.stayable?.get(playerId);
|
|
3539
|
+
if (!record) {
|
|
3540
|
+
return;
|
|
3541
|
+
}
|
|
3542
|
+
// Every hello checks the account: a queued stay never crosses to another.
|
|
3543
|
+
if ((entry.userId ?? null) !== record.userId) {
|
|
3544
|
+
h.stayable.delete(playerId);
|
|
3545
|
+
return;
|
|
3546
|
+
}
|
|
3547
|
+
if (known) {
|
|
3548
|
+
return;
|
|
3549
|
+
}
|
|
3550
|
+
if (data.resume === true && record.at && Date.now() <= record.until && (entry.userId ?? null) === record.userId) {
|
|
3551
|
+
entry.ended = true;
|
|
3552
|
+
} else {
|
|
3553
|
+
h.stayable.delete(playerId);
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
// A held door stays shut while the place keeps asking for it: a step in which
|
|
3558
|
+
// it did not (the player stepped off) lets it go.
|
|
3559
|
+
function liftStayHolds(h) {
|
|
3560
|
+
for (const [playerId, record] of h.stayable ?? []) {
|
|
3561
|
+
if (record.until !== null && Date.now() > record.until) {h.stayable.delete(playerId);}
|
|
3562
|
+
}
|
|
3563
|
+
for (const [playerId, hold] of h.stayHolds ?? []) {
|
|
3564
|
+
if (!hold.seen || !h.players.has(playerId)) {
|
|
3565
|
+
h.stayHolds.delete(playerId);
|
|
3566
|
+
} else {
|
|
3567
|
+
hold.seen = false;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
2893
3570
|
}
|
|
2894
3571
|
|
|
2895
3572
|
// This place's doors (contract §4): in dev, the `HubDoor` scene actors whose
|
|
@@ -3195,14 +3872,61 @@ function frontOf(door) {
|
|
|
3195
3872
|
// What `ballot.js` uses of this layer (v1.68): names and avatars are the
|
|
3196
3873
|
// kit's own, never the deck's; a player not in the session is no face.
|
|
3197
3874
|
function ballotDeps(h) {
|
|
3875
|
+
const usernameOf = (playerId) => (h.sim?.players.has(playerId) ? h.session?.players.find((p) => p.playerId === playerId)?.username ?? null : null);
|
|
3198
3876
|
return {
|
|
3199
3877
|
blockedPairs: () => blockedPairs(h),
|
|
3200
3878
|
namesOf: (ids) => namesOf(h, ids),
|
|
3201
|
-
usernameOf
|
|
3879
|
+
usernameOf,
|
|
3202
3880
|
avatarOf: (playerId) => (h.players.get(playerId)?.hello ? h.players.get(playerId).avatar : null),
|
|
3881
|
+
// v1.179 `ballot.keepAway` only (the invariant in ballot.js).
|
|
3882
|
+
...(h.place.ballot?.keepAway === true ? {
|
|
3883
|
+
inRoster: (playerId) => h.session?.players.some((p) => p.playerId === playerId) === true,
|
|
3884
|
+
// The signed-in Castle account on a player id now; null for every guest
|
|
3885
|
+
// (anonymous, dev guests included) and anyone not in the roster.
|
|
3886
|
+
identityOf: (playerId) => {
|
|
3887
|
+
const p = h.session?.players.find((q) => q.playerId === playerId);
|
|
3888
|
+
return p && p.isAnonymous !== true && USER_ID.test(String(p.userId)) ? String(p.userId) : null;
|
|
3889
|
+
},
|
|
3890
|
+
// The account a retained visit is held for, on the same terms.
|
|
3891
|
+
awayIdentityOf: (playerId) => {
|
|
3892
|
+
const kept = h.resumeKept?.get(playerId)?.identityUserId;
|
|
3893
|
+
return typeof kept === 'string' && USER_ID.test(kept) ? kept : null;
|
|
3894
|
+
},
|
|
3895
|
+
// Retained away now: arrived, dropped, inside its resume deadline (as
|
|
3896
|
+
// prepareResume reckons it), not let go, and not dropped right after
|
|
3897
|
+
// their own Back (a fresh v1.173 mark lets the visit go).
|
|
3898
|
+
retained: (playerId) => retainedAway(h, playerId, usernameOf),
|
|
3899
|
+
// A present player's profile under `account`: their session name and
|
|
3900
|
+
// the avatar of a hello made under that same account, else none.
|
|
3901
|
+
profileOf: (playerId, account) => {
|
|
3902
|
+
const entry = h.players.get(playerId);
|
|
3903
|
+
const name = usernameOf(playerId);
|
|
3904
|
+
if (!entry?.hello || entry.userId !== account || !name) {
|
|
3905
|
+
return null;
|
|
3906
|
+
}
|
|
3907
|
+
return Number.isInteger(entry.avatar) ? { name, avatar: entry.avatar } : { name };
|
|
3908
|
+
},
|
|
3909
|
+
} : {}),
|
|
3203
3910
|
};
|
|
3204
3911
|
}
|
|
3205
3912
|
|
|
3913
|
+
// v1.179 keepAway: whether the place still holds a dropped player's visit
|
|
3914
|
+
// now, by the same deadline and Back rule `prepareResume` applies, so a tap
|
|
3915
|
+
// or send between ticks never outlives what reconcile would let go.
|
|
3916
|
+
function retainedAway(h, playerId, usernameOf) {
|
|
3917
|
+
const entry = h.players.get(playerId);
|
|
3918
|
+
const kept = h.resumeKept?.get(playerId);
|
|
3919
|
+
if (!entry?.arrived || !kept || h.resumeDeparting?.has(playerId) || usernameOf(playerId)) {
|
|
3920
|
+
return false;
|
|
3921
|
+
}
|
|
3922
|
+
const since = kept.awayAt ?? kept.seenAt;
|
|
3923
|
+
const expired = pinnedResume(h) ? Date.now() - since > h.session.hub.reconnectWindowMs
|
|
3924
|
+
: Date.now() - since >= (houseResume(h) ? RESUME_KEEP_MS : h.place.resumePose === true ? RESUME_POSE_MS : RESUME_KEEP_MS);
|
|
3925
|
+
const mark = h.backing?.get(playerId);
|
|
3926
|
+
const backed = mark && Date.now() - mark.at <= BACK_WINDOW_MS && mark.userId === (entry.userId ?? null);
|
|
3927
|
+
return !expired && !backed;
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3206
3930
|
// What `say.js` uses of this layer. A deck whose manifest sets `cues` (v1.23)
|
|
3207
3931
|
// hands it more; any other hands it exactly what it did.
|
|
3208
3932
|
function sayDeps(h) {
|
|
@@ -3310,15 +4034,18 @@ function goTo(h, player, data) {
|
|
|
3310
4034
|
// The players staying in a town are told who went through which door
|
|
3311
4035
|
// (`hub-went`, v1.15), so a friend left behind can follow: each client shows
|
|
3312
4036
|
// it only for its own friends and party. Never across a block, and not for a
|
|
3313
|
-
// cabinet (a classic deck is played alone).
|
|
4037
|
+
// cabinet (a classic deck is played alone). Only connected players are told:
|
|
4038
|
+
// a lineage kept for its reconnect window, or one already gone, has no one
|
|
4039
|
+
// to read it.
|
|
3314
4040
|
function tellWent(h, goingIds, door) {
|
|
3315
4041
|
if (!h.sim || h.place.result || !goingIds.length) {
|
|
3316
4042
|
return;
|
|
3317
4043
|
}
|
|
3318
4044
|
const going = new Set(goingIds);
|
|
3319
4045
|
const pairs = blockedPairs(h);
|
|
4046
|
+
const connected = new Set(h.session?.players.map((p) => p.playerId));
|
|
3320
4047
|
for (const [playerId, entry] of h.players) {
|
|
3321
|
-
if (!entry.arrived || going.has(playerId)) {
|
|
4048
|
+
if (!entry.arrived || going.has(playerId) || !connected.has(playerId)) {
|
|
3322
4049
|
continue;
|
|
3323
4050
|
}
|
|
3324
4051
|
const hidden = pairs?.get(playerId);
|
|
@@ -3401,17 +4128,69 @@ function deckDoorPlace(h, props, deck) {
|
|
|
3401
4128
|
|
|
3402
4129
|
// All outgoing travel paths retire the lease after sending the command.
|
|
3403
4130
|
function sendGo(h, playerId, msg) {
|
|
4131
|
+
HoldShow.forget(h, playerId);
|
|
4132
|
+
Replay.forget(h, playerId);
|
|
4133
|
+
if (h.recordings || h.replays) {(h.replayDeparting ??= new Set()).add(playerId);}
|
|
3404
4134
|
if (h.session?.send) {
|
|
3405
4135
|
Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
|
|
3406
|
-
|
|
4136
|
+
Disguise.forget(h, playerId);
|
|
4137
|
+
if (h.cars || h.disguiseUsed) {(h.vehicleDeparting ??= new Set()).add(playerId);}
|
|
3407
4138
|
h.session.send(playerId, msg);
|
|
3408
4139
|
Shot.stopHolding(h, playerId);
|
|
3409
|
-
// An explicit kit trip ends the visit rather than retaining it for a drop.
|
|
3410
|
-
h.resumeDeparting?.add(playerId);
|
|
3411
4140
|
if (h.manifest.act === true) {Act.forget(h, playerId); (h.actDeparting ??= new Set()).add(playerId);}
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
4141
|
+
// An explicit kit trip ends the visit rather than retaining it for a drop.
|
|
4142
|
+
letVisitGo(h, playerId);
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
// The visit is over, not paused: a drop on the way out is not retained, and
|
|
4147
|
+
// no arrival or durable pose is kept to come back to. A kit trip (`sendGo`)
|
|
4148
|
+
// and a drop right after the player's own Back (`hub-back`) both end a visit
|
|
4149
|
+
// this way.
|
|
4150
|
+
function letVisitGo(h, playerId) {
|
|
4151
|
+
h.backing?.delete(playerId);
|
|
4152
|
+
h.resumeDeparting?.add(playerId);
|
|
4153
|
+
h.arrivalPoses?.clear(playerId);
|
|
4154
|
+
if (h.poseStore) { void h.poseStore.clear(h.players.get(playerId)?.userId, playerId); }
|
|
4155
|
+
h.resumePending?.delete(playerId);
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
// v1.173: how long a player's own Back (`hub-back`) stays armed: the SDK's
|
|
4159
|
+
// Hub.back timeout (30 s) and some slack. A drop inside it is the Back
|
|
4160
|
+
// leaving; one after it is an ordinary drop.
|
|
4161
|
+
const BACK_WINDOW_MS = 35_000;
|
|
4162
|
+
|
|
4163
|
+
// v1.173: the client's word that its player is leaving this place by their
|
|
4164
|
+
// own Back (system back, Escape or the Back control), said just before it
|
|
4165
|
+
// asks the host for the way back. It only arms (`h.backing`): nothing changes
|
|
4166
|
+
// until that connection drops while the mark is fresh (`backDropped`), when
|
|
4167
|
+
// the visit ends as a kit trip's does, so the next entry is a fresh arrival.
|
|
4168
|
+
// A Back that fails leaves the visit as it was once the mark goes stale.
|
|
4169
|
+
// Ignored in a game (`result`), in a place that retains no visit, before
|
|
4170
|
+
// arrival, from a player not in the roster or unknown here, and once the
|
|
4171
|
+
// player is already departing (a trip or an end); a repeat refreshes the
|
|
4172
|
+
// mark's time.
|
|
4173
|
+
function backOut(h, player) {
|
|
4174
|
+
const playerId = player?.playerId;
|
|
4175
|
+
const entry = h.players.get(playerId);
|
|
4176
|
+
if (h.place?.result || !h.resumeDeparting || !entry?.arrived ||
|
|
4177
|
+
!h.session?.players.some((p) => p.playerId === playerId) || h.resumeDeparting.has(playerId)) {
|
|
4178
|
+
return;
|
|
4179
|
+
}
|
|
4180
|
+
(h.backing ??= new Map()).set(playerId, { at: Date.now(), userId: entry.userId ?? null });
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4183
|
+
// The kit has just seen this player's connection gone. A fresh Back mark
|
|
4184
|
+
// for the same account lets the visit go before anything of it is kept;
|
|
4185
|
+
// a stale one is dropped and changes nothing.
|
|
4186
|
+
function backDropped(h, playerId) {
|
|
4187
|
+
const mark = h.backing?.get(playerId);
|
|
4188
|
+
if (!mark) {
|
|
4189
|
+
return;
|
|
4190
|
+
}
|
|
4191
|
+
h.backing.delete(playerId);
|
|
4192
|
+
if (Date.now() - mark.at <= BACK_WINDOW_MS && mark.userId === (h.players.get(playerId)?.userId ?? null)) {
|
|
4193
|
+
letVisitGo(h, playerId);
|
|
3415
4194
|
}
|
|
3416
4195
|
}
|
|
3417
4196
|
|
|
@@ -3755,9 +4534,17 @@ function firePad(h, hub, door, playerIds) {
|
|
|
3755
4534
|
// The pad keeps its id until ghost answers the fire, so a retried go (or a
|
|
3756
4535
|
// gathering update) after a lost answer names the same pad, which ghost
|
|
3757
4536
|
// answers with the group it already fixed rather than firing a second one.
|
|
3758
|
-
|
|
4537
|
+
// A go while that fire is still out sends no second fire: for players it
|
|
4538
|
+
// already names, its answer sends them; anyone else is not sent (null), so
|
|
4539
|
+
// the place may try them again once it settles.
|
|
4540
|
+
const pending = h.pads.get(door);
|
|
4541
|
+
if (pending?.firing) {
|
|
4542
|
+
return [...members.keys()].every((userId) => pending.fireMembers?.has(userId)) ? pending.padId : null;
|
|
4543
|
+
}
|
|
4544
|
+
const pad = pending ?? { padId: newPadId(door), json: null, at: 0 };
|
|
3759
4545
|
pad.firing = true;
|
|
3760
4546
|
pad.fireSent = true;
|
|
4547
|
+
pad.fireMembers = new Set(members.keys());
|
|
3761
4548
|
h.pads.set(door, pad);
|
|
3762
4549
|
hub
|
|
3763
4550
|
.updatePad({ doorId: door, padId: pad.padId, memberUserIds: [...members.keys()], fire: true })
|
|
@@ -3787,9 +4574,14 @@ function padFired(h, door, pad, users, fired) {
|
|
|
3787
4574
|
const group = Array.isArray(fired) ? fired : [];
|
|
3788
4575
|
// The group is ghost's; anyone of it still here goes, on the pad now or not,
|
|
3789
4576
|
// but a player whose app has turned out to have no door trips since (v1.156).
|
|
3790
|
-
|
|
4577
|
+
// "Here" is the roster as the answer lands: the player the pad was asked for
|
|
4578
|
+
// if still connected, else the account's current connection, never one that
|
|
4579
|
+
// has since dropped (its reconnect window or a departed lineage).
|
|
4580
|
+
const connected = h.session?.players.map((p) => p.playerId) ?? [];
|
|
4581
|
+
const here = travelersOf(h, connected);
|
|
3791
4582
|
const going = (userId) => {
|
|
3792
|
-
const
|
|
4583
|
+
const asked = users.get(userId);
|
|
4584
|
+
const playerId = asked && connected.includes(asked) ? asked : here.get(userId);
|
|
3793
4585
|
return playerId && !h.noTrips.has(playerId) ? playerId : null;
|
|
3794
4586
|
};
|
|
3795
4587
|
tellWent(h, group.map(going).filter(Boolean), door);
|
|
@@ -4111,7 +4903,7 @@ function applyRead(h, { playerId, state, lifetime }, read) {
|
|
|
4111
4903
|
if (!entry || entry.progressState !== state || h.progressStates.get(playerId) !== state || state.readLifetime !== lifetime || !read) {
|
|
4112
4904
|
return;
|
|
4113
4905
|
}
|
|
4114
|
-
const { avatarRev, colorRev, wearRev, earnedRev, startedAt } = lifetime;
|
|
4906
|
+
const { avatarRev, colorRev, wearRev, earnedRev, startedAt, keepLook } = lifetime;
|
|
4115
4907
|
// Their results and records, for `hub.results` (v1.5).
|
|
4116
4908
|
History.take(h, playerId, read, startedAt);
|
|
4117
4909
|
// The wearable likewise, unless the game put one on since (v1.4).
|
|
@@ -4119,14 +4911,14 @@ function applyRead(h, { playerId, state, lifetime }, read) {
|
|
|
4119
4911
|
// The earned item likewise, unless an unlock or choice was made since (v1.53).
|
|
4120
4912
|
Earned.applyRead(h, playerId, earnedRev, read);
|
|
4121
4913
|
// The platform avatar, unless the client chose another since the read began.
|
|
4122
|
-
if (!entry.signUp && Number.isInteger(read.avatar) && read.avatar >= 0 && read.avatar < AVATARS && entry.avatarRev === avatarRev) {
|
|
4914
|
+
if (!entry.signUp && !keepLook && Number.isInteger(read.avatar) && read.avatar >= 0 && read.avatar < AVATARS && entry.avatarRev === avatarRev) {
|
|
4123
4915
|
if (entry.avatar !== read.avatar) {
|
|
4124
4916
|
// A colour queued for the previous character cannot follow a new body.
|
|
4125
4917
|
entry.color = cleanAvatarColor(read.avatarColor);
|
|
4126
4918
|
}
|
|
4127
4919
|
entry.avatar = read.avatar;
|
|
4128
4920
|
}
|
|
4129
|
-
if (!entry.signUp && entry.colorRev === colorRev) {
|
|
4921
|
+
if (!entry.signUp && !keepLook && entry.colorRev === colorRev) {
|
|
4130
4922
|
entry.color = cleanAvatarColor(read.avatarColor);
|
|
4131
4923
|
}
|
|
4132
4924
|
const row = entry.fromDeckId
|
|
@@ -4202,6 +4994,9 @@ function sendHudOverrides(h) {
|
|
|
4202
4994
|
spec = JSON.stringify(mine) === JSON.stringify(Blocks.redactHud(h.hud, all)) ? null : mine;
|
|
4203
4995
|
}
|
|
4204
4996
|
}
|
|
4997
|
+
if (h.writerLease?.api.lost(h.players.get(playerId)?.userId)) {
|
|
4998
|
+
spec = { ...(spec ?? hudForAll(h)), text: WriterLease.NOTICE };
|
|
4999
|
+
}
|
|
4205
5000
|
const json = JSON.stringify(spec);
|
|
4206
5001
|
if ((h.sentHudMe.get(playerId) ?? 'null') !== json) {
|
|
4207
5002
|
h.sentHudMe.set(playerId, json);
|
|
@@ -4427,7 +5222,8 @@ function latchAvatarColors(h, out) {
|
|
|
4427
5222
|
// and again when the roster changes.
|
|
4428
5223
|
function blockedPairs(h) {
|
|
4429
5224
|
const players = h.session?.players ?? [];
|
|
4430
|
-
|
|
5225
|
+
// By player id and account: a switch on an id never reads an old answer.
|
|
5226
|
+
const key = `${h.sim?.timeMs ?? ''}:${players.map((p) => `${p.playerId}=${p.userId}`).join(',')}`;
|
|
4431
5227
|
if (h.blocked.key !== key) {
|
|
4432
5228
|
h.blocked = { key, pairs: Blocks.hiddenPairs(h.session, players.map((p) => p.playerId)) };
|
|
4433
5229
|
}
|
|
@@ -4527,7 +5323,7 @@ function earnedDeps(h, playerId, op) {
|
|
|
4527
5323
|
// shows an earned item, in deltas from the first one on.
|
|
4528
5324
|
function earnedForJoin(h) {
|
|
4529
5325
|
const earned = Earned.earnedForAll(h, blockedPairs(h));
|
|
4530
|
-
return Object.keys(earned).length ? { hubEarned: earned } : {};
|
|
5326
|
+
return Object.keys(earned).length || h.holdShowUsed ? { hubEarned: earned } : {};
|
|
4531
5327
|
}
|
|
4532
5328
|
|
|
4533
5329
|
function latchEarned(h, out) {
|
|
@@ -4669,6 +5465,19 @@ function identityUserIdOf(h, playerId) {
|
|
|
4669
5465
|
return p && USER_ID.test(String(p.userId ?? '')) ? String(p.userId) : null;
|
|
4670
5466
|
}
|
|
4671
5467
|
|
|
5468
|
+
// v1.185 `hub.wallet`: a signed-in account's wallet is stored under its
|
|
5469
|
+
// numeric user id; an anonymous player or a dev guest has one for the session.
|
|
5470
|
+
function walletIdentity(h, playerId) {
|
|
5471
|
+
const p = h.session?.players.find((q) => q.playerId === playerId);
|
|
5472
|
+
if (!p) {
|
|
5473
|
+
return null;
|
|
5474
|
+
}
|
|
5475
|
+
if (!p.isAnonymous && USER_ID.test(String(p.userId ?? ''))) {
|
|
5476
|
+
return { stored: true, userId: String(p.userId) };
|
|
5477
|
+
}
|
|
5478
|
+
return { stored: false, key: typeof p.userId === 'string' && p.userId ? `u:${p.userId}` : `p:${playerId}` };
|
|
5479
|
+
}
|
|
5480
|
+
|
|
4672
5481
|
function usernameOf(h, playerId) {
|
|
4673
5482
|
return h.session?.players.find((p) => p.playerId === playerId)?.username ?? 'player';
|
|
4674
5483
|
}
|