载入中...
搜索中...
未找到
RPGSaveSession.cpp
浏览该文件的文档.
47 bytes[static_cast<std::size_t>(index + 8)] = static_cast<std::uint8_t>(right >> (56 - index * 8));
53std::size_t renameStringValue(eve::Value *value, std::string_view oldId, std::string_view newId) {
63 for (std::size_t index = 0; index < value->arraySize(); ++index) changed += visitor(value->at(index));
122eve::Result<void> applyQuestAdditions(eve::Value &payload, const std::set<std::string> &questIds) {
138 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvariantViolation,
158 eve::DiagnosticCode::Conflict, "quest-addition migration target already exists in the old tracker",
169 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvariantViolation,
191 eve::DiagnosticCode::NotFound, "quest-addition migration target is absent from the current registry",
199void RPGSaveSession::bind(GameState &gameState, Tracker &tracker, RPGActor &actor, inventory::Bag &bag,
228 eve::DiagnosticCode::Conflict, "RPG content version cannot change after migration routes are registered",
235eve::Result<void> RPGSaveSession::allowCompatibleContentVersion(std::string_view contentVersion) {
239 "compatible RPG content version must be a non-empty identifier without controls", "contentVersion"));
242 eve::DiagnosticCode::Conflict, "current RPG content version must not be registered as an older version",
252 eve::DiagnosticCode::Conflict, "RPG content version already has an ID migration route", "contentVersion"));
274 eve::DiagnosticCode::Conflict, "RPG ID migration source must differ from the current content version",
278 eve::DiagnosticCode::Conflict, "RPG content version is already admitted as directly compatible",
283 eve::DiagnosticCode::AlreadyExists, "RPG ID migration source is already registered", "migration"));
300 "quest-addition migration source must differ from the current content version", "fromContentVersion"));
303 eve::DiagnosticCode::Conflict, "RPG content version is already admitted as directly compatible",
307 eve::DiagnosticCode::NotFound, "quest-addition migration target is not registered", "questId"));
311 eve::DiagnosticCode::AlreadyExists, "quest-addition migration is already registered", "migration"));
324 "single-actor party migration requires a distinct valid source version", "fromContentVersion"));
327 eve::DiagnosticCode::Conflict, "RPG content version is already admitted as directly compatible",
339 eve::DiagnosticCode::PreconditionViolation, "RPG save session requires bound participants", {}));
342 eve::DiagnosticCode::PreconditionViolation, "RPG save session requires a content version", {}));
385 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::PreconditionViolation,
388 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::PreconditionViolation,
414 eve::DiagnosticCode::UnknownVersion, "unsupported RPG save-session snapshot version", "schemaVersion"));
419 eve::DiagnosticCode::ParseError, "single-actor migration requires an actor payload", "payload.actor"));
450 eve::DiagnosticCode::Conflict, "RPG save-session content version has no compatible or migration route",
458 if (!gameStateValue || !gameStateValue->isObject() || !trackerValue || !trackerValue->isObject() ||
494 if (!publish) return eve::Result<void>::success(eve::Status::success(eve::StatusCode::Applied));
全局游戏状态:开关(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={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Human-readable, scoped identifier in the form namespace:name.
Definition Identity.h:411
static std::optional< LogicalId > parse(std::string_view text)
Parses a scoped logical name.
Definition Identity.cpp:36
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
Result< std::string > toJson() const
Serialize this value as deterministic compact JSON.
Definition Value.cpp:67
const std::string & asString() const
Return the string payload; the caller must have checked the kind.
Definition Value.cpp:87
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:124
Coordinates persistent inventory owners without duplicating their live state.
Definition InventorySaveSession.h:22
eve::Result< std::string > snapshotJson() const
Capture the complete bag and equipment state.
Definition InventorySaveSession.cpp:150
void bind(Bag &bag, EquipmentSet &equipment) noexcept
Bind the authoritative inventory participants.
Definition InventorySaveSession.cpp:145
eve::Result< std::string > snapshotJson() const
Serialize this state as the canonical versioned RPG game-state JSON document.
Definition GameState.cpp:119
Authoritative ordered relationship between stable party member IDs and RPG actors....
Definition Party.h:24
eve::Result< std::string > checkpointJson() const
Capture ordered member IDs and every actor safe checkpoint into one versioned document.
Definition Party.cpp:182
static const QuestDefinition * find(const std::string &id)
Find a registered quest definition by id.
Definition Quest.cpp:160
eve::Result< std::string > checkpointJson() const
Capture this actor at a persistent safe checkpoint.
Definition RPGActorPersistence.cpp:20
eve::Result< void > validateSnapshotJson(std::string_view json)
Parse and fully prepare a save without publishing participant state.
Definition RPGSaveSession.cpp:375
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:199
eve::Result< std::string > snapshotJson() const
Capture every bound participant into one deterministic versioned JSON document.
Definition RPGSaveSession.cpp:336
eve::Result< void > allowCompatibleContentVersion(std::string_view contentVersion)
Accept one older content contract that is data-compatible with the configured version.
Definition RPGSaveSession.cpp:235
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:260
eve::Result< void > allowSingleActorPartyMigration(std::string_view fromContentVersion)
Register an explicit schema-v1 single-actor to schema-v2 party migration.
Definition RPGSaveSession.cpp:315
eve::Result< void > setContentVersion(std::string_view contentVersion)
Configure the exact game-content contract required by this save session.
Definition RPGSaveSession.cpp:219
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:287
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:209
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate all participants and atomically publish a save-session snapshot.
Definition RPGSaveSession.cpp:379
std::unordered_map< std::string, QuestRuntime > entries
运行时条目(QuestSystem 读写;公开以便测试与脚本查询)。
Definition Tracker.h:123
eve::Result< std::string > snapshotJson() const
Serialize persistent quest progress as deterministic versioned JSON.
Definition Tracker.cpp:44
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate and atomically restore quest progress against the current registry.
Definition Tracker.cpp:73
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
RPGSaveIdDomain
Definition-reference field kinds supported by direct RPG save ID migrations.
Definition RPGSaveSession.h:30
@ 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
Stable outer format shared by persistence and cross-process snapshots.
Definition Snapshot.h:46