aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2022-07-09 22:32:08 +0200
committerGitHub <noreply@github.com>2022-07-09 22:32:08 +0200
commit051181fa6ee00d8379e8a7dc7442b58342d4352b (patch)
tree58ad84f05310024b311c533684defdbeb5ee3e84 /src/gui
parent7c261118e06c630ea9ad00f20d7005b8edc108dd (diff)
downloadminetest-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/gui')
-rw-r--r--src/gui/guiChatConsole.cpp4
-rw-r--r--src/gui/guiFormSpecMenu.cpp4
-rw-r--r--src/gui/guiTable.cpp2
-rw-r--r--src/gui/modalMenu.cpp2
-rw-r--r--src/gui/touchscreengui.cpp2
5 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/guiChatConsole.cpp b/src/gui/guiChatConsole.cpp
index 01e10ea2e..280f7e45b 100644
--- a/src/gui/guiChatConsole.cpp
+++ b/src/gui/guiChatConsole.cpp
@@ -76,9 +76,9 @@ GUIChatConsole::GUIChatConsole(
m_background_color.setBlue(clamp_u8(myround(console_color.Z)));
}
- u16 chat_font_size = g_settings->getU16("chat_font_size");
+ const u16 chat_font_size = g_settings->getU16("chat_font_size");
m_font = g_fontengine->getFont(chat_font_size != 0 ?
- chat_font_size : FONT_SIZE_UNSPECIFIED, FM_Mono);
+ rangelim(chat_font_size, 5, 72) : FONT_SIZE_UNSPECIFIED, FM_Mono);
if (!m_font) {
errorstream << "GUIChatConsole: Unable to load mono font" << std::endl;
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index e01a5347a..e4ea9ff58 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -3212,8 +3212,8 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
offset = v2s32(0,0);
}
- double gui_scaling = g_settings->getFloat("gui_scaling");
- double screen_dpi = RenderingEngine::getDisplayDensity() * 96;
+ const double gui_scaling = g_settings->getFloat("gui_scaling", 0.5f, 42.0f);
+ const double screen_dpi = RenderingEngine::getDisplayDensity() * 96;
double use_imgsize;
if (m_lock) {
diff --git a/src/gui/guiTable.cpp b/src/gui/guiTable.cpp
index 79ae1aea3..3929d678b 100644
--- a/src/gui/guiTable.cpp
+++ b/src/gui/guiTable.cpp
@@ -84,7 +84,7 @@ GUITable::GUITable(gui::IGUIEnvironment *env,
#endif
core::rect<s32> relative_rect = m_scrollbar->getRelativePosition();
s32 width = (relative_rect.getWidth() / (2.0 / 3.0)) * density *
- g_settings->getFloat("gui_scaling");
+ g_settings->getFloat("gui_scaling", 0.5f, 20.0f);
m_scrollbar->setRelativePosition(core::rect<s32>(
relative_rect.LowerRightCorner.X-width,relative_rect.UpperLeftCorner.Y,
relative_rect.LowerRightCorner.X,relative_rect.LowerRightCorner.Y
diff --git a/src/gui/modalMenu.cpp b/src/gui/modalMenu.cpp
index 172eb11e6..cfc4d5c5a 100644
--- a/src/gui/modalMenu.cpp
+++ b/src/gui/modalMenu.cpp
@@ -40,7 +40,7 @@ GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
m_menumgr(menumgr),
m_remap_dbl_click(remap_dbl_click)
{
- m_gui_scale = g_settings->getFloat("gui_scaling");
+ m_gui_scale = std::max(g_settings->getFloat("gui_scaling"), 0.5f);
#ifdef HAVE_TOUCHSCREENGUI
float d = RenderingEngine::getDisplayDensity();
m_gui_scale *= 1.1 - 0.3 * d + 0.2 * d * d;
diff --git a/src/gui/touchscreengui.cpp b/src/gui/touchscreengui.cpp
index ebe1a6325..d483c136e 100644
--- a/src/gui/touchscreengui.cpp
+++ b/src/gui/touchscreengui.cpp
@@ -843,7 +843,7 @@ void TouchScreenGUI::translateEvent(const SEvent &event)
s32 dy = Y - m_pointerpos[event.TouchInput.ID].Y;
// adapt to similar behaviour as pc screen
- double d = g_settings->getFloat("mouse_sensitivity") * 3.0f;
+ const double d = g_settings->getFloat("mouse_sensitivity", 0.001f, 10.0f) * 3.0f;
m_camera_yaw_change -= dx * d;
m_camera_pitch = MYMIN(MYMAX(m_camera_pitch + (dy * d), -180), 180);