载入中...
搜索中...
未找到
TacticsGameSaveParticipant.cpp
浏览该文件的文档.
2
4
5#include <utility>
6
7namespace eve::tactics {
8namespace {
9
10class PreparedTacticsGameRestore final : public IPreparedGameRestore {
11public:
12 explicit PreparedTacticsGameRestore(TacticsPersistence::PreparedRestore prepared)
13 : prepared_(std::move(prepared)) {}
14 void commit() noexcept override { TacticsPersistence::commitPrepared(std::move(prepared_)); }
15
16private:
17 TacticsPersistence::PreparedRestore prepared_;
18};
19
20} // namespace
21
23 : battle_(&battle), hashProvider_(std::move(hashProvider)) {}
24
25std::string_view TacticsGameSaveParticipant::saveKey() const noexcept { return "tactics"; }
26
28 auto snapshot = TacticsPersistence::snapshot(*battle_, hashProvider_);
29 if (!snapshot.ok()) return Result<Value>::failure(snapshot.status());
30 return snapshotEnvelopeValue(snapshot.value());
31}
32
34 auto snapshot = parseSnapshotEnvelopeValue(state, hashProvider_);
35 if (!snapshot.ok()) return Result<std::unique_ptr<IPreparedGameRestore>>::failure(snapshot.status());
36 auto prepared = TacticsPersistence::prepareRestore(*battle_, snapshot.value(), hashProvider_);
37 if (!prepared.ok()) return Result<std::unique_ptr<IPreparedGameRestore>>::failure(prepared.status());
38 std::unique_ptr<IPreparedGameRestore> result =
39 std::make_unique<PreparedTacticsGameRestore>(std::move(prepared).takeValue());
40 return Result<std::unique_ptr<IPreparedGameRestore>>::success(std::move(result));
41}
42
43} // namespace eve::tactics
Poco::JSON::Object::Ptr result
Snapshot snapshot
Versioned battle snapshots with transactional restore.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
Battle short-root and authoritative owner of board and turn state.
TacticsGameSaveParticipant(Battle &battle, SnapshotHashProvider hashProvider)
Battle and digest contract must remain stable for this adapter's lifetime.
Result< std::unique_ptr< IPreparedGameRestore > > prepare(const Value &state) override
Validate and prepare a no-fail commit without changing live state.
std::string_view saveKey() const noexcept override
Stable unique participant key within the game-save schema.
Result< Value > capture() const override
Capture an independent owning snapshot of this domain.
static Result< SnapshotEnvelope > snapshot(Battle &battle, const SnapshotHashProvider &hashProvider)
Capture a version-one, integrity-sealed battle snapshot.
static Result< PreparedRestore > prepareRestore(Battle &battle, const SnapshotEnvelope &snapshot, const SnapshotHashProvider &hashProvider)
Verify and resolve a battle snapshot without changing live state. @thread Owning simulation thread; b...
static void commitPrepared(PreparedRestore prepared) noexcept
Publish a previously prepared battle state without further fallible work.
Result< VehiclePhysicsStatus > commit(physics::World &world, physics::ForceBatch &batch, std::shared_ptr< VehicleWheelRuntime > &runtime, std::vector< VehicleEntity::SuspensionState::WheelState > candidate, const SimulationStep &step)
Result< Value > snapshotEnvelopeValue(const SnapshotEnvelope &snapshot)
Convert an envelope to its strict canonical value representation.
Definition Snapshot.cpp:121
Result< SnapshotEnvelope > parseSnapshotEnvelopeValue(const Value &value, const SnapshotHashProvider &hashProvider)
Parse and verify an envelope from an owning Value.
Definition Snapshot.cpp:136
std::function< Result< ContentId >(std::string_view canonicalInput)> SnapshotHashProvider
Injected content-digest implementation used by snapshots.
Definition Snapshot.h:36