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/settings.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/settings.cpp')
-rw-r--r-- | src/settings.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 0e44ee0bc..a0225bc2c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_bloated.h" #include "exceptions.h" #include "threading/mutex_auto_lock.h" +#include "util/numeric.h" // rangelim #include "util/strfnd.h" #include <iostream> #include <fstream> @@ -534,6 +535,13 @@ float Settings::getFloat(const std::string &name) const } +float Settings::getFloat(const std::string &name, float min, float max) const +{ + float val = stof(get(name)); + return rangelim(val, min, max); +} + + u64 Settings::getU64(const std::string &name) const { std::string s = get(name); |