add debug fastforward
This commit is contained in:
@@ -52,7 +52,7 @@ DebugWorldState::DebugWorldState(Display& a_Display) : DisplayState(a_Display) {
|
||||
});
|
||||
|
||||
list.OnPlayerKick.Connect([this](PlayerID a_Player) {
|
||||
auto it = std::find_if(m_FakeClients.begin(), m_FakeClients.end(), [a_Player](auto& clientPtr){
|
||||
auto it = std::find_if(m_FakeClients.begin(), m_FakeClients.end(), [a_Player](auto& clientPtr) {
|
||||
if (!clientPtr->GetId().has_value())
|
||||
return false;
|
||||
return clientPtr->GetId().value() == a_Player;
|
||||
@@ -85,6 +85,7 @@ void DebugWorldState::OnAspectRatioChange(float a_Ratio) {
|
||||
|
||||
void DebugWorldState::OnKeyDown(SDL_Keycode a_Key) {
|
||||
// temporary tests
|
||||
constexpr int SECONDS = 10;
|
||||
switch (a_Key) {
|
||||
case SDLK_A:
|
||||
m_Client->SendPacket(td::protocol::packets::SpawnTroopPacket(td::EntityType::Zombie, 1));
|
||||
@@ -94,6 +95,11 @@ void DebugWorldState::OnKeyDown(SDL_Keycode a_Key) {
|
||||
m_Client->SendPacket(td::protocol::packets::PlaceTowerPacket(td::TowerType::Archer, td::TowerCoords(77, 13)));
|
||||
break;
|
||||
|
||||
case SDLK_F:
|
||||
m_Server->Update(SECONDS);
|
||||
m_Client->Update(SECONDS);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ float ClientSimulation::Update(float a_Delta) {
|
||||
// TODO: handle freezes (m_CurrentTime > 2 * m_StepTime)
|
||||
static const float stepTimeSecond = static_cast<float>(m_StepTime) / 1000.0f;
|
||||
m_CurrentTime += a_Delta;
|
||||
if (m_CurrentTime > stepTimeSecond) {
|
||||
m_CurrentTime = std::fmod(m_CurrentTime, stepTimeSecond);
|
||||
while (m_CurrentTime > stepTimeSecond) {
|
||||
m_CurrentTime -= stepTimeSecond;
|
||||
Step();
|
||||
}
|
||||
return (float)m_CurrentTime / stepTimeSecond;
|
||||
|
||||
Reference in New Issue
Block a user