fill client holes (lockstep)

This commit is contained in:
2025-08-07 10:53:00 +02:00
parent c813c49707
commit ba84864b6a
9 changed files with 95 additions and 22 deletions

View File

@@ -2,6 +2,7 @@
#include <td/game/World.h>
#include <optional>
#include <td/misc/Signal.h>
namespace td {
namespace sim {
@@ -17,16 +18,18 @@ class ClientSimulation : public protocol::PacketHandler {
GameBuffer m_History;
std::uint64_t m_CurrentTime;
std::uint64_t m_LastTime;
std::size_t m_CurrentStep;
StepTime m_CurrentStep;
std::shared_ptr<WorldSnapshot> m_LastSnapshot;
std::uint64_t m_LastValidStep;
StepTime m_LastValidStep;
static const protocol::LockStep EMPTY_LOCKSTEP;
using protocol::PacketHandler::Handle;
public:
utils::Signal<const std::vector<StepTime>&> OnMissingLockSteps;
/**
* \brief Replay constructor
* \param a_StepTime in ms
@@ -45,15 +48,18 @@ class ClientSimulation : public protocol::PacketHandler {
float Update();
virtual void Handle(const protocol::packets::LockStepsPacket& a_LockSteps) override;
virtual void Handle(const protocol::packets::PredictCommandPacket& a_Predict) override;
virtual void Handle(const protocol::packets::LockStepResponsePacket& a_LockSteps) override;
private:
void Step();
/**
* \returns false if the empty lockstep was used
*/
bool Step();
/**
* \brief Ticks a_Count times
*/
void FastForward(std::size_t a_Count);
std::size_t FastForward(std::size_t a_Count);
/**
* \brief Tries to recompute simulation if needed (for example in late command receival)