aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-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
12 files changed, 42 insertions, 36 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();