载入中...
搜索中...
未找到
eve::rpg::RPGSaveSession类 参考

A non-owning save boundary for the persistent classic-RPG state owners. 更多...

#include <RPGSaveSession.h>

类

class  PreparedRestore
 Validated owning RPG state that can be published without another fallible parse. 更多...
 

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< PreparedRestore > prepareRestoreSnapshotJson (std::string_view json)
 Parse, migrate and validate every RPG participant without publishing live state.
 
void commitPrepared (PreparedRestore prepared) noexcept
 Publish previously prepared RPG, quest, actor and inventory state together.
 
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 第 49 行定义.

构造及析构函数说明

◆ RPGSaveSession()

eve::rpg::RPGSaveSession::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.

参数
fromContentVersionExact source content contract accepted by this migration route.
domainSnapshot field domain to rewrite.
oldIdExact old identifier.
newIdExact 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 第 286 行定义.

引用了 eve::AlreadyExists, eve::Applied, eve::Conflict, domain, 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.

参数
fromContentVersionExact older content identifier whose tracker lacks the quest.
questIdQuest 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 第 313 行定义.

引用了 eve::AlreadyExists, eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::rpg::QuestRegistry::find(), eve::InvalidArgument, eve::NotFound, eve::PreconditionViolation, quests, 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.

参数
contentVersionExact 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 第 261 行定义.

引用了 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.

参数
fromContentVersionExact 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 第 341 行定义.

引用了 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()

void eve::rpg::RPGSaveSession::bind ( GameState &  gameState,
Tracker &  tracker,
RPGActor &  actor,
inventory::Bag &  bag,
inventory::EquipmentSet &  equipment 
)
noexcept

Bind the authoritative participants used by subsequent operations.

参数
gameStateBorrowed game-state owner.
trackerBorrowed quest-progress owner.
actorBorrowed preconfigured player actor restored at safe checkpoints.
bagBorrowed authoritative player bag.
equipmentBorrowed 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 第 225 行定义.

◆ bindParty()

void eve::rpg::RPGSaveSession::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.

参数
partyBorrowed 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 第 235 行定义.

◆ commitPrepared()

void eve::rpg::RPGSaveSession::commitPrepared ( PreparedRestore  prepared)
noexcept

Publish previously prepared RPG, quest, actor and inventory state together.

参数
preparedOwning single-use state from this session's prepare method.
前置条件
The bound owners and content registries have not changed since preparation. @thread Owning simulation thread only. @reentrancy No callbacks or scripts are invoked.

在文件 RPGSaveSession.cpp 第 531 行定义.

引用了 eve::inventory::InventorySaveSession::bind(), eve::inventory::InventorySaveSession::commitPrepared(), EV_ASSERT , 以及 state.

被这些函数引用 restoreSnapshotJson().

◆ getContentVersion()

std::string eve::rpg::RPGSaveSession::getContentVersion ( ) const
inline

Return an owning copy of the configured content contract identifier.

在文件 RPGSaveSession.h 第 104 行定义.

◆ prepareRestoreSnapshotJson()

eve::Result< RPGSaveSession::PreparedRestore > eve::rpg::RPGSaveSession::prepareRestoreSnapshotJson ( std::string_view  json)

Parse, migrate and validate every RPG participant without publishing live state.

返回
Owning prepared state or a structured failure; failure leaves every owner unchanged. @thread Owning simulation thread only. Bound objects and registries must remain stable until commit. @reentrancy No callbacks or scripts are invoked. @cost Comparable to a full save restore; once per load, not per frame.

在文件 RPGSaveSession.cpp 第 414 行定义.

引用了 eve::Value::asString(), eve::inventory::InventorySaveSession::bind(), eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::Value::find(), eve::Value::fromJson(), eve::InvalidArgument, eve::Value::isObject(), eve::Value::isString(), key, members, eve::ParseError, eve::parseSnapshotEnvelope(), eve::SnapshotEnvelope::payload, eve::PreconditionViolation, eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson(), eve::rpg::GameState::restoreSnapshotJson(), eve::rpg::Tracker::restoreSnapshotJson(), root, eve::SnapshotEnvelope::schema, eve::SnapshotEnvelope::schemaVersion, state, eve::Result< T >::success(), eve::Value::toJson(), eve::SnapshotEnvelope::type , 以及 eve::UnknownVersion.

被这些函数引用 eve::rpg::RPGGameSaveParticipant::prepare(), restoreSnapshotJson() , 以及 validateSnapshotJson().

◆ restoreSnapshotJson()

eve::Result< void > eve::rpg::RPGSaveSession::restoreSnapshotJson ( std::string_view  json)

Validate all participants and atomically publish a save-session snapshot.

参数
jsonUTF-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 第 407 行定义.

引用了 eve::Applied, commitPrepared(), eve::Result< T >::failure(), prepareRestoreSnapshotJson(), eve::Status::success() , 以及 eve::Result< T >::success().

◆ setContentVersion()

eve::Result< void > eve::rpg::RPGSaveSession::setContentVersion ( std::string_view  contentVersion)

Configure the exact game-content contract required by this save session.

参数
contentVersionNon-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 第 245 行定义.

引用了 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-session JSON: 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 第 362 行定义.

引用了 eve::inventory::InventorySaveSession::bind(), 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::RPGGameSaveParticipant::capture().

◆ validateSnapshotJson()

eve::Result< void > eve::rpg::RPGSaveSession::validateSnapshotJson ( std::string_view  json)

Parse and fully prepare a save without publishing participant state.

参数
jsonUTF-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 第 401 行定义.

引用了 eve::Applied, eve::Result< T >::failure(), prepareRestoreSnapshotJson(), eve::Status::success() , 以及 eve::Result< T >::success().


该类的文档由以下文件生成: