From 191cb117f9663d9eaf218f07da023503d698f785 Mon Sep 17 00:00:00 2001 From: Desour Date: Mon, 10 Feb 2025 17:15:57 +0100 Subject: [PATCH] Don't use fps_max_unfocused for the pause menu Nowadays, we have things like buttons that change appearance on hover, or scoll bars in the pause menu. These do not work fine with low fps. --- builtin/settingtypes.txt | 4 ++-- src/client/game.cpp | 4 ++-- src/client/renderingengine.cpp | 4 ++-- src/client/renderingengine.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 4af232f42..d95733db1 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -256,8 +256,8 @@ fps_max (Maximum FPS) int 60 1 4294967295 # Vertical screen synchronization. Your system may still force VSync on even if this is disabled. vsync (VSync) bool false -# Maximum FPS when the window is not focused, or when the game is paused. -fps_max_unfocused (FPS when unfocused or paused) int 20 1 4294967295 +# Maximum FPS when the window is not focused. +fps_max_unfocused (FPS when unfocused) int 20 1 4294967295 # View distance in nodes. viewing_range (Viewing range) int 190 20 4000 diff --git a/src/client/game.cpp b/src/client/game.cpp index 93771a5a2..f7cb5c0db 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -968,7 +968,7 @@ void Game::run() // Calculate dtime = // m_rendering_engine->run() from this iteration // + Sleep time until the wanted FPS are reached - draw_times.limit(device, &dtime, g_menumgr.pausesGame()); + draw_times.limit(device, &dtime); framemarker.start(); @@ -2504,7 +2504,7 @@ inline void Game::step(f32 dtime) ZoneScoped; if (server) { - float fps_max = (!device->isWindowFocused() || g_menumgr.pausesGame()) ? + float fps_max = !device->isWindowFocused() ? g_settings->getFloat("fps_max_unfocused") : g_settings->getFloat("fps_max"); fps_max = std::max(fps_max, 1.0f); diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index 0989e645f..643898eac 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -34,9 +34,9 @@ void FpsControl::reset() last_time = porting::getTimeUs(); } -void FpsControl::limit(IrrlichtDevice *device, f32 *dtime, bool assume_paused) +void FpsControl::limit(IrrlichtDevice *device, f32 *dtime) { - const float fps_limit = (device->isWindowFocused() && !assume_paused) + const float fps_limit = device->isWindowFocused() ? g_settings->getFloat("fps_max") : g_settings->getFloat("fps_max_unfocused"); const u64 frametime_min = 1000000.0f / std::max(fps_limit, 1.0f); diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index b99a71900..d76b19abe 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -45,7 +45,7 @@ struct FpsControl { void reset(); - void limit(IrrlichtDevice *device, f32 *dtime, bool assume_paused = false); + void limit(IrrlichtDevice *device, f32 *dtime); u32 getBusyMs() const { return busy_time / 1000; }