aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/game.cpp7
-rw-r--r--src/defaultsettings.cpp4
-rw-r--r--src/gui/guiEngine.cpp17
-rw-r--r--src/gui/guiEngine.h2
4 files changed, 16 insertions, 14 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 920383aaf..8f9d51417 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -3996,9 +3996,10 @@ inline void Game::limitFps(FpsControl *fps_timings, f32 *dtime)
else
fps_timings->busy_time = 0;
- u32 frametime_min = 1000 / (g_menumgr.pausesGame()
- ? g_settings->getFloat("pause_fps_max")
- : g_settings->getFloat("fps_max"));
+ u32 frametime_min = 1000 / (
+ device->isWindowFocused() && !g_menumgr.pausesGame()
+ ? g_settings->getFloat("fps_max")
+ : g_settings->getFloat("fps_max_unfocused"));
if (fps_timings->busy_time < frametime_min) {
fps_timings->sleep_time = frametime_min - fps_timings->busy_time;
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 3a0b88dc2..8f5ed3e17 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -165,7 +165,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("tooltip_show_delay", "400");
settings->setDefault("tooltip_append_itemname", "false");
settings->setDefault("fps_max", "60");
- settings->setDefault("pause_fps_max", "20");
+ settings->setDefault("fps_max_unfocused", "20");
settings->setDefault("viewing_range", "100");
#if ENABLE_GLES
settings->setDefault("near_plane", "0.1");
@@ -477,7 +477,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("max_block_generate_distance", "5");
settings->setDefault("enable_3d_clouds", "false");
settings->setDefault("fps_max", "30");
- settings->setDefault("pause_fps_max", "10");
+ settings->setDefault("fps_max_unfocused", "10");
settings->setDefault("max_objects_per_block", "20");
settings->setDefault("sqlite_synchronous", "1");
settings->setDefault("server_map_save_interval", "15");
diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp
index b40707d01..4a13f0b11 100644
--- a/src/gui/guiEngine.cpp
+++ b/src/gui/guiEngine.cpp
@@ -297,10 +297,14 @@ void GUIEngine::run()
driver->endScene();
+ IrrlichtDevice *device = RenderingEngine::get_raw_device();
+ u32 frametime_min = 1000 / (device->isWindowFocused()
+ ? g_settings->getFloat("fps_max")
+ : g_settings->getFloat("fps_max_unfocused"));
if (m_clouds_enabled)
- cloudPostProcess();
+ cloudPostProcess(frametime_min, device);
else
- sleep_ms(25);
+ sleep_ms(frametime_min);
m_script->step();
@@ -367,9 +371,8 @@ void GUIEngine::cloudPreProcess()
}
/******************************************************************************/
-void GUIEngine::cloudPostProcess()
+void GUIEngine::cloudPostProcess(u32 frametime_min, IrrlichtDevice *device)
{
- float fps_max = g_settings->getFloat("pause_fps_max");
// Time of frame without fps limit
u32 busytime_u32;
@@ -380,12 +383,10 @@ void GUIEngine::cloudPostProcess()
else
busytime_u32 = 0;
- // FPS limiter
- u32 frametime_min = 1000./fps_max;
-
+ // FPS limit
if (busytime_u32 < frametime_min) {
u32 sleeptime = frametime_min - busytime_u32;
- RenderingEngine::get_raw_device()->sleep(sleeptime);
+ device->sleep(sleeptime);
}
}
diff --git a/src/gui/guiEngine.h b/src/gui/guiEngine.h
index f9ad0fb0a..e5b3edce7 100644
--- a/src/gui/guiEngine.h
+++ b/src/gui/guiEngine.h
@@ -277,7 +277,7 @@ private:
/** do preprocessing for cloud subsystem */
void cloudPreProcess();
/** do postprocessing for cloud subsystem */
- void cloudPostProcess();
+ void cloudPostProcess(u32 frametime_min, IrrlichtDevice *device);
/** internam data required for drawing clouds */
struct clouddata {