Saves & Files¶
Kingdom saves the entire world to a compact binary blob. Saves live in named slots: type a name next to Save in the HUD and the world is stored under it. Saving under a name you've used before overwrites that slot; saving under a new name adds one. There is no fixed slot count, so you can keep as many worlds as your storage holds.
Every slot appears on the main menu under Saved Worlds, each with a Load and a Delete button. Delete asks you to click a second time before it removes anything.
A loaded or freshly created world prefills the save box (with the slot it came from, or a name built from the seed), so a plain Save keeps updating the same slot unless you rename it. Slot names are trimmed to letters, digits, spaces, dashes and underscores, and capped at 40 characters, so they double as file names.
Autosave¶
While you play, the world also autosaves to the slot named in the save box: every two minutes, when you leave for the main menu (the Menu button or Esc), and when you close the window. In other words, the slot you're playing in quietly keeps up with you, and a crash or a hasty quit costs at most the last couple of minutes.
Because the autosave writes to whatever name is in the box, renaming the box mid-session points both manual saves and autosaves at the new slot, leaving the old one as it was: an easy way to branch a world. To abandon a session without it being saved, there isn't a way to opt out beyond deleting the slot afterward; the testing ground remains the place for consequence-free experiments, since it never saves at all.
What's saved¶
A save captures everything needed to reconstruct your session exactly:
- The world seed.
- Every realm: who runs it (a person or the computer), its stockpile (wood, stone, and gold), its priorities and switches, its builder zones and the bridges it laid. A single-player world has one realm, yours.
- Stats: enemies defeated, and each realm's units lost.
- Diplomacy: which realms are allied, the proposals awaiting an answer, any alliance under notice with the time it has left, and whether the computer's realms may ally.
- Every unit: position, faction, role, and state, including where settlers on the road between villages are headed, so they finish the trip after a load.
- Cargo ships currently at sea, with their load, payout and owning realm, plus each realm's autonomous-trade switch and configured cargo load.
- Settler and troop ships under sail, with everyone aboard, their destination, and their owner (a realm's, a hired allied company's with the realm that hired it, or an enemy raid's).
- Warships afloat, with their owner (a realm's, a hired allied escort with the realm that hired it, or the enemy's), their remaining hull, any standing orders (an escort's crossing or an enemy ship's landing), and how long an enemy ship has been out on its sortie.
- Construction orders in progress with the realm that placed each, and which realm hired each mercenary ashore.
- All edited chunks: buildings, bridges, and depleted resources.
Rally flags (the knights' and the navy's) are deliberately transient: they direct a moment, not a realm, so a loaded game starts with none planted. The levies' term of service is transient too: serving levies are saved and still owed their pay, but a loaded game's levies are free to stand down as soon as the realm has been quiet for a little while.
The testing ground is never saved. It has no Save button, so experimenting there can't fill a save slot with an empty grid.
Loading replays the seed to regenerate untouched terrain, then applies your saved edits on top, so even an "infinite" world round-trips from a small file. Loading also tidies up after older saves that stored unedited terrain: any chunk that matches what the seed regenerates is treated as untouched, so the next save you write slims back down to just your edits.
The .dat format¶
The save is a custom binary format, not JSON or a standard container:
- It begins with the magic bytes
KGDMand a version number, so the loader can reject foreign files and knows which revision of the format it is reading. - The rest is a packed representation of the state listed above.
The format is versioned so it can grow without stranding anyone: a newer build keeps loading the saves older supported versions wrote, filling in whatever they predate with sensible defaults (a save from before settler ships simply loads with none at sea, and one from before the enemy and allied navies loads every warship as yours). Where a section changed shape, the loader converts it: saves from before version 20 stored houses as three separate layers (yours, the enemy's, and the allies'), which are folded into the single per-tile owner layer the world keeps now, and they described a single realm, which loads as the first (and only) realm owning every ship, order and hired unit. Saves from before version 21 carry no diplomacy and load with every realm at war. Only a save written by a newer build than the one loading it, or one older than the loader still supports, is refused.
Where they live¶
Each slot is a file named after it, <name>.dat, in a saves/
directory under the platform's data dir (for example
~/Library/Application Support/kingdom/saves on macOS,
~/.local/share/kingdom/saves on Linux, %APPDATA%\kingdom\saves on
Windows). A save file from before slots existed (kingdom_save.dat) is
moved into the directory on startup as a slot named world.
The browser can't write arbitrary files, so each slot's blob is stored as its own record in IndexedDB under your site's origin, keyed by the slot's name (the pre-slot save was keyed world, so it shows up as a slot of that name). Saves persist across page reloads as long as you don't clear site data.
In both cases the menu's Saved Worlds list shows whatever slots are present, and nothing when there are none.