载入中...
搜索中...
未找到
InventorySaveSession.cpp
浏览该文件的文档.
46eve::Result<std::vector<std::string>> decodeStrings(const eve::Value *encoded, const std::string &path) {
72 return eve::Result<std::unordered_map<std::string, std::string>>::failure(eve::Diagnostic::error(
79eve::Result<ItemStack> decodeStack(const eve::Value &encoded, const std::string &path, int &largestId,
89 !quantity->isInt64() || !durability || !durability->isNumeric() || !std::isfinite(number(*durability)))
106 if (stack.instanceId != 0 || !stack.itemId.empty() || stack.quantity != 0 || stack.durability != -1.f ||
109 eve::DiagnosticCode::InvalidArgument, "empty item stack must use canonical empty values", path));
118 if (stack.instanceId <= 0 || stack.quantity > definition->maxStack || !instanceIds.emplace(stack.instanceId).second)
120 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "item identity or stack quantity is invalid", path));
129 if (!definition || (!definition->equipSlot.empty() && definition->equipSlot != slot)) return false;
142InventorySaveSession::PreparedRestore &InventorySaveSession::PreparedRestore::operator=(PreparedRestore &&) noexcept =
153 eve::DiagnosticCode::PreconditionViolation, "inventory save session requires bound participants", {}));
196eve::Result<InventorySaveSession::PreparedRestore> InventorySaveSession::prepareRestoreSnapshotJson(
200 eve::DiagnosticCode::PreconditionViolation, "inventory save session requires bound participants", {}));
209 eve::DiagnosticCode::InvalidArgument, "snapshot does not belong to InventorySaveSession", "$.schema"));
217 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "inventory participants must be objects", "$"));
230 !std::isfinite(number(*maxWeight)) || number(*maxWeight) < 0.0 || !std::isfinite(number(*maxVolume)) ||
232 !capacityPolicy->isString() || !stackRule || !stackRule->isString() || !slots || !slots->isArray())
234 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "bag configuration is invalid", "$.bag"));
281 eve::DiagnosticCode::InvalidArgument, "equipment slot identity is invalid", "$.equipment.slots"));
292 eve::DiagnosticCode::Conflict, "equipped item violates its slot contract", "$.equipment.slots"));
Versioned atomic persistence boundary for one bag and equipment set.
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
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
bool isNumeric() const noexcept
Return whether this value is an integer or finite number.
Definition Value.h:159
std::int64_t asInt() const
Return the Int64 payload; the caller must have checked the kind.
Definition Value.cpp:69
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:124
Validated owning inventory state awaiting publication.
Definition InventorySaveSession.h:28
~PreparedRestore()
Prepared restore.
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:302
eve::Result< std::string > snapshotJson() const
Capture the complete bag and equipment state.
Definition InventorySaveSession.cpp:150
eve::Result< PreparedRestore > prepareRestoreSnapshotJson(std::string_view json) const
Parse and validate a snapshot without mutating either participant.
Definition InventorySaveSession.cpp:196
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate and atomically restore both bound inventory participants.
Definition InventorySaveSession.cpp:320
static bool hasStackRule(const std::string &name)
True when stack rule.
Definition InventorySystem.cpp:126
static bool hasAcceptRule(const std::string &name)
True when accept rule.
Definition InventorySystem.cpp:100
static bool hasCapacityPolicy(const std::string &name)
True when capacity policy.
Definition InventorySystem.cpp:114
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。
Definition AvatarInstance.h:37
@ InvalidArgument
@ NotFound
@ UnknownVersion
@ PreconditionViolation
@ ParseError
@ Conflict
@ Applied