diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2022-07-09 22:32:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-09 22:32:08 +0200 |
commit | 051181fa6ee00d8379e8a7dc7442b58342d4352b (patch) | |
tree | 58ad84f05310024b311c533684defdbeb5ee3e84 /src/client/renderingengine.cpp | |
parent | 7c261118e06c630ea9ad00f20d7005b8edc108dd (diff) | |
download | minetest-051181fa6ee00d8379e8a7dc7442b58342d4352b.tar.gz minetest-051181fa6ee00d8379e8a7dc7442b58342d4352b.tar.bz2 minetest-051181fa6ee00d8379e8a7dc7442b58342d4352b.zip |
Enforce limits of settings that could cause buggy behaviour (#12450)
Enforces the setting value bounds that are currently only limited by the GUI (settingtypes.txt).
Diffstat (limited to 'src/client/renderingengine.cpp')
-rw-r--r-- | src/client/renderingengine.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index 7afca4500..ea2dbfa80 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -86,8 +86,8 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver) // Resolution selection bool fullscreen = g_settings->getBool("fullscreen"); - u16 screen_w = g_settings->getU16("screen_w"); - u16 screen_h = g_settings->getU16("screen_h"); + u16 screen_w = std::max<u16>(g_settings->getU16("screen_w"), 1); + u16 screen_h = std::max<u16>(g_settings->getU16("screen_h"), 1); // bpp, fsaa, vsync bool vsync = g_settings->getBool("vsync"); @@ -598,7 +598,7 @@ static float calcDisplayDensity() float RenderingEngine::getDisplayDensity() { static float cached_display_density = calcDisplayDensity(); - return cached_display_density * g_settings->getFloat("display_density_factor"); + return std::max(cached_display_density * g_settings->getFloat("display_density_factor"), 0.5f); } #elif defined(_WIN32) @@ -626,14 +626,15 @@ float RenderingEngine::getDisplayDensity() display_density = calcDisplayDensity(get_video_driver()); cached = true; } - return display_density * g_settings->getFloat("display_density_factor"); + return std::max(display_density * g_settings->getFloat("display_density_factor"), 0.5f); } #else float RenderingEngine::getDisplayDensity() { - return (g_settings->getFloat("screen_dpi") / 96.0) * g_settings->getFloat("display_density_factor"); + return std::max(g_settings->getFloat("screen_dpi") / 96.0f * + g_settings->getFloat("display_density_factor"), 0.5f); } #endif |