send map when arriving late
This commit is contained in:
@@ -30,14 +30,22 @@ ClientSimulation::ClientSimulation(std::shared_ptr<game::World> a_World, GameHis
|
||||
Step();
|
||||
}
|
||||
|
||||
ClientSimulation::ClientSimulation(std::shared_ptr<game::World> a_World, std::uint64_t a_StepTime) :
|
||||
ClientSimulation::ClientSimulation(
|
||||
std::shared_ptr<game::World> a_World, std::uint64_t a_StepTime, const std::vector<protocol::LockStep>& a_FirstSteps) :
|
||||
m_StepTime(a_StepTime),
|
||||
m_World(a_World),
|
||||
m_History(std::numeric_limits<StepTime>::max()),
|
||||
m_CurrentTime(0),
|
||||
m_CurrentStep(0),
|
||||
m_LastSnapshot(std::make_shared<WorldSnapshot>()),
|
||||
m_LastValidStep(0) {}
|
||||
m_LastValidStep(0) {
|
||||
if (!a_FirstSteps.empty()) {
|
||||
for (std::size_t i = 0; i < a_FirstSteps.size(); i++) {
|
||||
m_History[i] = a_FirstSteps[i];
|
||||
}
|
||||
FastForward(a_FirstSteps.size());
|
||||
}
|
||||
}
|
||||
|
||||
float ClientSimulation::Update(float a_Delta) {
|
||||
// TODO: handle freezes (m_CurrentTime > 2 * m_StepTime)
|
||||
|
||||
@@ -47,6 +47,16 @@ protocol::packets::LockStepResponsePacket ServerSimulation::GetResponse(
|
||||
return {result};
|
||||
}
|
||||
|
||||
std::vector<protocol::LockStep> ServerSimulation::GetFirstLocksteps() {
|
||||
std::vector<protocol::LockStep> result;
|
||||
if (m_CurrentTime <= LOCKSTEP_BUFFER_SIZE)
|
||||
return result;
|
||||
|
||||
result.reserve(m_CurrentTime);
|
||||
result.insert(result.begin(), m_History.begin(), m_History.begin() + m_CurrentTime);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // namespace sim
|
||||
} // namespace td
|
||||
|
||||
Reference in New Issue
Block a user