26 m_hashes.push_back({.tick = tick, .hash = hash});
34 [&](
const sim::Command& command) { return command.targetTick < lastTick; });
50 return std::unexpected(replay.error());
52 if (replay->world !=
ReplayWorld::Probe || replay->startTick != 0 || !replay->initialDelta.empty())
53 return std::unexpected(
"仮の世界は刻み 0 の全部 0 の状態からしか再生できない");
59 std::vector<sim::Command> commands;
70 "再生: 刻み {} のコマンド(番号 {})が適用に間に合わなかった(次の適用は刻み {})", command.
targetTick,
76 commands.push_back(command);
83 const auto& commands =
m_replay.commands;
84 const auto& hashes =
m_replay.tickHashes;
89 rng::find_if(hashes, [&](
const ReplayTickHash& entry) {
return entry.
tick > tick; }) - hashes.begin());
93 const auto& expected =
m_replay.tickHashes;
void Rewind(uint64_t tick)
std::vector< sim::Command > TakeCommands(uint64_t applyTick, uint32_t limit)
static constexpr uint64_t LOOKAHEAD_TICKS
ReplayPlayer(ReplayFile replay)
void CheckHash(uint64_t tick, uint64_t hash)
static std::expected< ReplayPlayer, std::string > Load(const fs::path &path)
void AddCommands(std::span< const sim::Command > commands)
std::vector< sim::Command > m_commands
std::vector< ReplayTickHash > m_hashes
std::expected< void, std::string > Write(const fs::path &path) const
void AddHash(uint64_t tick, uint64_t hash)
constexpr uint64_t MAX_LOGGED_MISMATCHES
std::expected< ReplayFile, std::string > ReadReplayFile(const fs::path &path)
std::expected< void, std::string > WriteReplayFile(const fs::path &path, const ReplayFile &replay)
void Log(Channel channel, Level level, FormatWithLocation< std::type_identity_t< Args >... > pattern, Args &&... args)
std::vector< sim::Command > commands