载入中...
搜索中...
未找到
RTSRestore.cpp
浏览该文件的文档.
10 snapshot.buildings.size() != buildingCount() || snapshot.resourceNodes.size() != resourceNodeCount() ||
14 DiagnosticCode::Conflict, "RTS snapshot topology/version does not match this module", "snapshot"));
55 DiagnosticCode::Conflict, "RTS snapshot contains an unknown/duplicate building", "buildings.subject"));
64 DiagnosticCode::Conflict, "RTS snapshot contains an unknown/duplicate player", "players.subject"));
68 DiagnosticCode::Conflict, "RTS snapshot contains an unknown/duplicate faction", "factions.subject"));
72 DiagnosticCode::Conflict, "RTS snapshot contains an unknown/duplicate match", "matches.subject"));
98 !validType(value.rallyTransport, static_cast<Unit*>(nullptr)) || !validUnits(value.reinforcements) ||
107 DiagnosticCode::Conflict, "RTS resource snapshot contains a non-unit worker", "resourceNodes.workers"));
113 DiagnosticCode::Conflict, "RTS player snapshot contains an invalid selection", "players.selection"));
119 DiagnosticCode::Conflict, "RTS faction snapshot contains invalid membership", "factions.members"));
121 if (!std::all_of(value.participants.begin(), value.participants.end(), [&](const auto& participant) {
163 auto validAttributes = attributeValidator.restore(attributes, currentAttributes.value().capturedRevision);
208 RTSUnitAttributeAdapter::restore(*unit, attributes, currentAttributes.value().capturedRevision);
235 unit->worker()->resourceNode = ResourceNodeLink::bind(handle(value.worker.resourceNode)).value();
252 if (unit->abilities()->channel) unit->abilities()->channel->target = handle(value.abilityTarget);
295 for (auto subject : value.builders) building->construction()->builders.push_back(handle(subject));
306 for (auto subject : value.reinforcements) building->rally()->reinforcements.push_back(handle(subject));
312 for (auto subject : value.occupants) building->garrison()->occupants.push_back(handle(subject));
379 if (unitCount() != 0 || buildingCount() != 0 || resourceNodeCount() != 0 || playerCount() != 0 ||
382 DiagnosticCode::Conflict, "RTS snapshot topology can only be rebuilt into an empty module", "snapshot"));
385 Diagnostic::error(DiagnosticCode::Conflict, "unsupported RTS snapshot version", "snapshot.version"));
393 auto reserveSubject = [&](SubjectRef subject) { return subject.isValid() && subjects.insert(subject).second; };
397 Diagnostic::error(DiagnosticCode::Conflict, "invalid/duplicate unit subject", "units.subject"));
401 Diagnostic::error(DiagnosticCode::Conflict, "invalid/duplicate building subject", "buildings.subject"));
409 Diagnostic::error(DiagnosticCode::Conflict, "invalid/duplicate player subject", "players.subject"));
413 Diagnostic::error(DiagnosticCode::Conflict, "invalid/duplicate faction subject", "factions.subject"));
417 Diagnostic::error(DiagnosticCode::Conflict, "invalid/duplicate match subject", "matches.subject"));
RTS module owner and phase-one composition profile entry point.
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
Canonical attributes component adapter, backed by attributes::AttributeSet.
Definition RTSTypes.h:323
Result< void > restore(const eve::attributes::AttributeProjectionSnapshot &snapshot, Revision expectedRevision)
Restore selected values after generation and revision checks.
Definition RTSTypes.cpp:338
RTS building domain root with placement and production composition.
Definition RTSTypes.h:840
static Result< EntityLink > bind(ecs::EntityHandle handle)
Bind a live ECS handle, rejecting a null or stale handle.
Definition RTSTypes.h:184
Faction domain root; membership is a set of typed runtime handles.
Definition RTSTypes.h:1178
Independent match composition root; factions may participate in different matches.
Definition RTSTypes.h:1295
Generic orders component adapter; the queue remains the sole order owner.
Definition RTSTypes.h:385
Result< void > restoreState(const Snapshot &snapshot)
Transactionally restore a complete RTS order projection.
Definition RTSTypes.cpp:501
Player domain root; selection is RTS-local, authority/economy/social are links.
Definition RTSTypes.h:1119
Production adapter whose queue owns all task state.
Definition RTSTypes.h:438
Result< void > restore(std::string_view json)
Transactionally restore the canonical production queue.
Definition RTSTypes.cpp:630
RTS adapter that keeps the common container as the sole instance owner.
Definition RTSEffects.h:77
eve::Result< void > restore(const RTSEffectSnapshot &snapshot)
Restore effects and target state, invalidating prior handles.
Definition RTSEffects.cpp:131
RTS impact adapter over the canonical pooled weapon projectile trajectory runtime.
Definition RTSSystems.h:653
Result< void > restore(const RTSProjectileSystemSnapshot &snapshot, const ProjectileSubjectResolver &resolver)
Validate and atomically restore shared trajectories plus RTS payloads.
Definition RTSSystems.cpp:3582
static eve::Result< void > restore(Unit &unit, const eve::attributes::AttributeProjectionSnapshot &snapshot, eve::Revision expectedRevision)
Restore selected unit combat stats after owner/revision checks.
Definition RTSAttributes.cpp:91
static eve::Result< eve::attributes::AttributeProjectionSnapshot > snapshot(Unit &unit)
Capture selected unit combat stats with owner generation and revision.
Definition RTSAttributes.cpp:81
std::size_t factionCount() const noexcept
Return the number of live Faction roots owned by this module.
Definition RTS.cpp:3622
Result< Player * > newPlayer(SubjectRef subject)
Create and own one Player root with a valid subject identity.
Definition RTS.cpp:595
Match * findMatch(SubjectRef subject) const noexcept
Resolve a module-owned match by persistent subject identity.
Definition RTS.cpp:3626
std::size_t matchCount() const noexcept
Return the number of live Match roots owned by this module.
Definition RTS.cpp:3623
Result< Building * > newBuilding(SubjectRef subject, LogicalId definition={})
Create and own one Building root.
Definition RTS.cpp:550
ResourceNode * findResourceNode(SubjectRef subject) const noexcept
Resolve a module-owned resource node by persistent subject identity.
Definition RTS.cpp:893
Result< Match * > newMatch(SubjectRef subject)
Create and own one independent RTS match composition root.
Definition RTS.cpp:798
Building * findBuilding(SubjectRef subject) const noexcept
Resolve a module-owned building by persistent subject identity.
Definition RTS.cpp:891
std::size_t buildingCount() const noexcept
Return the number of live Building roots owned by this module.
Definition RTS.cpp:3619
std::size_t resourceNodeCount() const noexcept
Return the number of live resource nodes owned by this module.
Definition RTS.cpp:3620
Result< Faction * > newFaction(SubjectRef subject)
Create and own one Faction root with a valid subject identity.
Definition RTS.cpp:610
std::size_t playerCount() const noexcept
Return the number of live Player roots owned by this module.
Definition RTS.cpp:3621
Result< ResourceNode * > newResourceNode(SubjectRef subject, std::string resourceType, float amount, WorldPosition position, std::size_t workerCapacity=1)
Create and own one harvestable resource node.
Definition RTS.cpp:571
Unit * findUnit(SubjectRef subject) const noexcept
Resolve a module-owned unit by persistent subject identity.
Definition RTS.cpp:889
Result< void > rebuildState(const RTSStateSnapshot &snapshot)
Materialize a complete snapshot into an empty RTS module.
Definition RTSRestore.cpp:378
Result< Unit * > newUnit(SubjectRef subject, LogicalId definition={})
Create and own one Unit root.
Definition RTS.cpp:519
std::size_t unitCount() const noexcept
Return the number of live Unit roots owned by this module.
Definition RTS.cpp:3618
Result< void > restoreState(const RTSStateSnapshot &snapshot)
Validate and atomically restore an exact-topology RTS root snapshot.
Definition RTSRestore.cpp:8
Faction * findFaction(SubjectRef subject) const noexcept
Resolve a module-owned faction by persistent subject identity.
Definition RTS.cpp:3625
Harvestable RTS resource node; deposited balances are owned by an external resource account.
Definition RTSTypes.h:1071
Entity-local sorted tags; this is the RTS entity's tag authority.
Definition RTSTypes.h:153
const std::vector< std::string > & values() const noexcept
Return tags in deterministic order.
Definition RTSTypes.h:162
Result< void > add(std::string_view tag)
Add a tag in deterministic lexical order.
Definition RTSTypes.cpp:233
SubjectRef subjectOf(ecs::Entity *entity)
Definition RTSSnapshotInternal.h:4
Definition RTS.cpp:24
@ Conflict
@ Applied
Complete RTS order projection snapshot; entity handles must be rebound by the owning domain.
Definition RTSTypes.h:388
std::vector< RTSProjectilePayloadSnapshot > payloads
Definition RTSSystems.h:646
weapon::ProjectileRuntimeSnapshot runtime
Definition RTSSystems.h:645
Complete RTS-owned state; v2 adds movement groups, v1 imports with no groups. @cost Linear in saved e...
Definition RTSSnapshot.h:172
std::vector< RTSPlayerSnapshot > players
Definition RTSSnapshot.h:178
std::vector< RTSResourceNodeSnapshot > resourceNodes
Definition RTSSnapshot.h:177
std::vector< RTSFactionSnapshot > factions
Definition RTSSnapshot.h:179
std::vector< RTSMatchSnapshot > matches
Definition RTSSnapshot.h:180
std::vector< RTSBuildingSnapshot > buildings
Definition RTSSnapshot.h:176
RTSProjectileSystemSnapshot projectiles
Definition RTSSnapshot.h:181
std::vector< ProjectileSlotSnapshot > slots
Definition ProjectileRuntime.h:98