From 3cac7f33284df2a556f3dc367efe74f60aec3d8e Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 2 Jun 2022 21:20:46 +0200 Subject: fix: prevent ignoring generation update speed --- src/game/game.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 55877bb..b623e64 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -174,18 +174,21 @@ void Game::on_update() noexcept std::chrono::duration_cast( time_now - _last_gen_update_time); - if (time_since_last_gen_update.count() > GENERATION_UPDATE_SPEED_MILLIS) + if (time_since_last_gen_update.count() <= GENERATION_UPDATE_SPEED_MILLIS) { - const auto new_current_gen = _generation_tracker->get_current_generation() + 1U; + _last_update_time = time_now; + return; + } - _generation_tracker->set_current_generation(new_current_gen); + const auto new_current_gen = _generation_tracker->get_current_generation() + 1U; - _status_manager->set_section_body( - StatusLineSection::E, - fmt::format("{}", new_current_gen)); + _generation_tracker->set_current_generation(new_current_gen); - _last_gen_update_time = time_now; - } + _status_manager->set_section_body( + StatusLineSection::E, + fmt::format("{}", new_current_gen)); + + _last_gen_update_time = time_now; auto matrix = _scene->get_matrix(); -- cgit v1.2.3-18-g5258