Documentation / Saves & coming back

💾 Saves & coming back 存檔同返嚟

What it does 做乜嘢

Saves are versioned JSON, written locally, with no cloud sync and no account. On resume, the simulation ticks forward by the elapsed real-world time, clamped to thirty days, so timers complete, production runs until the barn fills, animals finish, the mine regenerates, and a summary shows exactly what happened while you were away. 存檔係本機嘅版本化 JSON 檔案,冇雲端同步,亦都唔使帳號。返嚟嗰陣,模擬會跟返實際過咗嘅時間推前(最多推 30 日),時限會完成、生產會做到倉滿為止、動物會完成、礦場會重生,仲有個總結話你知走咗嗰段時間發生咗乜。

How it works 點運作

Saves are written through an atomic-write helper that retries the rename on EPERM, EACCES and EBUSY — a plain rename can fail on Windows whenever the destination file is momentarily open, which a virus scanner, the search indexer or a sync client does to every file you just wrote. A project-wide guard refuses a bare fs.rename anywhere in the tree so this cannot be bypassed by accident. The simulation itself is headless and deterministic: tick(state, elapsedMs) -> state runs with no three.js and no DOM, over a seeded random number generator, which is what makes offline progress the exact same code path as live play rather than a second implementation that quietly drifts from the first. 存檔透過一個原子寫入輔助工具寫入,遇到 EPERM、EACCES、EBUSY 會自動重試——喺 Windows 度,普通嘅 rename 只要目標檔案暫時俾人打開咗就會失敗,而防毒軟件、搜尋索引或者同步軟件成日都會打開你啱啱寫嘅檔案。項目入面有個守衛,唔畀成個 repo 出現裸嘅 fs.rename,所以呢個保護唔會俾人唔小心繞過。模擬本身係無畫面同確定性嘅:tick(state, elapsedMs) -> state 完全唔使 three.js 同 DOM,跟住一個有種子嘅隨機數產生器行,呢個令離線進度同即時遊玩用返完全同一條程式碼路徑,而唔係另一份會慢慢同原本唔一致嘅實作。

Failure modes 失敗情況

The clamp to thirty days means a save left untouched for months resumes as thirty days of progress, not months — this is a deliberate bound, stated plainly in the return summary rather than left for the player to notice a discrepancy. A save that fails to write (after every atomic-write retry is exhausted) must not corrupt the previous valid save; the write targets a temporary file and only replaces the real save file on a successful rename. 推前上限係三十日,即係擺咗幾個月冇開嘅存檔,返嚟都淨係當三十日進度計,唔係幾個月——呢個係刻意嘅上限,會喺總結度講清楚,唔會等玩家自己發現唔對路。就算原子寫入重試晒都失敗,都唔應該整爛之前個有效存檔;寫入會先寫去暫存檔案,成功 rename 咗先會取代返正式存檔。

What is not yet implemented 仲未整好嘅部分

The published v0.1.0-22 desktop baseline is available (see the changelog). The save schema, its migrations, and the offline-resume tick loop live in packages/shared and are verified by asserting tick(24h) equals 1,440 applications of tick(1min) over long horizons — this is checked in the change that introduces it rather than left to a screenshot to catch. 已發佈嘅 v0.1.0-22 桌面基準而家可以下載(睇更新日誌)。存檔格式、遷移邏輯,同離線推進嘅 tick 循環都喺 packages/shared 入面,驗證方法係喺長時段度斷言 tick(24h) 等於 1,440 次 tick(1min)——呢個係喺加入嗰個改動入面就驗證,唔係靠張截圖先發現有事。