A non-owning save boundary for the persistent classic-RPG state owners. 更多...
#include <RPGSaveSession.h>
Public 成员函数 | |
| RPGSaveSession ()=default | |
| Rpg save session. | |
| void | bind (GameState &gameState, Tracker &tracker, RPGActor &actor, inventory::Bag &bag, inventory::EquipmentSet &equipment) noexcept |
| Bind the authoritative participants used by subsequent operations. | |
| void | bindParty (GameState &gameState, Tracker &tracker, Party &party, inventory::Bag &bag, inventory::EquipmentSet &equipment) noexcept |
| Bind a complete authoritative player party instead of a single compatibility actor. | |
| eve::Result< void > | setContentVersion (std::string_view contentVersion) |
| Configure the exact game-content contract required by this save session. | |
| std::string | getContentVersion () const |
| Return an owning copy of the configured content contract identifier. | |
| eve::Result< void > | allowCompatibleContentVersion (std::string_view contentVersion) |
| Accept one older content contract that is data-compatible with the configured version. | |
| eve::Result< void > | addIdRenameMigration (std::string_view fromContentVersion, RPGSaveIdDomain domain, std::string_view oldId, std::string_view newId) |
| Register one direct old-to-current definition ID rewrite. | |
| eve::Result< void > | addQuestAdditionMigration (std::string_view fromContentVersion, std::string_view questId) |
| Register an additive migration that initializes one newly introduced quest. | |
| eve::Result< void > | allowSingleActorPartyMigration (std::string_view fromContentVersion) |
| Register an explicit schema-v1 single-actor to schema-v2 party migration. | |
| eve::Result< std::string > | snapshotJson () const |
| Capture every bound participant into one deterministic versioned JSON document. | |
| eve::Result< void > | validateSnapshotJson (std::string_view json) |
| Parse and fully prepare a save without publishing participant state. | |
| eve::Result< void > | restoreSnapshotJson (std::string_view json) |
| Validate all participants and atomically publish a save-session snapshot. | |
详细描述
A non-owning save boundary for the persistent classic-RPG state owners.
The session does not become a second source of truth: it only coordinates the canonical snapshot codecs owned by its participants. More participant types can be added in later schema versions without moving their mutable state here.
在文件 RPGSaveSession.h 第 48 行定义.
构造及析构函数说明
◆ RPGSaveSession()
|
default |
Rpg save session.
成员函数说明
◆ addIdRenameMigration()
| eve::Result< void > eve::rpg::RPGSaveSession::addIdRenameMigration | ( | std::string_view | fromContentVersion, |
| RPGSaveIdDomain | domain, | ||
| std::string_view | oldId, | ||
| std::string_view | newId | ||
| ) |
Register one direct old-to-current definition ID rewrite.
- 参数
-
fromContentVersion Exact source content contract accepted by this migration route. domain Snapshot field domain to rewrite. oldId Exact old identifier. newId Exact identifier expected by the currently loaded definitions.
- 返回
- Applied status, or a structured failure without changing registered rules.
- 备注
- The current content version must already be configured. Rules are pure admission-time transforms over an owning payload copy and are mutually exclusive with compatible-version admission. Unknown new versions and source versions without a route remain rejected; no downgrade is supported. @thread Owning simulation thread only. @reentrancy No callbacks are invoked.
在文件 RPGSaveSession.cpp 第 260 行定义.
引用了 eve::AlreadyExists, eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, key, eve::PreconditionViolation, eve::Status::success() , 以及 eve::Result< T >::success().
◆ addQuestAdditionMigration()
| eve::Result< void > eve::rpg::RPGSaveSession::addQuestAdditionMigration | ( | std::string_view | fromContentVersion, |
| std::string_view | questId | ||
| ) |
Register an additive migration that initializes one newly introduced quest.
- 参数
-
fromContentVersion Exact older content identifier whose tracker lacks the quest. questId Quest definition present in the current registry and absent from the old snapshot.
- 返回
- Applied status, or a structured failure without changing registered routes.
- 备注
- During admission, the old tracker payload is rebuilt in current registry order and this quest receives its canonical initial runtime state. Existing quest entries remain byte-equivalent owning values and still pass the strict Tracker codec. The source route may also contain direct ID renames, but cannot be declared directly compatible. Unknown missing or extra quests remain rejected. @thread Owning simulation thread only; the process-local QuestRegistry must not mutate concurrently. @reentrancy No callbacks or scripts are invoked.
在文件 RPGSaveSession.cpp 第 287 行定义.
引用了 eve::AlreadyExists, eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::rpg::QuestRegistry::find(), eve::InvalidArgument, eve::NotFound, eve::PreconditionViolation, eve::Status::success() , 以及 eve::Result< T >::success().
◆ allowCompatibleContentVersion()
| eve::Result< void > eve::rpg::RPGSaveSession::allowCompatibleContentVersion | ( | std::string_view | contentVersion | ) |
Accept one older content contract that is data-compatible with the configured version.
- 参数
-
contentVersion Exact older content identifier accepted during restore.
- 返回
- Applied status, or InvalidArgument/Conflict without changing the compatibility set.
- 备注
- This does not rewrite identifiers or definitions. Every participant is still validated against the currently loaded registries before any live state changes. Use only for additive or otherwise codec-compatible content updates; incompatible updates require an explicit transformer. @thread Owning simulation thread only. @reentrancy No callbacks are invoked.
在文件 RPGSaveSession.cpp 第 235 行定义.
引用了 eve::AlreadyExists, eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::Status::success() , 以及 eve::Result< T >::success().
◆ allowSingleActorPartyMigration()
| eve::Result< void > eve::rpg::RPGSaveSession::allowSingleActorPartyMigration | ( | std::string_view | fromContentVersion | ) |
Register an explicit schema-v1 single-actor to schema-v2 party migration.
- 参数
-
fromContentVersion Exact old content contract whose save contains actor.
- 返回
- Applied status, or a structured failure without changing migration policy.
- 备注
- Party member zero receives the old actor checkpoint. Remaining live roster members keep their preconfigured new-content baseline. The route is used only by bindParty() sessions and may coexist with ID and additive-quest migrations for the same source version.
在文件 RPGSaveSession.cpp 第 315 行定义.
引用了 eve::AlreadyExists, eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::PreconditionViolation, eve::Status::success() , 以及 eve::Result< T >::success().
◆ bind()
|
noexcept |
Bind the authoritative participants used by subsequent operations.
- 参数
-
gameState Borrowed game-state owner. tracker Borrowed quest-progress owner. actor Borrowed preconfigured player actor restored at safe checkpoints. bag Borrowed authoritative player bag. equipment Borrowed authoritative player equipment set.
- 备注
- All objects must outlive this session. Rebinding invalidates no participant state. @thread Call and use the session on the participants' owning simulation thread. @reentrancy No callbacks are invoked.
在文件 RPGSaveSession.cpp 第 199 行定义.
◆ bindParty()
|
noexcept |
Bind a complete authoritative player party instead of a single compatibility actor.
- 参数
-
party Borrowed ordered party whose live roster must already be configured.
- 备注
- Produces schema version 2 snapshots. All objects must outlive this session; the party owns only generation-safe actor links, while the RPG ECS world retains actor ownership.
在文件 RPGSaveSession.cpp 第 209 行定义.
◆ getContentVersion()
|
inline |
Return an owning copy of the configured content contract identifier.
在文件 RPGSaveSession.h 第 87 行定义.
◆ restoreSnapshotJson()
| eve::Result< void > eve::rpg::RPGSaveSession::restoreSnapshotJson | ( | std::string_view | json | ) |
Validate all participants and atomically publish a save-session snapshot.
- 参数
-
json UTF-8 JSON produced by snapshotJson().
- 返回
- Applied state, or a structured failure without modifying either participant.
- 备注
- The strict common envelope rejects unknown fields and verifies its schema-owned, non-cryptographic corruption digest before participant parsing. This detects damaged saves but is not an authentication or anti-cheat boundary. @thread Call on the owning simulation thread. @reentrancy No callbacks are invoked.
在文件 RPGSaveSession.cpp 第 379 行定义.
◆ setContentVersion()
| eve::Result< void > eve::rpg::RPGSaveSession::setContentVersion | ( | std::string_view | contentVersion | ) |
Configure the exact game-content contract required by this save session.
- 参数
-
contentVersion Non-empty opaque UTF-8 identifier, at most 256 bytes and without controls.
- 返回
- Applied status, or InvalidArgument without changing the previous identifier.
- 备注
- This identifies definitions/data compatibility, independently of the envelope schema version. @thread Owning simulation thread only. @reentrancy No callbacks are invoked.
在文件 RPGSaveSession.cpp 第 219 行定义.
引用了 eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::Status::success() , 以及 eve::Result< T >::success().
◆ snapshotJson()
| eve::Result< std::string > eve::rpg::RPGSaveSession::snapshotJson | ( | ) | const |
Capture every bound participant into one deterministic versioned JSON document.
- 返回
- Integrity-sealed
rpg:save-sessionJSON: schema v1 for bind(), v2 for bindParty().
- 备注
- The returned value owns all bytes and remains valid independently of the participants. @thread Call on the owning simulation thread. @reentrancy No callbacks are invoked.
在文件 RPGSaveSession.cpp 第 336 行定义.
引用了 eve::inventory::InventorySaveSession::bind(), eve::rpg::Party::checkpointJson(), eve::rpg::RPGActor::checkpointJson(), eve::Diagnostic::error(), eve::Result< T >::failure(), eve::Value::fromJson(), eve::makeSnapshotEnvelope(), eve::detail::Id128< Tag >::nil(), payload, eve::PreconditionViolation, eve::serializeSnapshotEnvelope(), eve::inventory::InventorySaveSession::snapshotJson(), eve::rpg::GameState::snapshotJson() , 以及 eve::rpg::Tracker::snapshotJson().
◆ validateSnapshotJson()
| eve::Result< void > eve::rpg::RPGSaveSession::validateSnapshotJson | ( | std::string_view | json | ) |
Parse and fully prepare a save without publishing participant state.
- 参数
-
json UTF-8 JSON produced by snapshotJson().
- 返回
- Success only when restoreSnapshotJson() can reach its no-fail commit boundary.
- 备注
- Integrity, content compatibility and every participant codec are checked. This is intended for slot selection and backup recovery; it never mutates bound participants. @thread Call on the owning simulation thread. @reentrancy No callbacks are invoked.
在文件 RPGSaveSession.cpp 第 375 行定义.
该类的文档由以下文件生成:
- src/modules/rpg/RPGSaveSession.h
- src/modules/rpg/RPGSaveSession.cpp