From 7893342e1ba5fd01be7448244db967fda3c5cfe9 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Mon, 9 Dec 2024 17:35:20 +0100 Subject: checked for 0 division --- src/crepe/manager/LoopTimerManager.cpp | 7 +++++++ src/test/CMakeLists.txt | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/crepe/manager/LoopTimerManager.cpp b/src/crepe/manager/LoopTimerManager.cpp index 37b9c44..70a57d2 100644 --- a/src/crepe/manager/LoopTimerManager.cpp +++ b/src/crepe/manager/LoopTimerManager.cpp @@ -31,6 +31,9 @@ void LoopTimerManager::update() { if (this->delta_time > this->maximum_delta_time) { this->delta_time = this->maximum_delta_time; } + if(this->delta_time.count() <= 0){ + this->delta_time = std::chrono::duration(0.0); + } this->actual_fps = 1.0 / this->delta_time.count(); this->elapsed_time += this->delta_time; @@ -49,6 +52,10 @@ void LoopTimerManager::advance_fixed_update() { void LoopTimerManager::set_target_fps(int fps) { this->target_fps = fps; + //check if fps is lower or equals 0 + if(fps <= 0){ + return; + } // target time per frame in seconds this->frame_target_time = std::chrono::duration(1.0) / this->target_fps; } diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 1c963d8..a6d3387 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -15,7 +15,6 @@ target_sources(test_main PUBLIC Vector2Test.cpp LoopManagerTest.cpp LoopTimerTest.cpp - InputTest.cpp ScriptEventTest.cpp ScriptSceneTest.cpp -- cgit v1.2.3