From 70b53d90ef650e6d3e01667122a6f0c8af4e3fb2 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sun, 13 Jun 2004 19:48:04 +0000 Subject: [PATCH] Avoid problems when get_time() frequently returns the same value twice This was SVN commit r503. --- source/lib/timer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/lib/timer.cpp b/source/lib/timer.cpp index 89cc5985c4..821c2619d7 100755 --- a/source/lib/timer.cpp +++ b/source/lib/timer.cpp @@ -114,6 +114,9 @@ void calc_fps() cur_fps = 1.0f / (float)(t-last_t); // = 1 / elapsed time last_t = t; + if (cur_fps > 1e+6) // Avoid undesirable infinities if some frames + return; // were rendered in no time + // calculate fps activity over 3 frames (used below to prevent fluctuation) // -1: decreasing, +1: increasing, 0: neither or fluctuating float h1 = fps_hist[(head-1)%H]; // last frame's cur_fps