载入中...
搜索中...
未找到
PixelWorldReplay.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Result.h"
6#include "common/Snapshot.h"
7#include "common/Time.h"
9
10#include <cstdint>
11#include <optional>
12#include <span>
13#include <vector>
14
15namespace eve::pixelworld_replay {
16
22
25 int x = 0;
26 int y = 0;
27 std::uint64_t digest = 0;
29 friend bool operator==(const PixelChunkDigest&, const PixelChunkDigest&) = default;
30};
31
35 std::uint64_t revision = 0;
36 std::uint64_t worldDigest = 0;
37 std::vector<PixelChunkDigest> chunks;
38};
39
41enum class PixelReplayMatch : std::uint8_t { Matched, Diverged };
42
46 std::uint64_t expectedRevision = 0;
47 std::uint64_t actualRevision = 0;
48 std::optional<PixelChunkDigest> expectedChunk;
49 std::optional<PixelChunkDigest> actualChunk;
50};
51
59
68public:
70 [[nodiscard]] eve::Result<void> append(PixelReplayEntry entry);
71
76 [[nodiscard]] eve::Result<void> captureCheckpoint(const eve::pixelworld::PixelWorld& world);
77
85 [[nodiscard]] eve::Result<PixelReplayReceipt> replay(
87
94 [[nodiscard]] eve::Result<eve::SnapshotEnvelope> snapshot(
95 eve::PersistentId instanceId, const eve::SnapshotHashProvider& hashProvider) const;
96
104 [[nodiscard]] eve::Result<void> restoreSnapshot(
105 const eve::SnapshotEnvelope& snapshot, const eve::SnapshotHashProvider& hashProvider);
106
108 [[nodiscard]] std::span<const PixelReplayEntry> entries() const noexcept { return entries_; }
109 [[nodiscard]] std::span<const PixelReplayCheckpoint> checkpoints() const noexcept { return checkpoints_; }
110
111private:
112 std::vector<PixelReplayEntry> entries_;
113 std::vector<PixelReplayCheckpoint> checkpoints_;
114};
115
116} // namespace eve::pixelworld_replay
LogicalId target
#define EVENGINE_API_PLATFORM
Definition Export.h:107
World3D * world
Move-only, checked operation results for the common layer.
Versioned, integrity-checked persistence envelopes.
Common time values and an injectable deterministic simulation clock.
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Id128 public API.
Definition Identity.h:112
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
Sparse, chunked, deterministic 2D falling-material world.
Definition PixelWorld.h:224
Owning command log and periodic checkpoint projection for PixelWorld.
std::span< const PixelReplayEntry > entries() const noexcept
Immutable owning-log views, valid until this log is mutated or destroyed.
std::span< const PixelReplayCheckpoint > checkpoints() const noexcept
PixelReplayMatch
Replay verification outcome; divergence is data, not an operational failure.
std::function< Result< ContentId >(std::string_view canonicalInput)> SnapshotHashProvider
Injected content-digest implementation used by snapshots.
Definition Snapshot.h:36
Stable outer format shared by persistence and cross-process snapshots.
Definition Snapshot.h:46
Owning replayable edit command. Sequence must be exactly previous + 1.
Definition PixelWorld.h:155
Canonical content digest for one authoritative PixelWorld Chunk.
friend bool operator==(const PixelChunkDigest &, const PixelChunkDigest &)=default
Operator ==.
Periodic replay checkpoint containing world and per-Chunk diagnostics.
First canonical mismatch found while replaying a log.
std::optional< PixelChunkDigest > actualChunk
std::optional< PixelChunkDigest > expectedChunk
One deterministic edit admitted immediately before its simulation Tick.
eve::pixelworld::PixelEditCommand command
Receipt from deterministic replay through an exact target Tick.
std::optional< PixelReplayDivergence > firstDivergence