载入中...
搜索中...
未找到
InventorySaveSession.cpp
浏览该文件的文档.
47eve::Result<std::vector<std::string>> decodeStrings(const eve::Value *encoded, const std::string &path) {
73 return eve::Result<std::unordered_map<std::string, std::string>>::failure(eve::Diagnostic::error(
80eve::Result<ItemStack> decodeStack(const eve::Value &encoded, const std::string &path, int &largestId,
90 !quantity->isInt64() || !durability || !durability->isNumeric() || !std::isfinite(number(*durability)))
107 if (stack.instanceId != 0 || !stack.itemId.empty() || stack.quantity != 0 || stack.durability != -1.f ||
110 eve::DiagnosticCode::InvalidArgument, "empty item stack must use canonical empty values", path));
119 if (stack.instanceId <= 0 || stack.quantity > definition->maxStack || !instanceIds.emplace(stack.instanceId).second)
121 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "item identity or stack quantity is invalid", path));
130 if (!definition || (!definition->equipSlot.empty() && definition->equipSlot != slot)) return false;
143InventorySaveSession::PreparedRestore &InventorySaveSession::PreparedRestore::operator=(PreparedRestore &&) noexcept =
154 eve::DiagnosticCode::PreconditionViolation, "inventory save session requires bound participants", {}));
197eve::Result<InventorySaveSession::PreparedRestore> InventorySaveSession::prepareRestoreSnapshotJson(
201 eve::DiagnosticCode::PreconditionViolation, "inventory save session requires bound participants", {}));
210 eve::DiagnosticCode::InvalidArgument, "snapshot does not belong to InventorySaveSession", "$.schema"));
218 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "inventory participants must be objects", "$"));
231 !std::isfinite(number(*maxWeight)) || number(*maxWeight) < 0.0 || !std::isfinite(number(*maxVolume)) ||
233 !capacityPolicy->isString() || !stackRule || !stackRule->isString() || !slots || !slots->isArray())
235 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "bag configuration is invalid", "$.bag"));
282 eve::DiagnosticCode::InvalidArgument, "equipment slot identity is invalid", "$.equipment.slots"));
293 eve::DiagnosticCode::Conflict, "equipped item violates its slot contract", "$.equipment.slots"));
Versioned atomic persistence boundary for one bag and equipment set.
Share string attribute map operations through the Windows Foundation DLL.
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
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
bool isNumeric() const noexcept
Return whether this value is an integer or finite number.
Definition Value.h:188
std::int64_t asInt() const
Return the Int64 payload; the caller must have checked the kind.
Definition Value.cpp:189
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
~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: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
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate and atomically restore both bound inventory participants.
Definition InventorySaveSession.cpp:321
static bool hasStackRule(const std::string &name)
True when stack rule.
Definition InventorySystem.cpp:129
static bool hasAcceptRule(const std::string &name)
True when accept rule.
Definition InventorySystem.cpp:103
static bool hasCapacityPolicy(const std::string &name)
True when capacity policy.
Definition InventorySystem.cpp:117
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
void keys(const Value &value, std::initializer_list< const char * > names)
Definition OceanCodecInternal.h:8
运行时容器:固定格数的背包 / 箱子 / 商店栏等。 行为由 InventorySystem 提供;本类暴露便于脚本绑定的薄封装方法。
Definition AvatarInstance.h:38
@ InvalidArgument
@ NotFound
@ UnknownVersion
@ PreconditionViolation
@ ParseError
@ Conflict
@ Applied