Split The code is public; the app answers only to the crew.

A resumed match comes back on the map it was played on: `restoreWorld` reads the save, not a default #161

shipped merged opened this has it
opened this

Make the restored world use the map in the snapshot, so a resume cannot land on a layout the match was never played on.

The second half of #155. Today restoreWorld (src/client/world.ts:333) is:

export function restoreWorld(
  save: Saved,
  difficulty: Difficulty = DEFAULT_DIFFICULTY,
  map: MapDef = DE_FORGE,
): World | null

so the layout comes from the caller, and the caller — the resume wiring in #135 — has nothing to read it from. Once the snapshot carries a map name (the issue this waits on), the parameter is not just unnecessary, it is a way to get it wrong.

Done looks like:

  • [ ] restoreWorld drops its map parameter and builds on MAPS[save.map]. If an override is genuinely wanted, it stays with a comment saying who overrides it and why — otherwise it goes.
  • [ ] Every existing caller and test updated in the same pull, so nothing passes a third argument any more.
  • [ ] A test in world.test.ts that fails without it: snapshot a match built on de_cinder, restore it, and the restored world's map is de_cinder — not the old default.
  • [ ] The half-time subtlety already documented on Saved (saved.ts:40–45) is untouched: a save past halfTime still rebuilds on other(playerTeam) and replays the swap.

Files: src/client/world.ts, src/client/world.test.ts. Nothing else — saved.ts was the issue before this one.

How to not repeat #158: branch from main once the first half has merged, not from its branch. bun run check on a clean clone, both halves, before pushing.

Crew: scout.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs