From 94488bf8f70e8be37068c57940f6cb5309b2eb87 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Thu, 29 Oct 2026 07:05:48 +0100 Subject: [PATCH] Save slots: CHANGELOG and architecture notes --- CHANGELOG.md | 2 ++ docs/ARCHITECTURE.md | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d62391..ba69f5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Keep several networks on one device, and play two of them side by side in two browser windows. The title screen lists your networks, newest first, with their day, tier, cash and when you last played; tap one to continue it, or use ⋯ to export or delete it. Starting a scenario, the weekly challenge or a new network, or importing a save, now adds a network instead of replacing the one you have, and you can rename a network from the menu. Each window remembers its own network when you reload it. If a network is already open in another window, you can switch to it or take it over, and the other window steps aside instead of both saving over each other. Your existing save carries on as your first network. +- When your browser's storage is full, the warning now lists your other networks by size so you can export or delete one to make room. Closing the tab in the middle of a puzzle no longer loses recent progress on the network you set aside. - A new start screen with four doors: Puzzles, Sandbox, Normal, and Scenarios & weekly. Every network now picks its rules when it starts, and they stay locked for that network; your saved games carry on exactly as before. - Normal comes in three flavours. Change Freeze has a third of the outages and no DDoS floods, delivers PNIs, cross-connects and builds in days instead of months (#151), and skips the peering inbox, hardware shortages and sold-out routes. On-call is the classic game. BGP at 3 a.m. brings almost twice the outages, lasting half as long again, and twice the DDoS. The HUD and the share card show which one you picked. - Sandbox is a real sandbox now (#188): everything is unlocked from day one, your own subsea cable included, money never runs out, deliveries are quick, and you pick how much chaos you want, from none to spicy. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index d856f63..91b1435 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -78,7 +78,7 @@ Development runs on `npm run dev` (assembles on every request, reloads on save); - **`S`**: the whole saved game (one JSON object). Cash, day, POPs, links, transit, IX ports, PNIs, caches, customers (`biz`), offers, incidents (`inc`), live events - (`ev`), stats, settings. Saved to `localStorage` key `sot-save-v1`. + (`ev`), stats, settings. Saved to `localStorage` key `sot-save-v1:` (one per network, see below). - **`R`**: results of the last `compute()`: per-link load, per-exit use, served and demanded traffic, reach, costs and revenue. Never saved; always rebuilt. - **`UI`**: view state (selection, open tabs, speed, confirmations). Not game state. @@ -146,9 +146,19 @@ Served share per city (`sfOf`) drives eyeball revenue and customer mood. ## Saves, imports and migration -- `save()` writes `S` to localStorage every few seconds and after actions. +- `save()` writes `S` to localStorage every few seconds and after actions, into this window's slot + (`UI.slot`, `src/game/91-slots.js`): `sot-save-v1:`, plain JSON or `gz:`-compressed above a million + characters, with a stamp `sv:{seq,at}` appended. Then the index `sot-slots` (name, ASN, preset, day, tier, + cash, last played, size, seq) is updated; the title screen lists networks from the index alone. +- Each tab keeps its slot in `sessionStorage['sot-slot']`. One window per slot: a Web Lock + (`sot-slot:`) where supported, plus a heartbeat `sot-open:`; BroadcastChannel `sot-slots` asks + another window to hand over, and the `storage` event stops a window whose slot was saved newer elsewhere + (higher seq) or deleted. A window never writes a slot whose index seq is newer than its own. +- The single save of older versions (`sot-save-v1`) is copied to slot `main` and read back before the + index lists it; the old key is removed only by that slot's next successful save. - `boot()` loads the save through `migrate()` → `sanitize()`. If loading throws, the - damaged save is kept under `sot-save-broken` and the player starts fresh. + slot is kept and marked damaged in the index (it can still be exported or deleted). +- Puzzles never write a slot; while one runs, `save()` writes the network set aside (`UI.pzKeep`). - `sanitize(s)` is the gate for all untrusted state (saves and imported files): it drops unknown ids, clamps numbers, repairs references and fills defaults. Every new field in `S` needs a line there.