From 1cc9f503a44dc77096eb7140d6f2bcdaf9e51a79 Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 11 Aug 2017 17:22:25 +1000 Subject: [PATCH] DT can actually be 0 :P (e.g. in server with no graphics, and I guess on really fast computers). Bad things happen with dt=0, so set dt to at least 1 ms. --- src/main_loop.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main_loop.cpp b/src/main_loop.cpp index 4b06403ae..5d429fa5d 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -86,7 +86,11 @@ float MainLoop::getLimitedDt() { m_curr_time = device->getTimer()->getRealTime(); dt = (float)(m_curr_time - m_prev_time); - if (dt <= 0) break; // should not really happen + if (dt <= 0) + { + dt = 1; // at least 1 ms, otherwise with dt=0 bad things happen + break; // should not really happen + } const World* const world = World::getWorld(); if (UserConfigParams::m_fps_debug && world) {