Browse Source

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).
SmallJoker 1 year ago
parent
commit
051181fa6e

+ 1 - 1
builtin/mainmenu/dlg_contentstore.lua

@@ -191,7 +191,7 @@ end
 
 local function queue_download(package, reason)
 	local max_concurrent_downloads = tonumber(core.settings:get("contentdb_max_concurrent_downloads"))
-	if number_downloading < max_concurrent_downloads then
+	if number_downloading < math.max(max_concurrent_downloads, 1) then
 		start_install(package, reason)
 	else
 		table.insert(download_queue, { package = package, reason = reason })

+ 4 - 4
builtin/settingtypes.txt

@@ -95,7 +95,7 @@ always_fly_fast (Always fly fast) bool true
 
 #    The time in seconds it takes between repeated node placements when holding
 #    the place button.
-repeat_place_time (Place repetition interval) float 0.25 0.001
+repeat_place_time (Place repetition interval) float 0.25 0.25 2
 
 #    Automatically jump up single-node obstacles.
 autojump (Automatic jumping) bool false
@@ -223,7 +223,7 @@ view_bobbing_amount (View bobbing factor) float 1.0 0.0 7.9
 
 #    Multiplier for fall bobbing.
 #    For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double.
-fall_bobbing_amount (Fall bobbing factor) float 0.03 0.0
+fall_bobbing_amount (Fall bobbing factor) float 0.03 0.0 100.0
 
 [**Camera]
 
@@ -1877,7 +1877,7 @@ server_side_occlusion_culling (Server side occlusion culling) bool true
 #    Reducing this value increases cave and dungeon density.
 #    Altering this value is for special usage, leaving it unchanged is
 #    recommended.
-chunksize (Chunk size) int 5 1 5
+chunksize (Chunk size) int 5 1 10
 
 #    Dump the mapgen debug information.
 enable_mapgen_debug_info (Mapgen debug) bool false
@@ -1926,7 +1926,7 @@ curl_file_download_timeout (cURL file download timeout) int 300000 100 214748364
 screen_dpi (DPI) int 72 1
 
 #    Adjust the detected display density, used for scaling UI elements.
-display_density_factor (Display Density Scaling Factor) float 1
+display_density_factor (Display Density Scaling Factor) float 1 0.5 5.0
 
 #    Windows systems only: Start Minetest with the command line window in the background.
 #    Contains the same information as the file debug.txt (default name).

+ 3 - 3
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");

+ 4 - 4
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 ("

+ 1 - 1
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;

+ 2 - 1
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");
 }
 

+ 7 - 5
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");

+ 8 - 8
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");

+ 1 - 1
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));
 	}
 
 

+ 1 - 1
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);

+ 7 - 5
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)

+ 1 - 1
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()

+ 6 - 5
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

+ 1 - 1
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();
 

+ 1 - 1
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;

+ 2 - 2
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;

+ 2 - 2
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) {

+ 1 - 1
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

+ 1 - 1
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;

+ 1 - 1
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);

+ 3 - 3
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();

+ 1 - 1
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);
 
 	/*

+ 2 - 0
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) {

+ 1 - 0
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);
 }
 
 

+ 1 - 1
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");

+ 2 - 2
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);
 	}
 
 	/*

+ 8 - 0
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);

+ 1 - 0
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,