Document autoload, loading by name and server detection

This commit is contained in:
RallyBlock committed 2026-10-26 12:29:58 -04:00
1 parent 1b67c96c8c
commit 071ab25fa7
1 file changed
+21 -7
+21 -7
View File
@@ -40,6 +40,8 @@ The first save after starting always runs. After that, a save is skipped if noth
While bricks are loading, the per-brick change checks are skipped, and a finished or cancelled load counts as one change.
The game turns off packages added after the client add-ons when a server shuts down, which includes AutoSave's change watcher. AutoSave installs it again afterwards, and the first save on each new server always runs.
A save is also skipped while bricks are loading, while bricks are being cleared, and while the mission is being cleaned up. If a load or a clear starts in the middle of a save, the save stops, its temp file is removed, and the next interval tries again.
## Large builds
@@ -62,20 +64,33 @@ Admins can use:
- `/autosaver on` and `/autosaver off`
- `/autosaver save` (or `now`): save right away
- `/autosaver load` (or `reload`): clear all bricks, then load the newest file in `saves/autosave/`
- `/autosaver load <name>`: clear all bricks, then load that autosave instead, for example `/autosaver load 2026-10-26 08-55-15`
- `/autosaver interval <seconds>`: 30 to 86400, default 300
- `/autosaver chunk <bricks>`: bricks per slice, 1 to 20000, default 4000
- `/autosaver tick <milliseconds>`: pause between slices, 1 to 1000, default 1 (never less than 12 ms in practice)
- `/autosaver screenshot on` or `off` (also `screenshots` or `preview`): picture for each save, default on
- `/autosaver autoload on` or `off`: load the newest autosave when a server starts, default off
Out-of-range values are clamped. Changes are announced to everyone and saved right away.
`load` uses the file with the newest modified time on disk, including saves made since the game started. It loads with saved ownership and exact colors. The command is case-insensitive.
`load` with no name uses the file with the newest modified time on disk, including saves made since the game started. With a name, `.bls` is optional, case does not matter, and any part of the name works if only one autosave matches it (`/autosaver load 08-55-15`). If several match, nothing is cleared and you are told how many. Names cannot point outside `saves/autosave/`. Either way it loads with saved ownership and exact colors. The command is case-insensitive.
## Autoload
With autoload on, the newest file in `saves/autosave/` is loaded when a server starts, with saved ownership and exact colors, the same as `/autosaver load`. It waits until the mission is running. It is skipped, with a console line saying why, when:
- a game mode is running (game modes bring their own build);
- a save was picked when the server was set up, or bricks are already loaded or loading;
- there is no autosave.
The loaded build counts as already saved, so the next interval does not write the same build again.
## Preferences
Settings are server prefs, stored in `config/server/prefs.cs` with the game's other server prefs:
```
$Pref::Server::AutoSave::AutoLoad = 0;
$Pref::Server::AutoSave::Chunk = 4000;
$Pref::Server::AutoSave::Enabled = 1;
$Pref::Server::AutoSave::Interval = 300;
@@ -83,16 +98,17 @@ $Pref::Server::AutoSave::Preview = 1;
$Pref::Server::AutoSave::Tick = 1;
```
They are read when you start hosting. Until then the timer only checks every 5 seconds whether a server is up. If a pref is missing, the default is used and added to the file the next time the game writes its prefs.
They are read each time a server starts. AutoSave checks every 5 seconds for a new server, which it tells apart by the mission's `MissionGroup`, so stopping one server and starting another is noticed even within one save interval. The save timer restarts with each new server. If a pref is missing, the default is used and added to the file the next time the game writes its prefs.
Every `/autosaver on`, `off`, `interval`, `chunk`, `tick` and `screenshot` writes `prefs.cs` right away, using the same export the game runs when custom game settings change. AutoSave only writes the file while a server is running, after the game has loaded it, so other prefs are kept. You can also edit the lines while the game is closed. Values out of range are clamped the same way as in chat.
Every `/autosaver on`, `off`, `interval`, `chunk`, `tick`, `screenshot` and `autoload` writes `prefs.cs` right away, using the same export the game runs when custom game settings change. AutoSave only writes the file while a server is running, after the game has loaded it, so other prefs are kept. You can also edit the lines while the game is closed. Values out of range are clamped the same way as in chat.
## Console
- `autoSave()` starts a save now
- `autoSaveNewest()` returns the newest autosave path
- `autoSaveFind(name)` returns the autosave path for a name, `*N` if N files match, or nothing
- `autoSaveApply()` clamps the settings, copies them to `$Pref::Server::AutoSave::*`, writes `config/server/prefs.cs` while hosting, and restarts the timer
- `$AutoSave::Enabled`, `$AutoSave::Interval`, `$AutoSave::Chunk`, `$AutoSave::Tick`, `$AutoSave::Preview` are the live values
- `$AutoSave::Enabled`, `$AutoSave::Interval`, `$AutoSave::Chunk`, `$AutoSave::Tick`, `$AutoSave::Preview`, `$AutoSave::AutoLoad` are the live values
A value set on `$AutoSave::*` in the console is not saved, and a new interval does not take effect, until `autoSaveApply()` is called.
@@ -109,6 +125,4 @@ cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MIN
cmake --build build
```
The result is `build/AutoSave.dll`. CMake is set so the filename has no `lib` prefix. The link line is tsfuncs, MinHook, `psapi`, `gdiplus` (PNG to JPEG for the preview) and `shlwapi`, with static libgcc and libstdc++.
Source is `src/main.cpp` and `CMakeLists.txt`. The current DLL is attached to the latest release.
The result is `build/AutoSave.dll`. CMa