载入中...
搜索中...
未找到
RPGSaveSession.cpp
浏览该文件的文档.
48 bytes[static_cast<std::size_t>(index + 8)] = static_cast<std::uint8_t>(right >> (56 - index * 8));
54std::size_t renameStringValue(eve::Value *value, std::string_view oldId, std::string_view newId) {
64 for (std::size_t index = 0; index < value->arraySize(); ++index) changed += visitor(value->at(index));
123eve::Result<void> applyQuestAdditions(eve::Value &payload, const std::set<std::string> &questIds) {
139 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvariantViolation,
159 eve::DiagnosticCode::Conflict, "quest-addition migration target already exists in the old tracker",
170 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvariantViolation,
192 eve::DiagnosticCode::NotFound, "quest-addition migration target is absent from the current registry",
220RPGSaveSession::PreparedRestore::PreparedRestore(std::unique_ptr<Impl> state) : state_(std::move(state)) {}
223RPGSaveSession::PreparedRestore &RPGSaveSession::PreparedRestore::operator=(PreparedRestore &&) noexcept = default;
254 eve::DiagnosticCode::Conflict, "RPG content version cannot change after migration routes are registered",
261eve::Result<void> RPGSaveSession::allowCompatibleContentVersion(std::string_view contentVersion) {
265 "compatible RPG content version must be a non-empty identifier without controls", "contentVersion"));
268 eve::DiagnosticCode::Conflict, "current RPG content version must not be registered as an older version",
278 eve::DiagnosticCode::Conflict, "RPG content version already has an ID migration route", "contentVersion"));
300 eve::DiagnosticCode::Conflict, "RPG ID migration source must differ from the current content version",
304 eve::DiagnosticCode::Conflict, "RPG content version is already admitted as directly compatible",
309 eve::DiagnosticCode::AlreadyExists, "RPG ID migration source is already registered", "migration"));
326 "quest-addition migration source must differ from the current content version", "fromContentVersion"));
329 eve::DiagnosticCode::Conflict, "RPG content version is already admitted as directly compatible",
333 eve::DiagnosticCode::NotFound, "quest-addition migration target is not registered", "questId"));
337 eve::DiagnosticCode::AlreadyExists, "quest-addition migration is already registered", "migration"));
350 "single-actor party migration requires a distinct valid source version", "fromContentVersion"));
353 eve::DiagnosticCode::Conflict, "RPG content version is already admitted as directly compatible",
365 eve::DiagnosticCode::PreconditionViolation, "RPG save session requires bound participants", {}));
368 eve::DiagnosticCode::PreconditionViolation, "RPG save session requires a content version", {}));
414eve::Result<RPGSaveSession::PreparedRestore> RPGSaveSession::prepareRestoreSnapshotJson(std::string_view json) {
417 eve::DiagnosticCode::PreconditionViolation, "RPG save session requires bound participants", {}));
420 eve::DiagnosticCode::PreconditionViolation, "RPG save session requires a content version", {}));
445 eve::DiagnosticCode::UnknownVersion, "unsupported RPG save-session snapshot version", "schemaVersion"));
450 eve::DiagnosticCode::ParseError, "single-actor migration requires an actor payload", "payload.actor"));
481 eve::DiagnosticCode::Conflict, "RPG save-session content version has no compatible or migration route",
489 if (!gameStateValue || !gameStateValue->isObject() || !trackerValue || !trackerValue->isObject() ||
505 if (!gameStateRestore.ok()) return eve::Result<PreparedRestore>::failure(gameStateRestore.status());
507 if (!trackerRestore.ok()) return eve::Result<PreparedRestore>::failure(trackerRestore.status());
511 if (!inventoryCandidate.ok()) return eve::Result<PreparedRestore>::failure(inventoryCandidate.status());
EVEngine assertion entry point, backed by zeroerr.
#define EV_ASSERT(cond,...)
Assert an internal engine invariant (state that must always hold).
Definition Assert.h:37
全局游戏状态:开关(bool)、变量(数字)、独立变量(按作用域)。
Versioned atomic persistence boundary for one bag and equipment set.
Generation-safe ordered RPG party relationships.
任务 / 成就 / 教程的通用定义模板与进程级注册表。
Transactional composition of persistent RPG state owners.
Versioned, integrity-checked persistence envelopes.
目标追踪器运行时实例(玩家日志 / 成就 / 教程可各建一份)。
std::map< std::string, std::span< const std::uint8_t > > members
Definition UnityPackage.cpp:81
Owning, renderer-independent dynamic values.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
Human-readable, scoped identifier in the form namespace:name.
Definition Identity.h:414
static std::optional< LogicalId > parse(std::string_view text)
Parses a scoped logical name.
Definition Identity.cpp:37
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
Result< std::string > toJson() const
Serialize this value as deterministic compact JSON.
Definition Value.cpp:187
const std::string & asString() const
Return the string payload; the caller must have checked the kind.
Definition Value.cpp:207
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:177
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:244
Validated owning inventory state awaiting publication.
Definition InventorySaveSession.h:28
Coordinates persistent inventory owners without duplicating their live state.
Definition InventorySaveSession.h:22
void commitPrepared(PreparedRestore prepared) noexcept
Publish a previously validated state without failure or callbacks.
Definition InventorySaveSession.cpp:303
eve::Result< std::string > snapshotJson() const
Capture the complete bag and equipment state.
Definition InventorySaveSession.cpp:151
eve::Result< PreparedRestore > prepareRestoreSnapshotJson(std::string_view json) const
Parse and validate a snapshot without mutating either participant.
Definition InventorySaveSession.cpp:197
void bind(Bag &bag, EquipmentSet &equipment) noexcept
Bind the authoritative inventory participants.
Definition InventorySaveSession.cpp:146
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate and atomically restore a canonical RPG game-state JSON document.
Definition GameState.cpp:149
Authoritative ordered relationship between stable party member IDs and RPG actors....
Definition Party.h:24
static const QuestDefinition * find(const std::string &id)
Find a registered quest definition by id.
Definition Quest.cpp:178
Validated owning RPG state that can be published without another fallible parse.
Definition RPGSaveSession.h:52
~PreparedRestore()
PreparedRestore(PreparedRestore &&) noexcept
A non-owning save boundary for the persistent classic-RPG state owners.
Definition RPGSaveSession.h:49
eve::Result< void > validateSnapshotJson(std::string_view json)
Parse and fully prepare a save without publishing participant state.
Definition RPGSaveSession.cpp:401
void bind(GameState &gameState, Tracker &tracker, RPGActor &actor, inventory::Bag &bag, inventory::EquipmentSet &equipment) noexcept
Bind the authoritative participants used by subsequent operations.
Definition RPGSaveSession.cpp:225
eve::Result< std::string > snapshotJson() const
Capture every bound participant into one deterministic versioned JSON document.
Definition RPGSaveSession.cpp:362
eve::Result< void > allowCompatibleContentVersion(std::string_view contentVersion)
Accept one older content contract that is data-compatible with the configured version.
Definition RPGSaveSession.cpp:261
eve::Result< PreparedRestore > prepareRestoreSnapshotJson(std::string_view json)
Parse, migrate and validate every RPG participant without publishing live state.
Definition RPGSaveSession.cpp:414
void commitPrepared(PreparedRestore prepared) noexcept
Publish previously prepared RPG, quest, actor and inventory state together.
Definition RPGSaveSession.cpp:531
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.
Definition RPGSaveSession.cpp:286
eve::Result< void > allowSingleActorPartyMigration(std::string_view fromContentVersion)
Register an explicit schema-v1 single-actor to schema-v2 party migration.
Definition RPGSaveSession.cpp:341
eve::Result< void > setContentVersion(std::string_view contentVersion)
Configure the exact game-content contract required by this save session.
Definition RPGSaveSession.cpp:245
eve::Result< void > addQuestAdditionMigration(std::string_view fromContentVersion, std::string_view questId)
Register an additive migration that initializes one newly introduced quest.
Definition RPGSaveSession.cpp:313
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.
Definition RPGSaveSession.cpp:235
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate all participants and atomically publish a save-session snapshot.
Definition RPGSaveSession.cpp:407
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate and atomically restore quest progress against the current registry.
Definition Tracker.cpp:82
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
RPGSaveIdDomain
Definition-reference field kinds supported by direct RPG save ID migrations.
Definition RPGSaveSession.h:31
@ TraitSource
@ EquipmentSlot
@ QuestObjective
@ InvalidArgument
@ NotFound
@ UnknownVersion
@ PreconditionViolation
@ AlreadyExists
@ InvariantViolation
@ ParseError
@ Conflict
@ Applied
Result< SnapshotEnvelope > parseSnapshotEnvelope(std::string_view json, const SnapshotHashProvider &hashProvider)
Parse and verify an envelope from canonical or compatible JSON text.
Definition Snapshot.cpp:190
detail::StrongUint64< detail::SchemaVersionTag > SchemaVersion
Persistent data-format version; not a runtime replacement generation.
Definition SchemaVersion.h:13
Result< std::string > serializeSnapshotEnvelope(const SnapshotEnvelope &snapshot)
Serialize an envelope as deterministic compact JSON.
Definition Snapshot.cpp:184
Result< SnapshotEnvelope > makeSnapshotEnvelope(std::string type, LogicalId schema, SchemaVersion schemaVersion, PersistentId instanceId, Revision revision, SimulationTick tick, Value payload, const SnapshotHashProvider &hashProvider)
Construct and seal a snapshot envelope.
Definition Snapshot.cpp:103
std::function< Result< ContentId >(std::string_view canonicalInput)> SnapshotHashProvider
Injected content-digest implementation used by snapshots.
Definition Snapshot.h:36
Definition Container.h:602
Stable outer format shared by persistence and cross-process snapshots.
Definition Snapshot.h:46
Impl(RPGSaveSession *session, GameState &&gameStateCandidate, Tracker &&trackerCandidate, inventory::InventorySaveSession::PreparedRestore &&inventoryCandidate, std::optional< RPGActor::CheckpointCandidate > &&actorCandidate, std::optional< Party::CheckpointCandidate > &&partyCandidate)
Definition RPGSaveSession.cpp:208
std::optional< Party::CheckpointCandidate > party
Definition RPGSaveSession.cpp:206
GameState gameState
Definition RPGSaveSession.cpp:202
std::optional< RPGActor::CheckpointCandidate > actor
Definition RPGSaveSession.cpp:205
RPGSaveSession * owner
Definition RPGSaveSession.cpp:201
Tracker tracker
Definition RPGSaveSession.cpp:203
inventory::InventorySaveSession::PreparedRestore inventory
Definition RPGSaveSession.cpp:204