Skip to content

Persistence

Summary: Persistence saves and restores a player's complete character — inventory, equipment, glyphs, quests, compendium, and world-map progress — through a single component that delegates to a swappable provider. A UPersistenceComponent on the player controller selects one of three providers (local file, remote backend, or read-only curated preset) by who plays the character and where it runs, then drives auto-save and an initial auto-load. The provider abstraction lets the same save-data shape and restore pipeline serve a player's own character file, a dedicated-server REST call, or a shipped demo "play-as" build. Character files live in a per-user folder, are written atomically with a backup, and carry a save version a newer build's file is never loaded under.

Table of Contents


Architecture Overview

+--------------------------------------------------------------+
|  AEternalPlayer (PlayerController)                            |
|                                                              |
|   +------------------------------------------------------+   |
|   |  UPersistenceComponent                               |   |
|   |  - CharacterId / AccountId (FGuid identity)          |   |
|   |  - Auto-save timer + save/load guards               |   |
|   |  - Selects ONE provider in InitializeProvider()     |   |
|   +-----------------------+------------------------------+   |
|                           |  IPersistenceProvider           |
+---------------------------|----------------------------------+
                            |
        +-------------------+-------------------+
        v                   v                   v
+----------------+  +----------------+  +-------------------------+
| Local provider |  | Remote provider|  | Preset provider         |
| JSON file      |  | REST API       |  | (READ-ONLY)             |
+-------+--------+  +-------+--------+  +-----------+-------------+
        |                   |                       |
        v                   v                       v
  <SaveRoot>/<User>/  eternal-server         UPresetCharacterAsset
  Characters/{Id}.json (PersistenceApi)      .Payload (cooked asset)

         All three speak the SAME FCharacterSaveData struct,
         and load runs the SAME restore pipeline:
         UPersistenceHelpers::RestoreCharacterFromSaveData()

Key Design Principles

Principle Rationale
One component, swappable provider Same save/load lifecycle whether solo, networked, or demo
Provider is an interface, not a branch IPersistenceProvider keeps storage mechanism out of the component
One save-data struct for all backends Local file, REST body, and preset payload are identical FCharacterSaveData JSON
Component lives on the controller Persistence must outlive pawn death (see System Ownership)
Server authority on save/load Clients never write; only the authority builds and restores state

Core Concepts

Why a Provider Abstraction?

The character-save shape and the restore logic are stable, but where the data lives is not: a player's own character is a file on their machine (solo, or as a listen host), a dedicated server round-trips through the backend, and a shipped demo loads a curated character that is never written back. Rather than branch on net mode throughout the component, the storage mechanism is hidden behind IPersistenceProvider. The component asks the provider to SaveCharacter / LoadCharacter and reacts to a completion delegate — async for remote, immediate for local — without knowing which backing store it is talking to.

Why the Component Lives on the Player Controller

Inventory and equipment must survive pawn death, so the save/load owner sits on AEternalPlayer (the player controller) rather than the pawn. During teardown the pawn — and the equipment/glyph data it transitively reaches through PlayerState — is destroyed before the component's EndPlay. The component therefore caches the equipment and quest component pointers in BeginPlay, and the authoritative save is the auto-save timer, supplemented by an explicit RequestSave() from AEternalGameMode::Logout while the pawn is still intact. EndPlay deliberately does not save.


Provider Selection

UPersistenceComponent::InitializeProvider() (called from BeginPlay) picks exactly one provider. A configured preset always wins; otherwise SelectProviderKind(Mode, NetMode, bLocalController, bPresetActive) picks the store by who plays the character and where. The rule is a pure static, so ProjectEternal.Persistence.ProviderSelection checks every row below without a world.

Provider Modes

EPersistenceProviderMode is a developer's override and lives in per-user editor config: UPersistenceDevUserSettings (config=EditorPerProjectUserSettings, Editor Preferences > Game > Persistence (Dev, this machine), or the toolbar's Persistence menu, which saves to Saved/Config/WindowsEditor/EditorPerProjectUserSettings.ini). It used to sit in the shared DefaultGame.ini, where a mode flipped for a test kept being committed with unrelated work. Config/DefaultEditorPerProjectUserSettings.ini sets editor sessions to Local, so a PIE dedicated server never calls the backend (its players' controllers are not saved; see Per-Player Identity); packaged builds never read editor config and always run Auto.

Mode Behaviour
Auto Remote on a dedicated server; the local file for this machine's own players; a listen host's guests bring theirs
Local The local file, even on a dedicated server (dev); a listen host's guests still bring theirs
Remote The remote backend provider; a listen host's guests still bring theirs
Preset Always load the configured read-only DefaultPreset (a developer's test of a preset; nothing ships it)

Precedence Chain

Preset selection is resolved first, by ResolveActivePreset(), and short-circuits local/remote selection entirely:

  1. GameInstance PendingPreset  ──►  menu selection survives OpenLevel()  ──► PRESET (read-only)
        | (null)
        v
  2. ProviderMode == Preset      ──►  a developer's forced mode            ──► PRESET (read-only)
        | (no)
        v
  3. a listen host's remote guest                                           ──► COOP GUEST
        | (no)
        v
     any client                                                             ──► NONE
        | (no)
        v
  4. ProviderMode == Remote                                                 ──► REMOTE
        | (no)
        v
  5. ProviderMode == Local, or not a dedicated server                       ──► LOCAL
        | (no)
        v
  6. a dedicated server                                                     ──► REMOTE
Character Where it runs Store
A chosen preset anywhere Preset (read-only)
The player's own solo, or the listen host's own controller Local file
A guest's a listen host (the guest's controller there) CoopGuest, under every mode: the guest's file is on the guest's machine, so the guest uploads it (see A Guest's Character); any store of the host's would hand the guest the host's character
Any a client None: clients never save or load
Online a dedicated server Remote

With no store (a client), the component has no provider: nothing loads, no auto-save timer starts, and a save request does nothing. A listen host's menu preset applies to its own players only; a guest brings its own.

A Guest's Character

A listen host admits one guest (AEternalGameMode::PreLogin sets GameSession->MaxPlayers to 2 and MaxSpectators to 0 on a listen server; the next login is refused as "Server full"). The guest's character comes from the guest's machine:

Guest (client)                                   Host (listen server), the guest's controller
--------------                                   -------------------------------------------
                                                 BeginPlay: kind CoopGuest, no identity, no auto-save
                                                 next tick: LoadCharacter waits; 30 s timeout armed
                   ◄── Client_RequestCharacter
GI pending preset?   ──► Server_PlayPreset(path)        only a CharacterPreset primary asset; read-only
roster character?    ──► Server_BeginUpload(header)     size, version, offline, not already in the session
                   ◄── Client_UploadAccepted / Client_UploadRefused + kick
chunks (≤16 KB, 4 ahead of their acks) ──► Server_UploadChunk  in order, sized, CRC32 at the end
                   ◄── Client_UploadChunkAck
                                                 JSON → FCharacterSaveData → migrate → restore (world map untouched)
                   ◄── Client_CharacterReady     the guest's first spawn, held until now, goes ahead
none of these        ──► Server_PlayWithoutCharacter     plays a character that is not saved
  • The wait is the load: UCoopGuestPersistenceProvider::LoadCharacter completes when the character has arrived, and HandleStartingNewPlayer queues a guest's first spawn only on OnInitialLoadFinished, so the guest enters with its own gear. IsAwaitingGuestCharacter keeps every other path from spawning it early: the spawn manager's spawn-all pass and a transition's everyone-placed check (a client's own ServerRestartPlayer can still spawn it early; that only hurts that guest). A refusal or the timeout (re-armed by every chunk) disconnects the guest (GameSession->KickPlayer) with the reason; anything it still sends is ignored.
  • Checks (cheating is accepted; these catch mistakes): at most 2 MB of JSON; a save version this build can read (a newer one is refused before it arrives, and again inside the JSON); an offline character; the id announced; a character no other player in the session plays (GetCharacterInPlay); a CRC over the compressed bytes. A second upload from the same guest is refused.
  • Transfer: FSaveBlob (Oodle, CRC32), FSaveBlobSender / FSaveBlobReceiver. A full character is about 9 KB compressed, one chunk; the window and chunking keep a larger blob (a stash, later) inside one reliable RPC's 64 KB and the connection's reliable buffer.
  • The host keeps nothing: the provider refuses every save (before the character arrives it would write an empty one; after, the guest's own machine writes the guest's file). BuildCharacterSaveData leaves the world map out for a guest, as restore already did. The guest's progress goes back to the guest's machine as snapshots (next section).
  • Dev: Eternal.JoinAsCharacter <address> [CharacterId] joins bringing a saved character (else the last saved), and puts ?Character=<id> on the join URL so a rejoin is recognised.

A Guest's Progress Back

The host owns the guest's live character, so the host builds the saves; the guest's machine owns the file, so the guest writes them. A guest never saves on its own during a game in a host's world: every write is a host snapshot.

Host, the guest's controller                       Guest
----------------------------                       -----
checkpoint → RequestGuestSnapshot
  one in flight; requests meanwhile coalesce
  FCoopSnapshot {Sequence, Character, NodeResults, bHostLeaving}
  JSON → FSaveBlob "Snapshot"
Client_BeginSnapshot(header)            ──►        UCoopGuestSubsystem::AcceptSnapshotHeader
Client_SnapshotChunk × n (4 ahead)      ──►        AcceptSnapshotChunk → after the last: WriteSnapshot
                                        ◄──        Server_SnapshotChunkAck(i)
                                        ◄──        Server_SnapshotDone(Sequence, bWritten)
acked node results dropped; a wanted snapshot goes next
  • Checkpoints: the auto-save timer (it runs for a guest's controller too; RequestSave there becomes a snapshot), every node clear while the guest is present, a change to the guest's inventory (an item handed over or picked up; one snapshot 2 s after the burst settles), the guest's Leave and the host's Quit / Return to menu.
  • Order: each snapshot carries a Sequence; the guest writes only one newer than its last write (an older or repeated one counts as written and changes nothing). A snapshot the guest never confirms is given up after 30 s. Snapshots are at least 1 s apart (a host on its way out does not wait), so a guest that keeps failing them cannot keep the host rebuilding them; the guest reports a failed snapshot once and drops the rest of its chunks.
  • Node clears: UWorldMapSubsystem::MarkNodeCleared broadcasts OnNodeCleared(NodeID, Tier, ClearSequence); the guest's controller records an FCoopNodeResult with the host's tier (the domain's CurrentTier) and the host's clear sequence, and resends it in every snapshot until one with it is written. The guest credits each clear sequence once per game, to the world map in its file, with FWorldMapCoopCredit::ApplyClear; its CurrentNodeID stays. A guest with no map data to credit them to writes the rest and does not confirm, so the host sends the clears again.
  • The merge (FCoopSnapshotMerge::Merge): gear, quests and compendium come from the snapshot; identity, name, class, type, SaveSequence and the world map come from the guest's file. A write that fails leaves its clears to be credited by the next snapshot. A snapshot of another character is refused.
  • Leaving: the guest's Change Preset / Return to menu / Quit calls LeaveHostGame: Server_RequestLeave, the host sends a snapshot built after the request (one already in flight does not answer it), the guest writes it, Client_LeaveAnswered, then the guest goes. 5 s cap. The host's Quit and Return to menu call FlushGuestsBeforeLeaving: a final snapshot (bHostLeaving) to every guest, a "Saving…" notification, and a wait of up to 5 s for the guests' confirmations before the host saves itself and goes.
  • A game that ends without the guest leaving (GEngine NetworkFailure / TravelFailure on the guest's link to its host, or a refusal): the engine travels to the menu, and UMainMenuController::ShowMainMenu shows UCoopGuestSubsystem::TakeMenuMessage() once: "Connection lost. Progress saved at 15:01.", "The host ended the game. …", "… Nothing was saved during this game." or "The host could not take your character: ". The file holds the last written snapshot; a partial snapshot never reaches it.
  • Rejoin: a guest that crashed and comes back with the same character (?Character=<id> on the join URL) is let in: AEternalGameMode::PreLogin finds the remote controller still holding that character, checks it is the same player (the same online id; under the null online subsystem, whose ids change every launch, the same address), releases it (ReleaseForRejoin: no more snapshots, no longer "in play") and kicks it, and admits one extra player for as long as the stale connection takes to close. The clears the old connection never got confirmed pass to the new one (TakeRejoinResults) and go in its first snapshot. A join without the option is refused as before until the old connection times out (about 60 s); a guest that never comes back keeps its last written snapshot.
  • Cost: under -PktLag=100 -PktLoss=2 on both machines a snapshot (one chunk) or a 220 KB blob (14 chunks) left the round trip of other reliable RPCs unchanged (p95 about 430 ms with and without it); the transfer shares the controller's channel.
  • Dev: Eternal.Coop.MeasureLatency <Seconds> <BlobBytes> (on a guest), Eternal.WorldMap.ClearNode <NodeID>, Eternal.Dev.After <Seconds> <Command…>, GameMenu.Quit.

The menu-selected preset is carried on the GameInstance because it is the only object that survives the OpenLevel() from the menu into the gameplay map (see Game Framework → Pending Preset Carrier). A chosen saved character rides the same way, as the roster's PendingCharacterId (see Character Roster).

No Backend Offline

A game that is not a dedicated server makes no backend call: EnsureAccountExists runs only with the Remote provider, and USessionComponent registers the "Game Room" only on NM_DedicatedServer. An offline game must load with nothing reachable.


Character Files

Where They Live

FSaveLocation names the folder:

<SaveRoot>
  Packaged, any configuration: %LOCALAPPDATA%\ProjectEternal\Saved\SaveGames\
  Editor / PIE:                <Project>/Saved/SaveGames/
<SaveRoot>/<UserFolder>/Characters/<CharacterId>.json        FCharacterSaveData
<SaveRoot>/<UserFolder>/Characters/<CharacterId>.json.bak    the previous good copy
  • The root is the user's app data in every packaged build. A Development build's own Saved folder sits next to the executable, inside the install, where an uninstall deletes it and cloud sync would need a second root. ResolveSaveRoot builds the same layout a Shipping build's Saved folder already has.
  • The user folder keeps two platform users on one machine apart: Steam/<SteamID64> for the signed-in Steam user (read from the Steam online subsystem's identity; nothing touches Steam's storage), Epic/<EpicAccountId> when the Epic launcher passed -epicuserid=, else Local. It is resolved once per process. Ids are reduced to letters, digits, - and _. The editor always uses Local.
  • Old dev saves at the top of Saved/SaveGames/ (<CharacterId>.json, from before the user folders) are moved into Local/Characters/ in editor builds, when the roster first lists and by a load that finds nothing. Not at start-up: every game instance initializes its subsystems, specs' included.

Writing

ULocalPersistenceProvider::SaveCharacter never leaves a half-written file where a character was:

  1. serialize to JSON (UTF-8, no BOM) and write <file>.tmp;
  2. if the current file reads as a character save, move it to <file>.bak; if it is torn, delete it and keep the existing .bak, which is the last good copy;
  3. rename .tmp over <file>.

Every write is stamped with the id it is saved under, SaveVersion 2, LastWriterDevice (FSaveLocation::GetWriterDeviceName: "PC" or "Steam Deck") and SaveSequence one past the higher of the incoming data and the copy on disk.

The component adds what nothing in play holds: the loaded CharacterName, PlayerClassTemplateId, PlayTimeSeconds and CharacterType ride along on every save (before, a save wrote them empty). It also writes nothing until the initial load has finished: before then the controller holds only the starting state.

Loading

LoadCharacter reads <file>; if it is missing, empty, does not parse, or does not name this character (no CharacterId, or another character's: any JSON object parses), it reads <file>.bak (logging a warning). Both reads upgrade an older save through FCharacterSaveMigration (version 1 → 2: an offline character, no counted writes, no known writer). Then:

On disk Load Later writes of that character
A good file, or a good backup Succeeds Allowed
Nothing Fails ("Save file not found") Allowed: it is a new character
A file written by a newer build (main or backup) Fails: "update the game" Refused
A file, but neither it nor its backup reads Fails Refused

A refused character keeps its files exactly as they were, for a newer build or a person to recover: this build's JSON reader drops fields it does not know, so writing a newer save back would strip them, and writing over an unreadable file would bury what is left of it. A newer build's save is refused even by a provider that never loaded it.

Deleting

DeleteSaveData renames <file> and <file>.bak to .deleted, so a mistaken delete can be undone by hand. Nothing loads or lists a .deleted file.


Character Roster

UCharacterRosterSubsystem (GameInstance, local only; not created on a dedicated server) is the list of the player's own characters:

Method Does
ListCharacters() Every character file in the user's folder, newest SaveTimestamp first: id, name, timestamp, LastWriterDevice, SaveSequence. A character whose file is gone but whose .bak survives is listed; a newer build's character is listed with bNeedsNewerGame; files that do not read, or are not named by a GUID, are left out
CreateCharacter(Starter, Name) Writes the starter's payload under a new random CharacterId: offline, no account, no play time, every item instance re-keyed (with its slots, plates and glyph sockets) so two characters made from one starter never share an item
CreateCharacterFromPreset(Preset) CreateCharacter from a preset's payload, at the preset's StartNodeID, named after it
DeleteCharacter(Id) The provider's .deleted rename; clears it as the pending character
Set/Get/ClearPendingCharacterId The character the next gameplay map plays, carried across the OpenLevel from the menu

Identity. On the gameplay map the component of the first local player plays the pending character. Without one, editor builds fall back to the fixed dev identity in Saved/Config/PersistenceLocal.ini (so PIE goes on where it left off), and a packaged session is not saved. A chosen character always auto-loads, whatever bLoadOnPIEStart says: playing it from scratch would write over it.

Saved characters off (UPersistenceDevSettings::bSavedCharacters, off in DefaultGame.ini for the demo and playtests): the War Table lists the preset cards only, a co-op guest joins as a preset, and nothing writes a character file. The roster and its console commands keep working for development.

With saved characters on, the War Table lists, after the preset cards, a card per saved character ("Last saved

Kits do not come along. A preset's GrantedKits live on the asset, not in its payload, so a character made from a preset has the preset's items and progress but not its composed Ability Kits.

Console (non-shipping): Eternal.Roster.List, Eternal.Roster.New <PresetName>, Eternal.Roster.Delete <Id>, Eternal.PlaySave [Id] (no id: the editor's dev character, or in a packaged dev build the character saved last).

Saving on the Way Out

Quit (game menu) and Return to menu (Change Preset, End of Demo) call UPersistenceComponent::SaveLocalPlayersBeforeLeaving first: every local player with a writable store saves while its state is whole, and those components then stop saving. Return to menu clears the world map before its OpenLevel, and the logout save that the map change triggers used to run after that clear and write the character with no world-map progress; quitting tears the world down with no logout at all.

In co-op both wait first, at most 5 s: a listen host sends its guest a last snapshot and waits for it to be written (FlushGuestsBeforeLeaving); a guest asks the host for its last snapshot (LeaveHostGame). See A Guest's Progress Back. AEternalGameMode::Logout saves a leaving player on a dedicated server or a local one, never a listen host's guest: its character is written on its own machine.


The Read-Only Preset Provider

UPresetPersistenceProvider serves a curated character that loads instead of a real save and is never written back. It is the in-window addition to the persistence system, supporting shipped demo / "play-as" builds.

Read-Only Contract

Method Behaviour
IsReadOnly() Returns true (the base interface default is false)
LoadCharacter() Returns the cached FCharacterSaveData snapshot every time
SaveCharacter() No-op (callback reports success so callers don't error)
DeleteSaveData() No-op
HasSaveData() Always reports the preset is available

The provider is initialized from a UPresetCharacterAsset::Payload via Initialize(const FCharacterSaveData&), which caches the snapshot in PresetData.

How Read-Only Changes Component Behaviour

UPersistenceComponent checks Provider->IsReadOnly() and adjusts its lifecycle:

Aspect Normal provider Read-only preset
Auto-save timer Started if AutoSaveInterval > 0 Never started
IsUsingPreset() false true
Auto-load on BeginPlay Only if bLoadOnPIEStart Always auto-loads
GameMode::Logout save Saves Save is a no-op (writes ignored)

Handing a Session to a Preset

A preset can be chosen while a real save is playing: Eternal.PlayPreset from a gameplay map, or any menu path that sets PendingPreset before its OpenLevel. The world being left still runs its save on the way out (GameMode::Logout fires as the map change destroys its controllers), and that save would rewrite the real character from a session the player has just walked away from. So RequestSave writes nothing once the game instance holds a pending preset that this component does not play (UPersistenceComponent::MayWriteSave). The paths that go back to the normal save (StartGame, Eternal.PlaySave, ReturnToPresetSelect) clear PendingPreset before they travel, so a real-save session keeps its travel save and its auto-save timer.

In PIE, L_Default is such a gameplay map: it runs AEternalGameMode with AEternalPlayer, so with bLoadOnPIEStart it loads, plays and saves the local save. The menu map L_MainMenu runs AMenuGameMode, which has no persistence component. The gate is per game instance: in a listen PIE, a preset launched from a client's window relaunches only that client, and the host keeps playing (and saving) the real save.

UPresetCharacterAsset — The Curated Source

A UPresetCharacterAsset is a cooked UPrimaryDataAsset (primary asset type "CharacterPreset") shipped with the build. Its Payload is the same FCharacterSaveData a real save file holds, so a preset loads through the exact same restore pipeline as a normal save. It also carries menu metadata (DisplayName, Description, Icon, ClassTag) for a character-select screen, plus an Availability gate controlling whether it is listed.

UPresetCharacterAsset
+-- DisplayName / Description / Icon / ClassTag   (menu metadata)
+-- Availability : EPresetAvailability            (menu listing gate)
+-- StartNodeID / StartLayoutSeed / StartAreaLevel / bNoExitPortalAtStart (the playtest scenario)
+-- Payload : FCharacterSaveData                  (curated snapshot, loaded read-only)

The Playtest Scenario

StartNodeID is the node the preset drops the player into; it overrides the payload's CurrentNodeID at load. Three more fields shape that node for the preset's session only, so a playtest replays the same dungeon at the level its character was built for:

Field Effect (0 = off)
StartLayoutSeed Every entry into the start node during the session builds this one layout
StartAreaLevel The start node plays at this area level: its enemies, drops, modifier roll, and the map card's item levels
bNoExitPortalAtStart The start node has no exit portal, for a scenario that ends elsewhere in it (the demo ends in the Remnant Realm's finale)

UPersistenceComponent::InitializeProvider hands them to UWorldMapSubsystem::SetSessionStart on the machine that owns the session's map (standalone or the listen host's own controller; a guest's preset never reaches it) and clears them for a normal save. They are never saved or replicated, and the map asset is untouched, so real characters on that node keep their per-entry layouts and the node's own area level. ProjectEternal.Content.Dungeon.GenerationRegression fingerprints every preset's start layout (keyed <map>/<node>@<seed>), so a generator change that moves it fails CI.

EPresetAvailability — Listing Gate

Value Behavior
Available Listed on the character-select War Table in every build
DevOnly Hidden in packaged builds, listed in editor/dev builds so WIP presets stay testable
Hidden Never listed; still reachable by name for regression testing

This gates listing only — a hidden preset still cooks into the build and stays loadable by name. The menu paths (CharacterSelectController, MainMenuController) filter on it via IsListedInMenu(); Eternal.PlayPreset deliberately ignores it, which is what keeps hidden presets usable as regression fixtures.

Why it lives on the asset rather than a config deny-list: a deny-list keyed by asset name silently stops matching the moment a preset is renamed, and the failure mode is a WIP build appearing in a shipped menu.

Authoring a Preset: Eternal.ExportPreset

Presets are authored by capturing a live in-game character. With a possessed character in play (editor/PIE), run in the console:

Eternal.ExportPreset <AssetName>

This editor-only console command snapshots the live local AEternalPlayer through the same UPersistenceHelpers::BuildCharacterSaveData path the auto-save uses, strips the per-machine identity (CharacterId / AccountId) and timestamp so the preset is identity-agnostic, then writes /Game/DataAssets/Presets/Preset_<AssetName>. Re-running overwrites in place: only the gameplay Payload is refreshed, so hand-edited display metadata is preserved.

To take one item out of a preset without capturing it again, run Eternal.Presets.RemoveItem <Preset> <ItemID> (editor only). It removes every item with that ItemID from the payload, with its bag and equipment slots, and saves. The payload's item list has no editor access, and a text round trip through Python drops a Remnant's state module data (the FJsonObjectWrapper does not import back), so the edit is made on the structs.

To turn one item into another without capturing again, run Eternal.Presets.ReplaceItem <Preset> <OldItemID> <NewItemID> (editor only). Only the ItemID changes: the instance keeps its level, rolled modifiers, state and slots. The new item must exist; nothing checks that the kept rolls and slot are legal on it, so swap like for like.

Do not re-capture a preset that carries a Remnant to change its gear. At spawn the Remnant is taken off the character and held until the fallen bearer is searched, so a capture made before that writes a preset with no Remnant in it. Use ReplaceItem, RemoveItem and the Eternal.Presets.SetAffix family, which edit the payload in place.


Save Data Shape

FCharacterSaveData is the top-level aggregate serialized to JSON for every provider. Fields below are exactly what the struct persists — items are stored as a flat array referenced by slot assignments, and item template data (icon, fragments, weapon stats) is not saved; it is reconstructed from the item registry by ItemID.

Group Fields Notes
Identity CharacterId, AccountId, CharacterName, PlayerClassTemplateId GUID identity + class template reference
Currency CraftingResource
Play time PlayTimeSeconds
Items Items: TArray<FItemSaveState> Flat instance list; slots reference these by InstanceId
Inventory InventorySlots: TArray<FInventorySlotSaveState> Item instance → grid top-left index
Equipment EquipmentSlots: TArray<FEquipmentSlotSaveState> Item instance → slot FGameplayTag
Glyphs StonePlates: TArray<FStonePlateSaveState> Plates + per-socket glyph placements
Quests QuestProgress: FQuestSaveState Received / active / completed quest tag containers
Compendium CompendiumEntries: TArray<FCompendiumEntry>
World map WorldMapProgress: FWorldMapSaveState Per-node state and journey counters, per-domain liberation and tier, CurrentNodeID, CheckpointNodeID (see World-Map Progress). The remote backend keeps only state, visited, clear count, liberation and the current node: the other fields are lost on a remote save/load until eternal-server gets matching columns and DTO fields
Versioning SaveVersion, SaveTimestamp SaveVersion 2 since the per-user character files (FCharacterSaveData::CurrentSaveVersion); a save above it is never loaded (see Loading)
Ownership CharacterType, SaveSequence, LastWriterDevice Offline (a file the player owns) or Online (the backend's; dedicated servers); one more per write; "PC" / "Steam Deck". A version 1 save loads as Offline, 0, empty. Kept through every save: the component carries the loaded type, and a Remote save is Online

Per-Item Instance State

FItemSaveState carries only instance-specific fields, not the template:

Field Purpose
InstanceId Matches UItemObject::InstanceId
ItemID Template reference resolved via the item registry
StackCount / ItemLevel / ConsumableUsagesLeft Per-instance counters
Modifiers : FEquipmentModifiers Rolled affixes, reused directly from the equipment fragment
StateModules : TArray<FItemStateModuleSaveEntry> Polymorphic per-instance runtime state (e.g. Remnant)

Each FItemStateModuleSaveEntry records a StructName plus a nested FJsonObjectWrapper so per-instance state serializes as introspectable JSON the backend can query — see Item State Modules.

⚠️ FJsonObjectWrapper persists JsonString, not JsonObject. JsonObject is a transient TSharedPtr; only the JsonString UPROPERTY serializes (PostSerialize re-parses it on load). Setting Wrapper.JsonObject = X without Wrapper.JsonObjectToString(Wrapper.JsonString) saves an empty payload — and on reload the empty string parses into a valid-but-empty object, so IsValid() guards pass and JsonObjectToUStruct "succeeds" into a default-constructed struct. Nothing errors. Always flush JsonString before save; guard readers with JsonObject->Values.IsEmpty() ("no state") not just IsValid(). (This silently dropped all Remnant state from preset exports — see Learnings/fjsonobjectwrapper-persists-jsonstring-only.md.)

World-Map Progress

FWorldMapSaveState is a snapshot of the map's runtime state. It names nodes by ID, so restore first carries it onto the loaded map's IDs (FWorldMapLanding::RedirectSave): a node the map no longer has moves to the node its UWorldMapData::NodeRedirects names, a node with no redirect is dropped, a node saved under both an old and its current ID keeps the current one's record, and a current node with nowhere to go becomes the map's start node. Each move and loss is logged (LogWorldMap, "World map restore: ..."). The front end's landing step reads the save through the same redirect. Restore then applies it verbatim through UWorldMapSubsystem (RestoreNodeStateFromSave, RestoreDomainStateFromSave, SetCheckpointFromSave, then SetCurrentNodeFromSave, which sends the state to clients); clears and unlocks are never replayed, and restoring a liberated domain does not fire OnDomainLiberated. On a listen server only the host's own load restores the map: a guest's load leaves it as it stands, so a joiner cannot move where the party stands or what is cleared under it. A dedicated server has no player of its own, so there every player's load still restores it.

A clear made together reaches a guest's own save through FWorldMapCoopCredit::ApplyClear (see the world map system's Co-op Credit): one more lifetime clear, the tier's clear only when the guest's domain plays at the clear's tier, the liberation of a Lord's domain; no visit, entry or attempt.

Struct Field Meaning In a save written before the field
FWorldNodeSaveState NodeID, State (EWorldNodeState as uint8), bVisited, ClearCount Lifetime state of the node —
LordAttempts Lord encounters at the node that ended without a clear, all tiers 0
EntryCount Travels into the node (a reload of the current node is not an entry); each entry's dungeon layout is drawn from it, so the first entry after a load walks a new layout 0
bTierVisited, TierClearCount, TierLordAttempts The same counters since the domain reached its current tier (a tier raise starts them again); read only above Tier I false / 0
FDomainSaveState DomainTag, bIsLiberated Liberation —
CurrentTier The domain's tier 0, restored as Tier I
FWorldMapSaveState Nodes, Domains, CurrentNodeID —
CheckpointNodeID The last safe node (Hub or Camp) the party entered None: restore takes the map's start node if it is safe, else none

The newer fields are optional and default to "never happened", so they needed no version step: the local provider's FJsonObjectConverter and presets' tagged serialization both leave a missing field at its default. (Version 2 came with the ownership fields; see Character Files.) Remote backend gap: eternal-server maps world-map progress to fixed columns (Backend Server world_map_nodes, domains, characters.current_node_id) and its DTOs carry only the original fields, so a remote save/load drops the counters, the tier and the checkpoint. Add the columns and DTO fields the next time the backend is touched.


Build & Restore Pipeline

Both save and load are orchestrated by static helpers in UPersistenceHelpers, keeping the conversion between live game objects and persistence structs out of the component.

SAVE                                         LOAD
----                                         ----
RequestSave()                                provider->LoadCharacter() -> callback
  |                                            |
  v                                            v
BuildCharacterSaveData(PlayerController)      RestoreCharacterFromSaveData(PlayerController, SaveData)
  + CollectAllItems (inv/equip/glyph)          + CreateItemFromSaveState (registry lookup)
  + CollectInventorySlots                      + RepopulateModifierCache / RepopulateEchoModCache
  + CollectEquipmentSlots                      + RestoreInventory / RestoreEquipment / RestoreGlyphs
  + CollectGlyphState                          + RestoreQuestProgress
  + CollectQuestProgress                       + RestoreCompendium
  + CollectCompendiumEntries                   + RestoreWorldMapProgress
  + CollectWorldMapProgress                    |
  |                                            v
  v                                          OnLoadComplete -> OnLoadCompleted.Broadcast(bSuccess)
provider->SaveCharacter() -> OnSaveComplete

Restore takes whatever a file or a guest's upload says and never crashes on it: an item listed twice is placed once (each placement skips an item that already has a container), and out-of-grid cells, unknown slot tags, absurd stone-plate and socket indices, unknown items and absurd stack counts are skipped (ProjectEternal.Persistence.RestoreHostileSave).

On restore, items are rebuilt from their template by ItemID (via the registry), instance fields are overwritten, and CachedDefinition pointers on rolled modifiers — including Echo Mods inside Remnant state modules — are repopulated so live modifier logic works after a fresh load. A successful load seeds LastSaveTime so the auto-save timer does not immediately fire over freshly loaded state.


Auto-Load & Travel Gate

On BeginPlay, the component schedules an initial load deferred to the next tick (so PostLogin can disable persistence first), when the provider is a read-only preset (always), a character was chosen on the menu (always), or bLoadOnPIEStart is set — and only on authority. WillAutoLoad() exposes whether that load was scheduled, and HasCompletedInitialLoad() whether it has finished.

AEternalGameMode keys its world-map travel on these flags: an auto-load must restore the saved/preset world-map node before the game reads the travel target, so the GameMode waits for the load to complete before traveling.

GameMode::HandleStartingNewPlayer
   |
   +-- Persistence->WillAutoLoad() && HasAuthority() ?
        |                              |
        | yes                          | no
        v                              v
   HasCompletedInitialLoad() ?     TravelToCurrentNode()  (start node, immediately)
        |             |
        | yes         | no
        v             v
   TravelTo...   bind OnLoadCompleted -> OnPlayerPersistenceLoaded -> TravelTo...

If a scheduled auto-load cannot proceed (disabled, no CharacterId, or no provider), DeferredAutoLoad still marks the load complete and broadcasts failure so the travel gate is released and startup does not stall.

See Game Framework for the GameMode/GameInstance lifecycle this plugs into.


Identity & Multiplayer

Per-Player Identity

When no login system has set an identity, the component assigns one in InitializeIdentity() (authority only), by the store it chose:

Store Identity
Local The roster's pending character for the first local player; else, in editor builds and for the first local player only, the dev identity below; else none (a packaged session with no chosen character is not saved, nor is any other controller: on a PIE dedicated server under Local, the players' controllers would otherwise all load and overwrite the one dev file)
Remote The dev identity below, then EnsureAccountExists (a 409 Conflict is treated as success)
Preset A throwaway random id: a preset never writes
CoopGuest None until the guest's character arrives; then the character's own id (a fresh one for a guest's preset)
None None

The dev identity (InitializeLocalIdentity()) first tries to load a previously saved AccountId / CharacterId from Saved/Config/PersistenceLocal.ini; failing that it generates deterministic GUIDs seeded by the player's LocalPlayer controller id (ULocalPlayer::GetControllerId()), and persists them for future sessions. Every install would get the same ids, which is why only editor and dedicated-server dev loops use it; a player's character gets a random id when the roster creates it.

The controller id is the per-player seed deliberately — it is stable across map transitions, unlike a PlayerState player id, which can change.

Server Authority

Persistence is server-authoritative. Identity assignment, auto-save scheduling, the deferred auto-load and the save on the way out all gate on authority; clients never save or load directly. A dedicated server uses the remote provider; a solo game and a listen host's own players use the local file, and a listen host keeps nothing for its guests (see Provider Selection). See Server Authority and Backend Server.


Public Contracts

Component Methods (UPersistenceComponent)

Method Parameters Purpose
RequestSave () Trigger a manual save; no-op if a save is in progress or the session is handed to a preset
MayWriteSave (PlayingPreset, PendingPreset) (static) False once the game instance holds a preset this component does not play
SelectProviderKind (Mode, NetMode, bLocalController, bPresetActive) (static) The store for one player's character (see Provider Selection)
SaveLocalPlayersBeforeLeaving (World) (static) Saves every local player with a writable store, then stops those components saving
GetProviderKind () None, CoopGuest, Local, Remote or Preset
GetCharacterInPlay () The character this player plays or is bringing in
RequestGuestSnapshot (bHostLeaving) Host: send the guest its character now, or after the one in flight
FlushGuestsBeforeLeaving (World, Then) (static) Host: last snapshot to every guest; Then once written or after 5 s
LeaveHostGame (Then) Guest: ask the host for a last snapshot; Then once written or after 5 s
ReleaseForRejoin () Host: a stale controller lets its character go; returns its unconfirmed clears
OnInitialLoadFinished native delegate (bool) The initial load finished; the game mode holds a guest's first spawn on it
RequestLoad () Trigger a load; no-op if a load is in progress
SetCharacterId / GetCharacterId (FGuid) Session character identity (must be set before save/load)
SetAccountId / GetAccountId (FGuid) Session account identity
SetDisabled (bool) Disable all persistence (call before BeginPlay to prevent auto-load)
IsOperationInProgress () True while a save or load is running
IsUsingRemoteProvider () True when the remote provider is active
IsUsingPreset () True when the active provider is a read-only preset
WillAutoLoad () True if BeginPlay scheduled an initial auto-load
HasCompletedInitialLoad () True once the initial auto-load has finished
GetProviderLocationString () Human-readable backing-store location (file path or URL)

Provider Interface (IPersistenceProvider)

Method Parameters Purpose
SaveCharacter (CharacterId, SaveData, Callback) Persist a snapshot (async remote / immediate local)
LoadCharacter (CharacterId, Callback) Load a snapshot, returned via the load delegate
HasSaveData (CharacterId) Whether a save exists
DeleteSaveData (CharacterId, Callback) Remove a save
IsReadOnly () Skip auto-save / save-on-exit when true (default false)

Events

Delegate Payload When Fired
OnSaveCompleted bool bSuccess After a save attempt resolves
OnLoadCompleted bool bSuccess After a load + restore resolves (also released when auto-load can't proceed)

Authoring Command

Command Form Purpose
Eternal.ExportPreset Eternal.ExportPreset <AssetName> (editor only) Capture the live character into /Game/DataAssets/Presets/Preset_<AssetName>
Eternal.Presets.RemoveItem Eternal.Presets.RemoveItem <Preset> <ItemID> (editor only) Take every item with that ItemID out of a preset's payload, with its slots

Source References

Component / Concept Path
UPersistenceComponent Source/ProjectEternal/Public/Persistence/Components/PersistenceComponent.h
Component implementation (provider selection, auto-load) Source/ProjectEternal/Private/Persistence/Components/PersistenceComponent.cpp
IPersistenceProvider (interface, IsReadOnly) Source/ProjectEternal/Public/Persistence/Providers/PersistenceProvider.h
ULocalPersistenceProvider (atomic write, .bak, version check) Source/ProjectEternal/Public/Persistence/Providers/LocalPersistenceProvider.h
FSaveLocation (save root, user folder, writer device) Source/ProjectEternal/Public/Persistence/SaveLocation.h
FCharacterSaveMigration Source/ProjectEternal/Public/Persistence/CharacterSaveMigration.h
UCharacterRosterSubsystem Source/ProjectEternal/Public/Persistence/CharacterRosterSubsystem.h
UCoopGuestPersistenceProvider Source/ProjectEternal/Public/Persistence/Providers/CoopGuestPersistenceProvider.h
FSaveBlob / sender / receiver Source/ProjectEternal/Public/Persistence/SaveBlobTransfer.h
UCoopGuestSubsystem (guest writes snapshots, menu message) Source/ProjectEternal/Public/Persistence/CoopGuestSubsystem.h
FCoopSnapshotMerge Source/ProjectEternal/Public/Persistence/CoopSnapshotMerge.h
FCoopSnapshot / FCoopNodeResult Source/ProjectEternal/Public/Persistence/Types/PersistenceTypes.h
Roster console commands, Eternal.PlaySave Source/ProjectEternal/Private/Persistence/Presets/PresetPlayCommands.cpp
War Table roster cards Source/ProjectEternal/Private/UI/Controllers/CharacterSelectController.cpp
Specs Source/ProjectEternal/Private/Tests/Persistence/ (LocalPersistence, CharacterRoster, ProviderSelection, SaveLocation, SaveSizeBudget, SaveBlobTransfer, CoopGuestPersistence, CoopSnapshot, RestoreHostileSave)
URemotePersistenceProvider Source/ProjectEternal/Public/Persistence/Providers/RemotePersistenceProvider.h
UPresetPersistenceProvider (read-only) Source/ProjectEternal/Public/Persistence/Providers/PresetPersistenceProvider.h
UPresetCharacterAsset Source/ProjectEternal/Public/Persistence/Presets/PresetCharacterAsset.h
Eternal.ExportPreset command Source/ProjectEternal/Private/Persistence/Presets/PresetExportCommand.cpp
Eternal.Presets.RemoveItem command Source/ProjectEternalEditor/Private/Authoring/PresetRemoveItemCommand.cpp
FCharacterSaveData + save structs Source/ProjectEternal/Public/Persistence/Types/PersistenceTypes.h
UPersistenceHelpers (build/restore) Source/ProjectEternal/Public/Persistence/PersistenceHelpers.h
UPersistenceDevSettings / UPersistenceDevUserSettings / EPersistenceProviderMode Source/ProjectEternal/Public/Persistence/PersistenceDevSettings.h
PendingPreset carrier Source/ProjectEternal/Public/GameMode/EternalGameInstance.h
Travel-gate consumer Source/ProjectEternal/Private/GameMode/EternalGameMode.cpp


Recent Changes

Date Change Impact
2026-11-14 Eternal.Presets.ReplaceItem One item in a preset becomes another without a re-capture, which would drop a held Remnant
2026-11-06 bSavedCharacters switch (off); a co-op guest joins as a preset, its items re-keyed by the host (UPersistenceHelpers::ReissueItemInstanceIds) The demo writes no character files; two players on one preset never share an item; the War Table shows presets only
2026-10-20 A listen host's guest gets its progress back as snapshots; leave, host quit, lost link and rejoin handled; restore skips hostile entries The guest's own file holds its gear and the clears made together (once each, at the host's tier); leaving or the host quitting writes a last snapshot first; a lost link returns to the menu saying when progress was saved; a crashed guest can rejoin at once; Logout no longer saves a listen host's guest; an item listed twice is placed once
2026-10-20 A listen host's guest brings its own character (upload on join); listen servers admit one guest The guest plays its own saved character (or its own preset) in the host's game, enters once it has arrived, and is refused with a reason for a duplicate, newer or online character; the host writes nothing for it
2026-10-20 Per-user character files, atomic writes with .bak, SaveVersion 2, character roster, store by role, no backend offline, save on quit / return to menu Packaged builds save to %LOCALAPPDATA% under a Steam / Epic / Local user folder; a crash mid-write leaves the last good copy; a newer build's save is refused, never stripped; the War Table plays and creates saved characters; listen hosts and solo games use files and make no backend call; ProviderMode is per developer; Return to menu no longer saves the character without its world map
2026-10-18 A session handed to a preset no longer saves (MayWriteSave) Launching a preset from a real-save world (PIE Eternal.PlayPreset from L_Default) no longer rewrites the local save on the way out; real-save sessions still save on travel and on their timer
2026-11-08 Preset bNoExitPortalAtStart A preset's start node can lose its exit portal for the preset's session only; the three demo presets set it, since the demo ends in the Remnant Realm
2026-11-06 Eternal.Presets.RemoveItem; the starting crafting shard left Momentum and Bleed Cascade Martha gives each build its shard, so the shard the demo presets started with (from before her) came twice
2026-10-17 World-map node redirects on restore; preset StartLayoutSeed / StartAreaLevel A save or preset written against an earlier map layout keeps its progress on the nodes that replaced its nodes (unknown nodes dropped, an unknown current node starts at the map's start node); a preset's start node builds one layout at one area level during its session only
2026-10-17 A guest's load on a listen host no longer restores the host's world map; FWorldMapCoopCredit::ApplyClear for co-op clears A joiner's save moved the host's current node and clears under the party; the guest's own save needs a rule for the clears it takes home
2026-10-17 World-map journey counters, domain tier and checkpoint in FWorldMapSaveState Lord attempts, entries, per-tier counters, CurrentTier and CheckpointNodeID persist locally and in presets; older saves load them at their defaults with no SaveVersion bump; the remote backend drops them until it gains matching columns
2026-08-06 EPresetAvailability on UPresetCharacterAsset Presets carry their own menu-listing gate (Available / DevOnly / Hidden) instead of a rename-fragile config deny-list; menu paths filter on it, Eternal.PlayPreset ignores it so hidden presets stay usable as regression fixtures
2026-06-17 Initial documentation Persistence system documented end-to-end; read-only Preset provider (UPresetPersistenceProvider / UPresetCharacterAsset / Eternal.ExportPreset) covered for demo "play-as" characters