Saving and safety

I built the editor so that losing a map should be hard. This page says what it does, and what it does not do.

Autosave

There is no Save command. The editor checks twice a second and writes your changes to disk once you have stopped changing things for a second. That covers:

  • the terrain and the objects,
  • the map's settings, meaning the sun, the playable area, fog and the players.

The status bar at the bottom of the window shows Saving… while a change is waiting, and All changes saved when it is on disk. If a save fails, the status bar shows the reason in red.

The editor also saves at once when you open another map or a model, when you export or play, when you close the window, and when you quit.

Some things never wait for autosave because they work on files directly: importing, renaming and deleting files in Imports, the script files, and the shader files. Those are on disk the moment you do them.

Atomic writes

The editor never writes over a file in place. It writes the new version next to the old one, forces it to disk, and only then renames it into place. At any moment the file is either the complete old version or the complete new one, never half of each. A crash, a full disk or a power cut in the middle of a save cannot leave you a broken file.

Backups

When the editor replaces a map file, it keeps the version it replaced as <name>.bak. The backup is refreshed at most every five minutes, so it is a real older state of the file and not a copy of the previous save.

Repair on open

Before it opens a map, the editor checks that map.toml, the terrain, the tile set and the two object files can be read. If one cannot:

  • and its backup can be read, the editor moves the damaged file aside as <name>.corrupt, puts the backup in its place, and shows a toast: Restored … from its backup because it could not be read. The damaged file was kept as … .corrupt.
  • and there is no good backup, the editor leaves the file alone.

Nothing is deleted without a copy being kept.

If the editor crashes

If the editor itself crashes, it tries to save whatever terrain and object changes were still waiting, before it stops. It also writes crash.txt into the editor data folder. The note has the editor version, the error, what was saved, and a trace for a bug report. A later crash replaces the note.

Autosave means the gap is small to begin with, at most about a second of work.

If the editor is killed from outside, or the computer loses power, there is no chance to save. Your map is still intact, as of the last autosave.

Playing is separate

Play starts the engine on a temporary copy of the map. If the engine crashes, only that run is lost. The editor tells you, and where the engine's error output went (engine.log).

Older maps

Opening a map from an older format brings it forward and saves it in the current format. A map from a newer W4 is refused. See Files of a map.

What is not built yet

Local versions, meaning automatic checkpoints you can go back to, exist in the map library but the editor does not make them yet. Until then your safety net is autosave, the backups, the undo history while the map is open, and your own copies or git.

I would not rely on a single copy of a map that matters. Copy the folder now and then, or put it in git. A new map already comes with a .gitignore that keeps the backups out.