# Savecraft Save and load for multiplayer games. Add one component to an actor, tick SaveGame on the variables to keep, and it is saved: placed in the level or spawned in play, loaded or streamed out, owned by the world or by a player who left an hour ago. Only the server saves; clients get the result by replication. Unreal Engine 5.6, 5.7 and 5.8. Win64 and Linux (dedicated servers). C++, with every gameplay node, event and setting open to Blueprint. Uses only engine plugins (Online Subsystem, for cloud saves). Support: contato@tessaroapps.com  <video controls width="100%" src="img/savecraft_setup.mp4"></video> [The setup in the editor and a save and load in play, 30 s](img/savecraft_setup.mp4) **Start here:** [Set up in 3 steps](#set-up-in-3-steps) · [Recipes in Blueprint](#recipes-in-blueprint) · [Settings](#settings) · [FAQ and troubleshooting](#faq-and-troubleshooting) · [Node reference](reference.html) **All sections:** [Set up in 3 steps](#set-up-in-3-steps) · [What gets saved](#what-gets-saved) · [The component](#the-component) · [Scope: world, player or global](#scope-world-player-or-global) · [Saving and loading](#saving-and-loading) · [Slots](#slots) · [Recipes in Blueprint](#recipes-in-blueprint) · [Multiplayer](#multiplayer) · [World Partition and level streaming](#world-partition-and-level-streaming) · [Old saves and versions](#old-saves-and-versions) · [Cloud saves (EOS and Steam)](#cloud-saves-eos-and-steam) · [Settings](#settings) · [Crash safety](#crash-safety) · [Performance](#performance) · [Blueprint access](#blueprint-access) · [C++](#c) · [Console commands](#console-commands) · [FAQ and troubleshooting](#faq-and-troubleshooting) · [Known limits](#known-limits) · [Demo](#demo) · [Tests](#tests) ## Set up in 3 steps 1. **Tick SaveGame** on each variable to keep. In the Blueprint editor: select the variable, open **Advanced** in its Details, tick **SaveGame**. In C++: `UPROPERTY(SaveGame)`. A struct variable needs only its own tick: every member inside comes along.  2. **Add the Savecraft Saveable component** to the actor. Its **What Gets Saved** list shows what it found, right there in the Blueprint editor (it refreshes when the Blueprint compiles).  3. **Save and load** on the server: **Save Game (Savecraft)** with a slot name, **Load Game (Savecraft)** to put it back. Both run in the background and fire their pin when done. That is the whole setup. No save game class per game, no list of actors to keep up to date, no ids to assign by hand. ## What gets saved For each actor with the component: - its SaveGame variables, and those of its other components (turn off **Save Components** to skip them); - its transform (**Save Transform**, on by default; actors spawned in play always keep theirs); - whether a level-placed actor was destroyed: a barrel blown up stays gone after a load. Actors spawned in play come back as the same class (a Blueprint child included), in the same place, with their data. Actors spawned after the save and not in it are removed on load. **Objects inside a variable.** A SaveGame variable pointing to a plain UObject (an inventory item, say) saves that object's SaveGame variables too, nested objects and arrays included. The object's Outer must be the actor or one of its components. On load Savecraft reuses the object already there if the class matches, otherwise it makes one. Two variables of the same actor pointing to one object still point to one object after a load. An object shared between two different actors is saved once for each, so it comes back as two copies. **Checking your setup.** **What Gets Saved** lists every variable that will be written, on the component in the Blueprint editor and on actors placed in a level. If an actor has the component but no variable ticked, Map Check warns you. **Before a save, after a load.** Add the **Savecraft Saveable Interface** to the actor (or one of its components) for two events: **On Savecraft Pre Save** (put state that lives elsewhere into SaveGame variables) and **On Savecraft Loaded** (the variables are back; react to them, fix old saves). Both run on the server. ## The component | Property | Default | What it does | |---|---|---| | **Scope** | World | Who owns the actor: the world, a player, or the game (see below) | | **Save Transform** | on | Location, rotation and scale. Spawned actors always keep theirs | | **Save Components** | on | The SaveGame variables of the actor's other components too | | **Save Id** | set by Savecraft | The id of an actor spawned in play. Read only | | **What Gets Saved** | | The list described above, in the editor only | ## Scope: world, player or global | Scope | For | Found again by | |---|---|---| | World (default) | crates, doors, buildings, loot | its level name, or its save id when spawned in play | | Player | pawn, player state, a player's backpack actor | the player's online id | | Global | game state, game mode, a quest manager | its class (one of each, never spawned) | **Player** actors are given back when that player joins again, even if the server restarted in between. A player who leaves keeps their things in the save. A pawn that respawns in the same session doesn't get the save twice. A player who reconnects before the server noticed the old connection drop (a hard disconnect takes a timeout) gets the old connection's state, and the stale one never overwrites it. The id is the online id (the Steam id under Steam, the product user id under EOS). The listen server's own player is always `LocalHost` (`LocalHost2` and up for split screen), so a host keeps their save whatever account they are on. For LAN tests without an online subsystem, set **Player Id Source** to Player Name. **Get Player Id** gives the id of any player state. ## Saving and loading | Node | What it does | |---|---| | **Save Game (Savecraft)** | Saves in the background. **Saved** fires once the file is whole on disk, **Failed** if it could not start or finish. Both carry **Stats** | | **Load Game (Savecraft)** | Loads into the map that is open, a few ms of actors per frame. **Progress** every frame (0 to 1), then **Loaded** or **Failed** | | **Open Slot** | From a main menu: opens the map the slot was saved on, then loads it there. Options go on the map URL (`listen` to host) | | **Save Game Blocking**, **Load Game Blocking** | All of it before returning. For quitting, where there is no next frame | | **Set Next Save Thumbnail** | The next save's picture, from any render target (a Scene Capture 2D's) | | **Is Busy**, **Get Load Progress**, **Get Last Stats** | For a loading screen or a "saving..." icon | The same events are on the **Save Subsystem** (**Get Save Subsystem** from any Blueprint): **On Save Finished**, **On Load Finished**, **On Load Progress**. Only one save or load runs at a time; a second one returns false. **Autosave.** **Autosave Interval Seconds** in the settings (0 is off), or **Set Autosave Interval** at runtime for an options menu. **Autosave When Player Leaves** writes a player's things the moment they disconnect. An autosave never interrupts a save or a load already running. ## Slots A slot is one file, `Saved/SaveGames/Savecraft/<Slot>.svc`. Each carries its picture, map, date, time played, Save Version and a line of your own text. | Node | What it does | |---|---| | **Get All Slots** | Every slot, newest first. Works from a main menu, no world needed | | **Get Slot Info**, **Does Slot Exist** | One slot's info. **Recovered** is true when the main file was damaged and the backup was read | | **Load Slot Thumbnail** | The slot's picture as a texture, for a menu | | **Delete Slot** | The slot, its backup and any unfinished copy, on disk | | **Delete Slot Everywhere** | The same, and its cloud copy | Profiles or several players on one PC: **Get Savecraft Settings**, set **Save Folder** (`Profile2`, say) before reading slots or saving. Each folder has its own slots. ## Recipes in Blueprint       These are diagrams of the nodes to place, drawn in the look of a Blueprint graph. ## Multiplayer Only the server saves and loads. Clients never write the world; what a load changes reaches them by replication. Dormant replicated actors are woken after a load so clients see the new values. A client presses a key, your Run On Server event calls Save Game. The demo does exactly that. Tested with a dedicated server and a listen server: 4 clients at 150 ms and 5% packet loss, 2040 actors (2060 on a World Partition map), clients dropping hard and rejoining, the server killed and a new one loading the save. All machines end up with the same hash of every crate (see [Tests](#tests)). **Players the save knows.** **Get Known Player Ids** lists every player the next save will write: online, gone, or only in the loaded save. **Forget Player** drops one of them, for a character reset or a wipe. A forgotten player online keeps what they have until they leave, but none of it is saved; they start fresh when they come back. An actor out of a client's network relevancy (past its Net Cull Distance) isn't replicated, saved or not. That client sees the new values when it gets close, like any other replicated change. ## World Partition and level streaming A level actor whose cell or sublevel streams out leaves its state with Savecraft and gets it back when it streams in. A save made while it is out still has it. A load made while it is out keeps its record until the cell loads. No setup. Runtime data layers work the same way: actors in a layer that is unloaded during a save or a load get their values when the layer activates. Streamed sublevels may repeat actor names (two `BP_Door_0`): the sublevel's name is part of the key. ## Old saves and versions Adding or removing a SaveGame variable needs nothing: removed ones are skipped, new ones keep their default, and a variable whose type changed is skipped instead of read wrong. A level actor renamed in the level goes in **Renamed Level Actors** (Project Settings > Plugins > Savecraft): old name, new name. Old saves give the new actor the old one's record. In a streamed sublevel write `Sublevel.OldName`. For anything else (a value that changed meaning), raise **Save Version** in the settings. Every actor loaded from an older save gets **On Savecraft Loaded** with the version its file was written with: the place to fix it (see the recipe above). **Get Loaded Save Version** gives it to any Blueprint. In C++, `OnMigrateSave` hands you the whole save before any of it is applied: ```cpp SaveSubsystem->OnMigrateSave.AddLambda([](FSVCSaveData& SaveData, int32 SavedWithVersion) { if (SavedWithVersion < 2) { if (FSVCActorRecord* Chest = SaveData.FindWorldActor(TEXT("L:OldChestName"))) { Chest->Key = TEXT("L:NewChestName"); } } }); ``` A renamed class or variable can also go through Unreal's Core Redirects as usual. A file written by version 1.0 of the plugin is kept with the tests and loaded by every build, so an update never breaks your players' saves. ## Cloud saves (EOS and Steam) Slots can live in the player's online cloud: Epic's Player Data Storage under EOS, Steam Cloud under Steam. Savecraft goes through the engine's online subsystem, so the same nodes work with both. 1. Have the player signed in. With EOS that is the EOS plugin set up as usual (Project Settings > Epic Online Services, an artifact, and Connect or an Epic account login). 2. Project Settings > Plugins > Savecraft > Cloud: tick **Upload After Save**. If Steam is the default online subsystem and the cloud should be Epic's, write `EOS` in **Cloud Subsystem**. 3. After the player signs in, before the slot list shows, call **Sync With Cloud (Savecraft)**. **Synced** gives how many slots came down and went up. How it decides: every slot file carries the time it was saved. Sync downloads each slot the cloud has newer (or this machine lacks) and uploads each one this machine has newer. A tie keeps both as they are. A damaged copy on either side never wins over a whole one, and a cloud file name with a path in it is ignored. - **Delete Slot Everywhere** deletes on disk and in the cloud. The plain **Delete Slot** only touches the disk, so the next sync brings the slot back. - **Upload Slot** sends one slot up by hand. **On Cloud Finished** fires after every job, with what it did. - Jobs wait in line, one at a time. Nothing blocks the game thread. - It needs a signed-in local player: a single player game, a listen server host, or a client keeping its own slots. A dedicated server has no player and skips it. - EOS names a file by its slot: keep slot names short (Epic allows 64 characters with the `.svc`). Tested against real EOS Player Data Storage, signed in through Steam: a save goes up by itself, the file deleted from disk comes back byte for byte on the next sync, and Delete Slot Everywhere removes it for good. Steam only, no code at all: in Steamworks, turn on Auto-Cloud for the save folder (`Saved/SaveGames/Savecraft` by default), with `*.svc` as the pattern, and leave Upload After Save off. Use one or the other, not both. ## Settings Project Settings > Plugins > Savecraft. **Get Savecraft Settings** reads and changes every one of them from Blueprint at runtime (not written back to the ini).  | Setting | Default | What it does | |---|---|---| | **Save Version** | 1 | Raise it when a change needs old saves fixed (see [Old saves and versions](#old-saves-and-versions)) | | **Save Folder** | Savecraft | Folder for the slots, inside `Saved/SaveGames`. An absolute path is used as it is | | **Compress** | on | Oodle on the save data: about 3 times smaller, the work off the game thread | | **Keep Backup** | on | The previous file stays as `.bak`; a damaged main file falls back to it | | **Renamed Level Actors** | empty | Old name, new name, for level actors renamed after saves were made | | **Save Budget Ms** | 0 | 0: a save reads every actor in one frame, an exact picture. Above 0: over several frames, this long each (see [Performance](#performance)) | | **Load Budget Ms** | 4 | How long each frame may spend putting actors back on load | | **Autosave Interval Seconds** | 0 | Autosave on the server every this many seconds. 0 is off | | **Autosave Slot** | Autosave | The slot autosaves write to | | **Autosave When Player Leaves** | off | Writes a player's things the moment they leave | | **Player Id Source** | Online Id | What finds a player again: the online id, or the player name for LAN tests | | **Upload After Save** | off | Every save also goes to the signed-in player's cloud | | **Cloud Subsystem** | empty | The online subsystem with the cloud. Empty is the game's default; `EOS` uses Epic's storage while Steam is the default | ## Crash safety A save never touches the last good file until the new one is whole on disk. It is written to `Slot.svc.tmp`, flushed, the old file becomes `Slot.svc.bak`, and the new one takes its place. Every file ends with a CRC32 checked on load: - killed while writing: the old save loads; - killed between the two moves: the new save loads from the `.tmp`; - main file damaged later (disk, another program): the backup loads, and **Recovered** says so.  Tested by killing the game mid-save for real, 20 times in a row: every run left a whole file (see [Tests](#tests)). ## Performance Measured on the demo's crates (each with 2 SaveGame variables, the component and a mesh), Unreal 5.8, Development build, an idle machine (`Tools/perf_test.sh`): | 10,040 actors | Save Budget Ms 0 (default) | Save Budget Ms 4 | |---|---|---| | Game thread, in all | 19 to 28 ms | 29 to 37 ms | | Longest frame | the same, in one frame | 4.00 ms, over 8 to 11 frames | | Save, start to file on disk | 69 to 103 ms | 119 to 193 ms | | File | 568 KB (1.58 MB before compression) | the same | | Load, game thread | 30 to 38 ms, spread at 4 ms per frame (Load Budget Ms) | the same | **Save Budget Ms** spreads the reading of actors over frames. The default of 0 takes an exact snapshot in one frame. Above 0 the save is not a single instant: an item moved from a chest to a player while it runs can land in both or in neither. Use it for big worlds, and keep 0 if your game moves valuables around during autosaves. Each class's SaveGame variables are listed once and cached. A record holds only the values; names and types are written once per class per file. ## Blueprint access Every node, event, setting and field a game needs is open to Blueprint: saving, loading, slots, pictures, progress, stats, players, versions, cloud, and all the settings at runtime. **Savecraft Saveable** takes a Blueprint child. The [node reference](reference.html) lists all of them with what each does, made from the plugin's headers. `Tools/check_blueprint_api.sh` proves it in the editor with no window: it makes a Blueprint child of the component, compiles it, and finds every one of 82 nodes, events, settings and fields through reflection, the way a Blueprint graph sees them. What stays in C++: `OnMigrateSave` (the whole save as raw records, before any of it is applied). On Savecraft Loaded and Renamed Level Actors cover the same cases in Blueprint. ## C++ - `USVCSaveSubsystem` (a world subsystem): `SaveGame`, `SaveGameBlocking`, `LoadGame`, `LoadGameBlocking`, `SetNextSaveThumbnail`, `IsBusy`, `GetLoadProgress`, `GetLastStats`, `GetPlayTimeSeconds`, `GetPlayerId`, `GetLoadedSaveVersion`, `GetKnownPlayerIds`, `ForgetPlayer`, `SetAutosaveInterval`, `OnSaveFinished`, `OnLoadFinished`, `OnLoadProgress`, `OnMigrateSave`. - `USVCCloudSubsystem` (a game instance subsystem): `SyncWithCloud`, `UploadSlot`, `DeleteSlotEverywhere`, `IsCloudBusy`, `GetLastResult`, `OnCloudFinished`. - `USVCGameInstanceSubsystem`: `OpenSlot`. `USVCBlueprintLibrary`: the slot functions and `GetSavecraftSettings`. - `ISVCSaveableInterface`: `OnSavecraftPreSave`, `OnSavecraftLoaded`. Mark C++ variables with `UPROPERTY(SaveGame)`. The module is `Savecraft`; add it to your Build.cs to call these from C++. ## Console commands - `Savecraft.Dump <slot>`: what the slot holds (actors, players, sizes) as JSON next to it. - `Savecraft.CloudSync`, `Savecraft.CloudUpload <slot>`, `Savecraft.CloudDelete <slot>`: the cloud jobs for local player 0, results in the log. ## FAQ and troubleshooting **A variable doesn't come back.** Check What Gets Saved on its actor's component. Not in the list: SaveGame is not ticked, or the variable is on a component with Save Components off. In the list but wrong after a load: something sets it after the load (BeginPlay of a respawned actor, a timer). Set it in On Savecraft Loaded instead, or skip your default when the actor was loaded. **Load Game returns false.** Another save or load is running (Is Busy), the slot doesn't exist or is damaged with no backup, or it was called on a client. Saves and loads run on the server only. **A destroyed crate comes back after a load, or one that should come back doesn't.** A level actor destroyed in this session can't come back from a load in place: the level no longer has it. Use Open Slot, which opens the map fresh and then loads. **A client sees old values.** The actor is out of that client's network relevancy (Net Cull Distance). It updates when the client gets close. Raise the cull distance on actors that must be seen from afar. **Players lose their things on a LAN test.** With no online subsystem every client has an empty online id. Set Player Id Source to Player Name for tests. **Cloud sync fails with "not signed in".** The cloud needs the player signed in to the online subsystem first (Steam running, or the EOS login done). On a dedicated server there is no player: the cloud is for player machines. **Cloud sync fails with a Steam ticket error under EOS.** The Steam App ID must be the one the EOS product's Steam identity provider expects. With app 480 (Spacewar) EOS refuses the ticket. **Where are the files?** `Saved/SaveGames/Savecraft/` in the project while developing, `%LOCALAPPDATA%/<Game>/Saved/SaveGames/Savecraft/` in a packaged Windows game. ## Known limits - A level actor destroyed earlier in the same session can't come back from a load: the level doesn't have it any more. Open the map, then load (that is what **Open Slot** does). - A loose UObject whose Outer is not the saving actor or its component is saved only as a reference. - Components added at runtime are matched by name; give them a fixed name if they hold SaveGame variables. - Consoles and Mac: plain engine code, not tested yet. ## Demo **Try it without the engine:** [SavecraftDemo_Win64.zip](https://github.com/filipetessaro/savecraft-demo/releases/latest/download/SavecraftDemo_Win64.zip) (215 MB), a Windows Shipping build. Unzip, run `SavecraftDemo.exe`; for two players, one runs `Host.bat` and the other `Join.bat`. In the source, open `SavecraftDemo.uproject` and press Play. The map has 40 crates with the Saveable component and two SaveGame variables, Coins and Health. Fly with WASD and the mouse, left click a crate for +10 coins (and +1 gold for you, saved with your player), right click to destroy it, E to spawn a new one. 1, 2 and 3 pick a slot, F5 saves, F9 loads, Delete empties the slot. Each slot shows its picture, date, time played and a line of text. | | | |---|---| |  |  | |  |  | Played alone, F9 reopens the map and loads, so destroyed crates come back too. With other players connected it loads in place and nobody is kicked. Clients press the same keys; the server does the saving. ## Tests - `Tools/run_tests.sh`: the automation tests, headless (`Savecraft.*`, 12 tests): file format, crash safety, save and load, background save, sliced save, streaming, players (rejoin, reconnect, forget), migration, old version file, codec tolerance, loose objects, cloud sync against a cloud kept in memory (damaged files and odd names included). - `Tools/net_test.ps1`: dedicated or listen server, 4 clients at 150 ms and 5% loss, 2000 crates, clients dropping and rejoining, the server killed and restarted from the save. `-WorldPartition` runs it on a World Partition map. - `Tools/kill_test.ps1`: kills the game mid-save 20 times and checks every leftover file. - `Tools/datalayer_test.sh`: saves with a runtime data layer unloaded and loads it in a new process. - `Tools/eos_cloud_test.sh`: cloud saves against real EOS, signed in through Steam. - `Tools/perf_test.sh`: the numbers in Performance. - `Tools/check_blueprint_api.sh`: the Blueprint access check. ## Changelog ## 1.0 - Savecraft Saveable component: any actor, its SaveGame variables, its components' and its transform. What Gets Saved in the Blueprint editor and on placed actors, Map Check warning. - World, player and global scope. Players found again by online id after a server restart, a hard disconnect or a rejoin. Get Known Player Ids, Forget Player. - Save Game and Load Game (Savecraft) async nodes, blocking versions for quitting, Open Slot from a main menu, slots with picture, date, play time and text. - World Partition cells, streamed sublevels and runtime data layers that are unloaded during a save or a load. - Loose UObjects inside SaveGame variables, nested and shared. - Save Version with On Savecraft Loaded, Renamed Level Actors, OnMigrateSave in C++. - Crash-safe file: .tmp, .bak and CRC32. Oodle compression. Save and load spread over frames. - Cloud saves through the online subsystem: EOS Player Data Storage and Steam Cloud. Sync With Cloud, Upload After Save, Delete Slot Everywhere. - Every setting readable and settable from Blueprint at runtime.