From 53f6807ea6f35d06ba57ed11c17fe431b8241789 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 4 Jun 2018 23:48:40 -0400 Subject: [PATCH] make fps update less often in hud --- src/PowderToySDL.cpp | 11 ++++++++--- src/gui/game/GameView.cpp | 3 --- src/gui/interface/Engine.h | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index df6a6c813d..864df4e00b 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -286,7 +286,8 @@ std::map readArguments(int argc, char * argv[]) int elapsedTime = 0, currentTime = 0, lastTime = 0, currentFrame = 0; unsigned int lastTick = 0; -float fps = 0, delta = 1.0f; +unsigned int lastFpsUpdate = 0; +float fps = 0; ui::Engine * engine = NULL; bool showDoubleScreenDialog = false; float currentWidth, currentHeight; @@ -465,8 +466,12 @@ void EngineProcess() } int correctedFrameTime = SDL_GetTicks() - frameStart; correctedFrameTimeAvg = correctedFrameTimeAvg * 0.95 + correctedFrameTime * 0.05; - engine->SetFps(1000.0 / correctedFrameTimeAvg); - if(frameStart - lastTick > 1000) + if (frameStart - lastFpsUpdate > 200) + { + engine->SetFps(1000.0 / correctedFrameTimeAvg); + lastFpsUpdate = frameStart; + } + if (frameStart - lastTick > 1000) { //Run client tick every second lastTick = frameStart; diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 0a3662e0e1..64250ae45b 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -2420,9 +2420,6 @@ void GameView::OnDraw() //FPS and some version info StringBuilder fpsInfo; fpsInfo << Format::Precision(2) << "FPS: " << ui::Engine::Ref().GetFps(); -#ifdef DEBUG - fpsInfo << " Delta: " << ui::Engine::Ref().GetDelta(); -#endif if (showDebug) { diff --git a/src/gui/interface/Engine.h b/src/gui/interface/Engine.h index c0731c75ff..223b2db7b0 100644 --- a/src/gui/interface/Engine.h +++ b/src/gui/interface/Engine.h @@ -60,7 +60,6 @@ namespace ui void SetFps(float fps); inline float GetFps() { return fps; } - inline float GetDelta() { return dt; } inline int GetMouseButton() { return mouseb_; } inline int GetMouseX() { return mousex_; }