Rolly Docs

Bring saves over from Save Game to Slot

Keep players' progress when a released game that saved with the engine's Save Game to Slot moves to Rolly Save: read each old save once with Import Engine Save Game, copy its values into your game, and save them with Rolly Save.

Sheet
04 of 64
Rev
1.0.0
Updated
On this sheet

Import on first start

Do this where your game starts, such as in the main menu’s Begin Play (the Game Instance’s Event Init runs before Rolly Save starts, so the nodes fail there), before the player can save:

  1. List Rolly Slots. On Success with an empty Slots array, the player has no Rolly Save save yet, so continue; otherwise stop here.
  2. Import Engine Save Game with the Slot Name and User Index your game gave Save Game to Slot, and Expected Class set to the Save Game class it saved, the one given to Create Save Game Object.
  3. On Success, cast Save Game to that class and copy its variables into your game: the Game Instance, the player’s inventory, the registered objects that hold your game’s state.
  4. Call Save Game to Rolly Slot, so the progress is in a Rolly Save slot from now on.
  5. On Failure, Result’s Status says why. Not Found means the player has no old save: start a new game.

Import Engine Save Game never writes, deletes or lists engine saves. To remove the old save once it is copied, call the engine’s Delete Game in Slot yourself. It works on clients, on that machine’s saves.

What a failure means

Status When
Not Found No engine save of that name exists for that User Index
Wrong Class The save holds a class that is not Expected Class or a child of it; Detail names both. Nothing was created
Damaged The file is no engine save, is cut short, or its values do not read
Newer Version A newer engine wrote it, such as a save synced from a device with a later build
Storage Failed The platform’s save system could not read it
Invalid Input No Expected Class, a slot name that cannot be used, or the name of a Rolly Save file

What it reads

  • Saves of UE4 and UE5 engines whose header records the engine’s custom versions. An older file without them is Damaged.
  • The class is checked before anything is created. A Blueprint Save Game class that is not loaded yet is checked through the asset registry, then loaded without blocking the game; one the registry does not know as a child of Expected Class is Wrong Class, and nothing of it loads. A renamed class follows your +ClassRedirects, which for a Blueprint class name its path ending in _C.
  • Assets and types the save points at load without blocking the game before the values are set, after the asset registry confirms them. A path that is gone, or names an object that is no asset or type, such as an actor in a map, reads as empty and is listed in the result’s Issues.
  • Bounds: names and paths of more than 1,023 characters, texts nested more than 32 levels deep and sizes that point outside the file stop the read as Damaged, where the engine’s own Load Game from Slot would trust them. Import only the player’s own saves of your game’s earlier versions, never files players share: the engine reads each value’s bytes itself, and a hand-edited value can still stop the game at an engine assertion, or exhaust its memory in any build, since the engine allocates a container’s elements by the count the file gives.

In a packaged game, the Save Game class must be in the build: a Blueprint class that only old saves refer to is not cooked unless something cooked refers to it, or its folder is in Project Settings > Packaging > Additional Asset Directories to Cook.

From C++

#include "Game/RollySaveSubsystem.h"

URollySaveSubsystem::Get(this)->ImportEngineSaveGame(TEXT("SaveSlot"), 0, UMyOldSaveGame::StaticClass(),
	[this](const FRollySaveResult& Result, USaveGame* SaveGame)
	{
		// On a later tick. SaveGame is set only when Result succeeded.
		if (const UMyOldSaveGame* Old = Cast<UMyOldSaveGame>(SaveGame))
		{
			Inventory->Gold = Old->Gold;
		}
	});
C++

The Blueprint node is URollySaveImportAction (Nodes/RollySaveImportAction.h).