summaryrefslogtreecommitdiff
path: root/src/client/gameui.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-01-22 17:56:35 +0100
committersfan5 <sfan5@live.de>2022-01-27 22:30:02 +0100
commit058846d687bef214fe6216938d4cf8bf2c79290e (patch)
treec1a74eb8b285b7e633e681604441cb1027a068b0 /src/client/gameui.cpp
parentfc161e757c14a0d0b86e69fb5ec631fae8b448de (diff)
downloadminetest-058846d687bef214fe6216938d4cf8bf2c79290e.tar.gz
minetest-058846d687bef214fe6216938d4cf8bf2c79290e.tar.bz2
minetest-058846d687bef214fe6216938d4cf8bf2c79290e.zip
Rework drawtime and related timekeeping code to use microseconds
Diffstat (limited to 'src/client/gameui.cpp')
-rw-r--r--src/client/gameui.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp
index ecb8e0ec4..bae5241b1 100644
--- a/src/client/gameui.cpp
+++ b/src/client/gameui.cpp
@@ -104,16 +104,16 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
// Minimal debug text must only contain info that can't give a gameplay advantage
if (m_flags.show_minimal_debug) {
- static float drawtime_avg = 0;
- drawtime_avg = drawtime_avg * 0.95 + stats.drawtime * 0.05;
- u16 fps = 1.0 / stats.dtime_jitter.avg;
+ const u16 fps = 1.0 / stats.dtime_jitter.avg;
+ m_drawtime_avg *= 0.95f;
+ m_drawtime_avg += 0.05f * (stats.drawtime / 1000);
std::ostringstream os(std::ios_base::binary);
os << std::fixed
<< PROJECT_NAME_C " " << g_version_hash
<< " | FPS: " << fps
<< std::setprecision(0)
- << " | drawtime: " << drawtime_avg << "ms"
+ << " | drawtime: " << m_drawtime_avg << "ms"
<< std::setprecision(1)
<< " | dtime jitter: "
<< (stats.dtime_jitter.max_fraction * 100.0) << "%"