#include namespace td { namespace game { GameHistory::GameHistory() : m_History(std::numeric_limits::max()) {} void GameHistory::SetLockStep(HistorySizeType a_Index, protocol::LockStep&& a_LockStep) { m_History[a_Index] = std::move(a_LockStep); } const protocol::LockStep& GameHistory::GetLockStep(HistorySizeType a_Index) const { return *m_History[a_Index]; } bool GameHistory::HasLockStep(HistorySizeType a_Index) const { return m_History[a_Index].has_value(); } void GameHistory::FromPacket(protocol::pdata::LockSteps&& a_Steps) { for (int i = 0; i < LOCKSTEP_BUFFER_SIZE; i++) { protocol::LockStep& step = a_Steps.m_LockSteps[i]; SetLockStep(i + a_Steps.m_FirstFrameNumber, std::move(step)); } } protocol::packets::LockStepsPacket GameHistory::ToPacket(HistorySizeType a_StartIndex) { std::array steps; for (int i = 0; i < LOCKSTEP_BUFFER_SIZE; i++) { steps[i] = GetLockStep(a_StartIndex + i); } return {a_StartIndex, std::move(steps)}; } } // namespace game } // namespace td