载入中...
搜索中...
未找到
ScriptComponentSnapshot.cpp
浏览该文件的文档.
31 return Result<void>::failure(Diagnostic::error(code, std::move(message), std::move(path), {}, "ecs.snapshot"));
51 DiagnosticCode::ParseError, "script component snapshot entity id must be decimal digits only", text, {},
56 DiagnosticCode::ParseError, "script component snapshot entity id overflows", text, {}, "ecs.snapshot"));
74EVENGINE_API_FOUNDATION Result<SnapshotEnvelope> snapshotScriptComponents(PersistentId instanceId, Revision revision, SimulationTick tick,
81 item.emplace(kVersionField, Value::integer(static_cast<std::int64_t>(entry.key.version.value())));
93EVENGINE_API_FOUNDATION Result<void> restoreScriptComponents(const SnapshotEnvelope& snapshot, const SnapshotHashProvider& hashProvider) {
94 if (snapshot.type != kScriptComponentSnapshotType || snapshot.schema != scriptComponentSnapshotSchema())
105 return snapshotFailure(DiagnosticCode::ParseError, "script component snapshot has no components array");
113 return snapshotFailure(DiagnosticCode::ParseError, "script component snapshot entry must be an object",
124 return snapshotFailure(DiagnosticCode::ParseError, "script component snapshot entry has an empty name",
127 return snapshotFailure(DiagnosticCode::ParseError, "script component snapshot entry has an invalid version",
162 return snapshotFailure(DiagnosticCode::Conflict, "script component snapshot has a duplicate entry",
174EVENGINE_API_FOUNDATION Result<std::string> serializeScriptComponentSnapshot(PersistentId instanceId, Revision revision, SimulationTick tick,
178 return std::move(envelope).andThen([](SnapshotEnvelope&& value) { return serializeSnapshotEnvelope(value); });
181EVENGINE_API_FOUNDATION Result<void> restoreScriptComponentSnapshotJson(std::string_view json, const SnapshotHashProvider& hashProvider) {
187EVENGINE_API_FOUNDATION Result<std::vector<ScriptComponentInstanceState>> scriptComponentInstancesOf(const ssq::Object& entityInstance) {
190 Diagnostic::error(DiagnosticCode::InvalidArgument, "script component inspection needs an entity instance",
195 Diagnostic::error(DiagnosticCode::InvalidArgument, "script component inspection needs a live script VM", {},
209 if (SQ_SUCCEEDED(sq_getinteger(vm, -1, &raw)) && raw > 0) entityId = static_cast<std::uint64_t>(raw);
264 const Value* stored = findScriptComponentValues(ScriptComponentStoreKey{entityId, name, version});
Stable, structured diagnostics shared by engine modules.
脚本组件数据的持久化信封(方案文档实施顺序第 4 步 / J-3 的存档通路)。
脚本组件字段的引擎侧权威存储。
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
static Value string(std::string value)
Compatibility factory for a string value.
Definition Value.h:121
static Value integer(std::int64_t value)
Compatibility factory for an Int64 value.
Definition Value.h:115
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:244
constexpr std::uint64_t value() const noexcept
Returns the underlying value at an explicit protocol boundary.
Definition StrongUint64.h:26
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
EVENGINE_API_FOUNDATION Result< std::string > scriptComponentStatesJson()
引擎侧脚本组件数据的**工具视图**(MCP eve_script_components 与诊断用)。
Definition ScriptComponentSnapshot.cpp:280
@ InvalidArgument
@ NotFound
@ UnknownVersion
@ Unsupported
@ ParseError
@ Conflict
EVENGINE_API_FOUNDATION Result< std::string > serializeScriptComponentSnapshot(PersistentId instanceId, Revision revision, SimulationTick tick, const SnapshotHashProvider &hashProvider)
采集并序列化成确定性 JSON(存档写盘用)。 @cost 同 snapshotScriptComponents + 一次序列化。
Definition ScriptComponentSnapshot.cpp:174
const Value * findScriptComponentValues(const ScriptComponentStoreKey &key)
读一条组件数据。
Definition ScriptComponentStore.cpp:41
void replaceScriptComponentValues(std::vector< ScriptComponentStoreEntry > entries)
用给定条目**整体替换**存储(恢复快照用)。
Definition ScriptComponentStore.cpp:81
@ Applied
constexpr const char * kScriptComponentSnapshotType
脚本组件快照的稳定类型(SnapshotEnvelope::type)。
Definition ScriptComponentSnapshot.h:29
EVENGINE_API_FOUNDATION Result< void > restoreScriptComponents(const SnapshotEnvelope &snapshot, const SnapshotHashProvider &hashProvider)
用快照里的数据**整体替换**当前的脚本组件数据。
Definition ScriptComponentSnapshot.cpp:93
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
std::vector< ScriptComponentStoreEntry > scriptComponentStoreEntries()
列出存储里的全部条目,按 (实体, 组件名, 版本) 升序。
Definition ScriptComponentStore.cpp:73
EVENGINE_API_FOUNDATION LogicalId scriptComponentSnapshotSchema()
脚本组件快照的 payload schema:eve:script-components 版本 1。
Definition ScriptComponentSnapshot.cpp:68
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
Result< void > verifySnapshotEnvelope(const SnapshotEnvelope &snapshot, const SnapshotHashProvider &hashProvider)
Verify an envelope's content hash without modifying it.
Definition Snapshot.cpp:63
const ScriptComponentRecord * findScriptComponent(const std::string &name, SchemaVersion version)
当前未退役的那条登记。
Definition ECS.cpp:1549
EVENGINE_API_FOUNDATION Result< std::vector< ScriptComponentInstanceState > > scriptComponentInstancesOf(const ssq::Object &entityInstance)
读一个脚本实体实例上挂着的全部**已登记**组件的状态。
Definition ScriptComponentSnapshot.cpp:187
std::function< Result< ContentId >(std::string_view canonicalInput)> SnapshotHashProvider
Injected content-digest implementation used by snapshots.
Definition Snapshot.h:36
EVENGINE_API_FOUNDATION Result< void > restoreScriptComponentSnapshotJson(std::string_view json, const SnapshotHashProvider &hashProvider)
从 JSON 解析、校验并恢复。
Definition ScriptComponentSnapshot.cpp:181
EVENGINE_API_FOUNDATION Result< SnapshotEnvelope > snapshotScriptComponents(PersistentId instanceId, Revision revision, SimulationTick tick, const SnapshotHashProvider &hashProvider)
把引擎侧的脚本组件数据封成一个快照信封。
Definition ScriptComponentSnapshot.cpp:74
一个脚本实体实例上某个组件的**当前状态**(供引擎工具读取)。
Definition ScriptComponentSnapshot.h:38
Stable outer format shared by persistence and cross-process snapshots.
Definition Snapshot.h:46