
SmartSave
Don't lose progress when the game crashes. Saves your character after crafting, chest changes, tombstone recovery and before teleports, never moves your respawn point in combat, and makes every save much faster. Client-side.SmartSave
Don't lose your progress when the game crashes.
Valheim saves your character (inventory, equipment, skills, recipes, map) only every few minutes, or every 30 minutes without a server setting. When your game crashes, everything since that save is gone:
- the armor you just crafted, and the materials it used up,
- items you moved in or out of a chest: duplicated or lost for good, because the chest is saved on the server but your bag isn't,
- your whole corpse run, if you had just emptied your tombstone,
- skill levels, new recipes, a forsaken power.
SmartSave saves your character at exactly those moments: after crafting, after closing a chest, after taking your tombstone, right before every teleport, and more. A crash costs you seconds, not minutes.
It never moves your respawn point while you are fighting, falling or swimming, so after a crash you don't reconnect into the fight.
And it makes saving much faster, including the game's own autosave. The explored map, the slowest part of every save, is built in one go and reused when nothing changed: under 1 ms instead of ~200 ms. Double saves are skipped. With a local character a save takes about 20 ms, barely noticeable.
Client-side only. The server doesn't need it, and it works on any server and in single player, with local or Steam Cloud characters.
Source code, issues and ideas: github.com/nfp007/smartsave
When it saves
| Moment | What happens |
|---|---|
| Crafting, upgrading, repairing | Saves when you close the crafting window (one save, however many items you made) |
| Closing a chest | Saves if your inventory changed while it was open. Chest to chest gives one save, not ten |
| Tombstone | Saves right after you take everything back |
| Before a teleport | Portals, Portaler, dungeon entrances, any mod that teleports. Loading screens are where games like to crash. By default this save also writes the map |
| After arriving | Saves 5 seconds after a teleport |
| Boss / forsaken power | Saves after a boss dies near you or when you take a new power |
| Skill level up, new recipe | Saves at the next calm moment |
| After combat | Anything that waited is saved when the fight is over |
| F6 | Save right now, everything including the map |
| Fallback | If nothing saved for 30 minutes, it saves at the next safe moment |
Two kinds of save
- Inventory save (items, skills, map): fine almost any time.
- Logout point (where you appear after a crash or reconnect): only moved when you stand on solid ground and are not in combat, not swimming, not riding and not mid-air.
So a crash in the middle of a fight brings you back with your items, but not into the fight.
SmartSave also fixes this for the game's own server save: with -saveinterval, the server tells every client to save, and vanilla always moves your logout point, even mid-fight. SmartSave keeps the save but leaves the logout point where it was.
Combat is detected from the game's own combat-music state, damage you take, your own attacks and blocks, and alerted enemies within 30 m that target you.
How long a save takes
Every character save freezes the game for a moment. That's the game's own save routine, the same as its regular autosave. Two things decide how long it takes: whether the explored map is written, and where your character is stored.
Measured on a normal PC (normal frame 10-20 ms):
| Character storage | Save with the game's map save | Save with SmartSave's map save | Save without map |
|---|---|---|---|
| Local | ~200-280 ms | ~20 ms when the map is reused, ~70 ms* right after exploring | ~20 ms, barely noticeable |
| Steam Cloud | ~300-400 ms | ~100-300 ms (almost all of it the Steam Cloud file handling) | ~100-140 ms |
With SmartSave the map part of a save takes under 1 ms when the map is reused, and ~50 ms when it has to be built because you just explored.
* Calculated from the measured parts (map ~50 ms plus the rest of a local save ~20 ms), not measured as a whole.
Faster map save. The game builds the map data for a save one point at a time, about 8.5 million steps. SmartSave builds the same data in one go: about 10 ms instead of 140-230 ms, plus ~40-60 ms for compressing it. This makes the game's own saves faster too.
Reusing the map. If your explored map and pins haven't changed since the last save, SmartSave reuses the last map data (under 1 ms). If they have changed, SmartSave prepares the map data in the background every minute (MapPrewarmSec), on another CPU core, so the next save can usually reuse it too.
Safeguard: once per game start, when you join a world (usually behind the loading screen), SmartSave builds the map data both ways, its own and the game's, and compares them byte by byte. Only if they are identical does it use its faster version for the rest of the session. If they differ (after a game update, or because another mod changes the map data), it switches back to the game's own map save and writes a warning to the log.
No double saves. The game's own regular save (the server's save interval, or the game's 30-minute timer) is skipped if a full save, with the map and your position, already ran within the last 30 seconds (SkipRepeatSaveSec). Saves when quitting, logging out or sleeping are never skipped.
The map is still the biggest part of a save. By default (MapSave = OnPortal), only the save right before a teleport writes it. The other SmartSave saves keep your items, skills and position safe and leave the stored map as it was. The map is also saved by the game's own saves (server save interval, logout) and by F6. After a crash you can lose map exploration and new pins since the last save that wrote the map. Never items. Because the map is reused when nothing changed, MapSave = Always now costs little: under 1 ms for the map most of the time, ~50 ms right after exploring.
Local instead of Steam Cloud makes every save faster still, SmartSave's and the game's own. With Steam Cloud, replacing the character file alone takes about 70-85 ms. With a local character it's about 1-2 ms. You can move a character between Steam Cloud and local storage in Valheim's Manage saves menu (main menu, character selection). A local character isn't synced to other PCs and isn't backed up by Steam, so keep your own backups.
Settings
All settings are in BepInEx/config/nfp007.SmartSave.cfg (also in ConfigurationManager, F1).
| Section | Setting | Default | |
|---|---|---|---|
| General | Enabled |
true | |
| General | LogSaves |
true | One line per save in the BepInEx log, with the reason |
| General | SaveMessage |
Off | Small "Saved" message top left: Off, Important (crafting, chests, tombstone, boss) or All. F6 always shows it |
| General | MinSaveIntervalSec |
15 | Cooldown between two less important saves (arrival, boss, end of combat, skill up, recipe, fallback). Never triggers a save itself; important saves ignore it |
| General | ManualSaveKey |
F6 | None = off. Always saves everything, including the map |
| General | FastMapSave |
true | Builds the map data much faster and reuses it when nothing changed, for SmartSave's saves and the game's own. Same result; checked against the game once per start, and switched off by itself if they ever differ |
| General | MapPrewarmSec |
60 | Every this many seconds, if the map changed, prepare the map data in the background. 0 = off |
| General | SkipRepeatSaveSec |
30 | Skip the game's own regular save if a full save ran within this many seconds. 0 = off |
| General | MapSave |
OnPortal | When SmartSave's saves also write the explored map (see above): OnPortal, Always, Never |
| Triggers | SaveAfterCrafting / SaveOnChestClose / SaveOnTombstone |
true | |
| Triggers | GuiCloseDelaySec |
1.5 | The window must stay closed this long before the save |
| Triggers | GuiMaxDelaySec |
20 | Window open longer than this after a change: save anyway |
| Triggers | SaveBeforeTeleport / SaveAfterTeleport |
true | |
| Triggers | ArrivalDelaySec |
5 | |
| Triggers | SaveOnSkillLevelUp / SaveOnNewRecipe / SaveOnBossKill / SaveAfterCombat |
true | |
| Triggers | FallbackIntervalMin |
30 | 0 = off |
| Combat | CombatCooldownSec |
10 | "In combat" for this long after damage or an attack |
| Combat | CombatScanRadiusM |
30 | |
| Combat | AllowProfileSaveInCombat |
true | Important saves keep your items in combat (logout point unchanged) |
| Combat | SafeServerPushSave |
true | The server's regular save doesn't move your logout point in combat |
| Server | RequestWorldSaveAsAdmin |
false | Admins only: also ask the server to save the world after important saves. Makes everybody stutter |
| Server | WorldSaveMinIntervalMin |
5 | |
| Debug | Profiling |
false | Measures every save (SmartSave's and the game's own) and writes the times to the BepInEx log and BepInEx/SmartSave_profile.csv. Needs a restart |
Good to know
- Each save takes a moment (see above). That's why there's a cooldown and saves are merged.
- Chests, buildings and tombstones live on the server, so a crash of your game doesn't touch them. Your character file is on your PC, and that's what SmartSave protects.
- It doesn't stop the game from crashing. It makes sure a crash costs you as little as possible.
- If another map mod misbehaves (pins or map not saved as expected), set
FastMapSave = false. Everything is then back to the game's own map save. - On a host (non-dedicated) SmartSave never delays the world save.
Installation
With a mod manager (Gale, r2modman, Thunderstore App): install SmartSave.
By hand: install BepInExPack Valheim, then copy SmartSave.dll into BepInEx/plugins/.