diff options
author | HampusM <hampus@hampusmat.com> | 2022-06-02 21:20:46 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:57:00 +0200 |
commit | 3cac7f33284df2a556f3dc367efe74f60aec3d8e (patch) | |
tree | 77a19d88c2ed442691db4f699ff57162d5892b99 | |
parent | 7578eb6f79afbb421298088ee53da620eb04037f (diff) |
fix: prevent ignoring generation update speed
-rw-r--r-- | src/game/game.cpp | 19 |
1 files 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<std::chrono::milliseconds>( 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(); |