aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/client/camera.cpp6
-rw-r--r--src/client/client.cpp8
-rw-r--r--src/client/client.h2
-rw-r--r--src/client/clouds.cpp3
-rw-r--r--src/client/fontengine.cpp12
-rw-r--r--src/client/game.cpp16
-rw-r--r--src/client/gameui.cpp2
-rw-r--r--src/client/hud.cpp2
-rw-r--r--src/client/joystick_controller.cpp12
-rw-r--r--src/client/render/stereo.cpp2
-rw-r--r--src/client/renderingengine.cpp11
-rw-r--r--src/client/tile.cpp2
-rw-r--r--src/emerge.cpp2
-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
-rw-r--r--src/map.cpp6
-rw-r--r--src/map.h2
-rw-r--r--src/mapgen/mapgen.cpp2
-rw-r--r--src/mapgen/mapgen_fractal.cpp1
-rw-r--r--src/nodedef.cpp2
-rw-r--r--src/server.cpp4
-rw-r--r--src/settings.cpp8
-rw-r--r--src/settings.h1
26 files changed, 69 insertions, 51 deletions
diff --git a/src/client/camera.cpp b/src/client/camera.cpp
index 7cc9cb6e8..df75c52d6 100644
--- a/src/client/camera.cpp
+++ b/src/client/camera.cpp
@@ -75,11 +75,11 @@ Camera::Camera(MapDrawControl &draw_control, Client *client, RenderingEngine *re
* (as opposed to the this local caching). This can be addressed in
* a later release.
*/
- m_cache_fall_bobbing_amount = g_settings->getFloat("fall_bobbing_amount");
- m_cache_view_bobbing_amount = g_settings->getFloat("view_bobbing_amount");
+ m_cache_fall_bobbing_amount = g_settings->getFloat("fall_bobbing_amount", 0.0f, 100.0f);
+ m_cache_view_bobbing_amount = g_settings->getFloat("view_bobbing_amount", 0.0f, 7.9f);
// 45 degrees is the lowest FOV that doesn't cause the server to treat this
// as a zoom FOV and load world beyond the set server limits.
- m_cache_fov = std::fmax(g_settings->getFloat("fov"), 45.0f);
+ m_cache_fov = g_settings->getFloat("fov", 45.0f, 160.0f);
m_arm_inertia = g_settings->getBool("arm_inertia");
m_nametags.clear();
m_show_nametag_backgrounds = g_settings->getBool("show_nametag_backgrounds");
diff --git a/src/client/client.cpp b/src/client/client.cpp
index 37d4bd816..0f8297080 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -118,6 +118,7 @@ Client::Client(
m_particle_manager(&m_env),
m_con(new con::Connection(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this)),
m_address_name(address_name),
+ m_allow_login_or_register(allow_login_or_register),
m_server_ser_ver(SER_FMT_VER_INVALID),
m_last_chat_message_sent(time(NULL)),
m_password(password),
@@ -125,8 +126,7 @@ Client::Client(
m_media_downloader(new ClientMediaDownloader()),
m_state(LC_Created),
m_game_ui(game_ui),
- m_modchannel_mgr(new ModChannelMgr()),
- m_allow_login_or_register(allow_login_or_register)
+ m_modchannel_mgr(new ModChannelMgr())
{
// Add local player
m_env.setLocalPlayer(new LocalPlayer(this, playername));
@@ -424,7 +424,7 @@ void Client::step(float dtime)
if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) {
std::vector<v3s16> deleted_blocks;
m_env.getMap().timerUpdate(map_timer_and_unload_dtime,
- g_settings->getFloat("client_unload_unused_data_timeout"),
+ std::max(g_settings->getFloat("client_unload_unused_data_timeout"), 0.0f),
g_settings->getS32("client_mapblock_limit"),
&deleted_blocks);
@@ -1254,7 +1254,7 @@ void Client::sendChatMessage(const std::wstring &message)
pkt << message;
Send(&pkt);
- } else if (m_out_chat_queue.size() < (u16) max_queue_size || max_queue_size == -1) {
+ } else if (m_out_chat_queue.size() < (u16) max_queue_size || max_queue_size < 0) {
m_out_chat_queue.push(message);
} else {
infostream << "Could not queue chat message because maximum out chat queue size ("
diff --git a/src/client/client.h b/src/client/client.h
index f01510ddb..bdcc2a3dd 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -349,7 +349,6 @@ public:
u16 getProtoVersion()
{ return m_proto_ver; }
- ELoginRegister m_allow_login_or_register = ELoginRegister::Any;
bool m_simple_singleplayer_mode;
float mediaReceiveProgress();
@@ -492,6 +491,7 @@ private:
ParticleManager m_particle_manager;
std::unique_ptr<con::Connection> m_con;
std::string m_address_name;
+ ELoginRegister m_allow_login_or_register = ELoginRegister::Any;
Camera *m_camera = nullptr;
Minimap *m_minimap = nullptr;
bool m_minimap_disabled_by_server = false;
diff --git a/src/client/clouds.cpp b/src/client/clouds.cpp
index 383a1d799..c84c03034 100644
--- a/src/client/clouds.cpp
+++ b/src/client/clouds.cpp
@@ -366,7 +366,8 @@ void Clouds::update(const v3f &camera_p, const video::SColorf &color_diffuse)
void Clouds::readSettings()
{
- m_cloud_radius_i = g_settings->getU16("cloud_radius");
+ // Upper limit was chosen due to posible render bugs
+ m_cloud_radius_i = rangelim(g_settings->getU16("cloud_radius"), 1, 62);
m_enable_3d = g_settings->getBool("enable_3d_clouds");
}
diff --git a/src/client/fontengine.cpp b/src/client/fontengine.cpp
index ad8305b45..0ae50dfe2 100644
--- a/src/client/fontengine.cpp
+++ b/src/client/fontengine.cpp
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "gettext.h"
#include "irrlicht_changes/CGUITTFont.h"
+#include "util/numeric.h" // rangelim
/** maximum size distance for getting a "similar" font size */
#define MAX_FONT_SIZE_OFFSET 10
@@ -172,9 +173,9 @@ unsigned int FontEngine::getFontSize(FontMode mode)
/******************************************************************************/
void FontEngine::readSettings()
{
- m_default_size[FM_Standard] = g_settings->getU16("font_size");
- m_default_size[_FM_Fallback] = g_settings->getU16("font_size");
- m_default_size[FM_Mono] = g_settings->getU16("mono_font_size");
+ m_default_size[FM_Standard] = rangelim(g_settings->getU16("font_size"), 5, 72);
+ m_default_size[_FM_Fallback] = m_default_size[FM_Standard];
+ m_default_size[FM_Mono] = rangelim(g_settings->getU16("mono_font_size"), 5, 72);
m_default_bold = g_settings->getBool("font_bold");
m_default_italic = g_settings->getBool("font_italic");
@@ -217,8 +218,9 @@ gui::IGUIFont *FontEngine::initFont(const FontSpec &spec)
if (spec.italic)
setting_suffix.append("_italic");
- u32 size = std::max<u32>(spec.size * RenderingEngine::getDisplayDensity() *
- g_settings->getFloat("gui_scaling"), 1);
+ // Font size in pixels for FreeType
+ u32 size = rangelim(spec.size * RenderingEngine::getDisplayDensity() *
+ g_settings->getFloat("gui_scaling"), 1U, 500U);
// Constrain the font size to a certain multiple, if necessary
u16 divisible_by = g_settings->getU16(setting_prefix + "font_size_divisible_by");
diff --git a/src/client/game.cpp b/src/client/game.cpp
index e6308c3b6..e838b337a 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -1932,7 +1932,7 @@ void Game::processKeyInput()
}
} else if (wasKeyDown(KeyType::INC_VOLUME)) {
if (g_settings->getBool("enable_sound")) {
- float new_volume = rangelim(g_settings->getFloat("sound_volume") + 0.1f, 0.0f, 1.0f);
+ float new_volume = g_settings->getFloat("sound_volume", 0.0f, 0.9f) + 0.1f;
g_settings->setFloat("sound_volume", new_volume);
std::wstring msg = fwgettext("Volume changed to %d%%", myround(new_volume * 100));
m_game_ui->showStatusText(msg);
@@ -1941,7 +1941,7 @@ void Game::processKeyInput()
}
} else if (wasKeyDown(KeyType::DEC_VOLUME)) {
if (g_settings->getBool("enable_sound")) {
- float new_volume = rangelim(g_settings->getFloat("sound_volume") - 0.1f, 0.0f, 1.0f);
+ float new_volume = g_settings->getFloat("sound_volume", 0.1f, 1.0f) - 0.1f;
g_settings->setFloat("sound_volume", new_volume);
std::wstring msg = fwgettext("Volume changed to %d%%", myround(new_volume * 100));
m_game_ui->showStatusText(msg);
@@ -4082,10 +4082,10 @@ void FpsControl::reset()
*/
void FpsControl::limit(IrrlichtDevice *device, f32 *dtime)
{
- const u64 frametime_min = 1000000.0f / (
- device->isWindowFocused() && !g_menumgr.pausesGame()
+ const float fps_limit = (device->isWindowFocused() && !g_menumgr.pausesGame())
? g_settings->getFloat("fps_max")
- : g_settings->getFloat("fps_max_unfocused"));
+ : g_settings->getFloat("fps_max_unfocused");
+ const u64 frametime_min = 1000000.0f / std::max(fps_limit, 1.0f);
u64 time = porting::getTimeUs();
@@ -4134,9 +4134,9 @@ void Game::readSettings()
m_cache_enable_joysticks = g_settings->getBool("enable_joysticks");
m_cache_enable_particles = g_settings->getBool("enable_particles");
m_cache_enable_fog = g_settings->getBool("enable_fog");
- m_cache_mouse_sensitivity = g_settings->getFloat("mouse_sensitivity");
- m_cache_joystick_frustum_sensitivity = g_settings->getFloat("joystick_frustum_sensitivity");
- m_repeat_place_time = g_settings->getFloat("repeat_place_time");
+ m_cache_mouse_sensitivity = g_settings->getFloat("mouse_sensitivity", 0.001f, 10.0f);
+ m_cache_joystick_frustum_sensitivity = std::max(g_settings->getFloat("joystick_frustum_sensitivity"), 0.001f);
+ m_repeat_place_time = g_settings->getFloat("repeat_place_time", 0.25f, 2.0);
m_cache_enable_noclip = g_settings->getBool("noclip");
m_cache_enable_free_move = g_settings->getBool("free_move");
diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp
index 01c733b4f..909719bbe 100644
--- a/src/client/gameui.cpp
+++ b/src/client/gameui.cpp
@@ -68,7 +68,7 @@ void GameUI::init()
u16 chat_font_size = g_settings->getU16("chat_font_size");
if (chat_font_size != 0) {
m_guitext_chat->setOverrideFont(g_fontengine->getFont(
- chat_font_size, FM_Unspecified));
+ rangelim(chat_font_size, 5, 72), FM_Unspecified));
}
diff --git a/src/client/hud.cpp b/src/client/hud.cpp
index 01f4d6ff3..c05ce76e8 100644
--- a/src/client/hud.cpp
+++ b/src/client/hud.cpp
@@ -55,7 +55,7 @@ Hud::Hud(Client *client, LocalPlayer *player,
this->player = player;
this->inventory = inventory;
- m_hud_scaling = g_settings->getFloat("hud_scaling");
+ m_hud_scaling = g_settings->getFloat("hud_scaling", 1.0f, 20.0f);
m_scale_factor = m_hud_scaling * RenderingEngine::getDisplayDensity();
m_hotbar_imagesize = std::floor(HOTBAR_IMAGE_SIZE *
RenderingEngine::getDisplayDensity() + 0.5f);
diff --git a/src/client/joystick_controller.cpp b/src/client/joystick_controller.cpp
index aae73c62d..9e58b9f62 100644
--- a/src/client/joystick_controller.cpp
+++ b/src/client/joystick_controller.cpp
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gettime.h"
#include "porting.h"
#include "util/string.h"
+#include "util/numeric.h"
bool JoystickButtonCmb::isTriggered(const irr::SEvent::SJoystickEvent &ev) const
{
@@ -202,9 +203,9 @@ JoystickLayout create_dragonrise_gamecube_layout()
}
-JoystickController::JoystickController() :
- doubling_dtime(g_settings->getFloat("repeat_joystick_button_time"))
+JoystickController::JoystickController()
{
+ doubling_dtime = std::max(g_settings->getFloat("repeat_joystick_button_time"), 0.001f);
for (float &i : m_past_pressed_time) {
i = 0;
}
@@ -217,19 +218,20 @@ void JoystickController::onJoystickConnect(const std::vector<irr::SJoystickInfo>
s32 id = g_settings->getS32("joystick_id");
std::string layout = g_settings->get("joystick_type");
- if (id < 0 || (u16)id >= joystick_infos.size()) {
+ if (id < 0 || id >= (s32)joystick_infos.size()) {
// TODO: auto detection
id = 0;
}
- if (id >= 0 && (u16)id < joystick_infos.size()) {
+ if (id >= 0 && id < (s32)joystick_infos.size()) {
if (layout.empty() || layout == "auto")
setLayoutFromControllerName(joystick_infos[id].Name.c_str());
else
setLayoutFromControllerName(layout);
}
- m_joystick_id = id;
+ // Irrlicht restriction.
+ m_joystick_id = rangelim(id, 0, UINT8_MAX);
}
void JoystickController::setLayoutFromControllerName(const std::string &name)
diff --git a/src/client/render/stereo.cpp b/src/client/render/stereo.cpp
index 967b5a78f..0f54e166e 100644
--- a/src/client/render/stereo.cpp
+++ b/src/client/render/stereo.cpp
@@ -27,7 +27,7 @@ RenderingCoreStereo::RenderingCoreStereo(
IrrlichtDevice *_device, Client *_client, Hud *_hud)
: RenderingCore(_device, _client, _hud)
{
- eye_offset = BS * g_settings->getFloat("3d_paralax_strength");
+ eye_offset = BS * g_settings->getFloat("3d_paralax_strength", -0.087f, 0.087f);
}
void RenderingCoreStereo::beforeDraw()
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
diff --git a/src/client/tile.cpp b/src/client/tile.cpp
index aa78c50f0..87d2818b4 100644
--- a/src/client/tile.cpp
+++ b/src/client/tile.cpp
@@ -1619,7 +1619,7 @@ bool TextureSource::generateImagePart(std::string part_of_name,
* textures that don't have the resources to offer high-res alternatives.
*/
const bool filter = m_setting_trilinear_filter || m_setting_bilinear_filter;
- const s32 scaleto = filter ? g_settings->getS32("texture_min_size") : 1;
+ const s32 scaleto = filter ? g_settings->getU16("texture_min_size") : 1;
if (scaleto > 1) {
const core::dimension2d<u32> dim = baseimg->getDimension();
diff --git a/src/emerge.cpp b/src/emerge.cpp
index 5c1569f04..e36d36448 100644
--- a/src/emerge.cpp
+++ b/src/emerge.cpp
@@ -173,7 +173,7 @@ EmergeManager::EmergeManager(Server *server, MetricsBackend *mb)
g_settings->getS16NoEx("num_emerge_threads", nthreads);
// If automatic, leave a proc for the main thread and one for
// some other misc thread
- if (nthreads == 0)
+ if (nthreads <= 0)
nthreads = Thread::getNumberOfProcessors() - 2;
if (nthreads < 1)
nthreads = 1;
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);
diff --git a/src/map.cpp b/src/map.cpp
index 213844d57..a53680065 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -323,7 +323,7 @@ struct TimeOrderedMapBlock {
/*
Updates usage timers
*/
-void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
+void Map::timerUpdate(float dtime, float unload_timeout, s32 max_loaded_blocks,
std::vector<v3s16> *unloaded_blocks)
{
bool save_before_unloading = maySaveBlocks();
@@ -340,7 +340,7 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
beginSave();
// If there is no practical limit, we spare creation of mapblock_queue
- if (max_loaded_blocks == U32_MAX) {
+ if (max_loaded_blocks < 0) {
for (auto &sector_it : m_sectors) {
MapSector *sector = sector_it.second;
@@ -399,7 +399,7 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
block_count_all = mapblock_queue.size();
// Delete old blocks, and blocks over the limit from the memory
- while (!mapblock_queue.empty() && (mapblock_queue.size() > max_loaded_blocks
+ while (!mapblock_queue.empty() && ((s32)mapblock_queue.size() > max_loaded_blocks
|| mapblock_queue.top().block->getUsageTimer() > unload_timeout)) {
TimeOrderedMapBlock b = mapblock_queue.top();
mapblock_queue.pop();
diff --git a/src/map.h b/src/map.h
index 931764215..6bc2aaaee 100644
--- a/src/map.h
+++ b/src/map.h
@@ -205,7 +205,7 @@ public:
Updates usage timers and unloads unused blocks and sectors.
Saves modified blocks before unloading if possible.
*/
- void timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
+ void timerUpdate(float dtime, float unload_timeout, s32 max_loaded_blocks,
std::vector<v3s16> *unloaded_blocks=NULL);
/*
diff --git a/src/mapgen/mapgen.cpp b/src/mapgen/mapgen.cpp
index cca036b7b..99db50426 100644
--- a/src/mapgen/mapgen.cpp
+++ b/src/mapgen/mapgen.cpp
@@ -1038,6 +1038,8 @@ void MapgenParams::readParams(const Settings *settings)
settings->getS16NoEx("chunksize", chunksize);
settings->getFlagStrNoEx("mg_flags", flags, flagdesc_mapgen);
+ chunksize = rangelim(chunksize, 1, 10);
+
delete bparams;
bparams = BiomeManager::createBiomeParams(BIOMEGEN_ORIGINAL);
if (bparams) {
diff --git a/src/mapgen/mapgen_fractal.cpp b/src/mapgen/mapgen_fractal.cpp
index fabb1b2b1..c9071cecf 100644
--- a/src/mapgen/mapgen_fractal.cpp
+++ b/src/mapgen/mapgen_fractal.cpp
@@ -131,6 +131,7 @@ void MapgenFractalParams::readParams(const Settings *settings)
settings->getNoiseParams("mgfractal_np_cave1", np_cave1);
settings->getNoiseParams("mgfractal_np_cave2", np_cave2);
settings->getNoiseParams("mgfractal_np_dungeons", np_dungeons);
+ iterations = std::max<u16>(iterations, 1);
}
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index a2af7e056..4022ac835 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -279,7 +279,7 @@ void TextureSettings::readSettings()
bool smooth_lighting = g_settings->getBool("smooth_lighting");
enable_mesh_cache = g_settings->getBool("enable_mesh_cache");
enable_minimap = g_settings->getBool("enable_minimap");
- node_texture_size = g_settings->getU16("texture_min_size");
+ node_texture_size = std::min<u16>(g_settings->getU16("texture_min_size"), 1);
std::string leaves_style_str = g_settings->get("leaves_style");
std::string world_aligned_mode_str = g_settings->get("world_aligned_mode");
std::string autoscale_mode_str = g_settings->get("autoscale_mode");
diff --git a/src/server.cpp b/src/server.cpp
index d94271143..24e352658 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -646,8 +646,8 @@ void Server::AsyncRunStep(bool initial_step)
// Run Map's timers and unload unused data
ScopeProfiler sp(g_profiler, "Server: map timer and unload");
m_env->getMap().timerUpdate(map_timer_and_unload_dtime,
- g_settings->getFloat("server_unload_unused_data_timeout"),
- U32_MAX);
+ std::max(g_settings->getFloat("server_unload_unused_data_timeout"), 0.0f),
+ -1);
}
/*
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);
diff --git a/src/settings.h b/src/settings.h
index 767d057f9..4b0787343 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -164,6 +164,7 @@ public:
s32 getS32(const std::string &name) const;
u64 getU64(const std::string &name) const;
float getFloat(const std::string &name) const;
+ float getFloat(const std::string &name, float min, float max) const;
v2f getV2F(const std::string &name) const;
v3f getV3F(const std::string &name) const;
u32 getFlagStr(const std::string &name, const FlagDesc *flagdesc,