Permalink
Browse files

Static view range

  • Loading branch information...
alexxvk authored and proller committed Jun 2, 2017
1 parent b56424e commit b72980e7c33281e3f1808fba212bbb88a8f2cc4a
Showing with 44 additions and 15 deletions.
  1. +5 −0 freeminer.conf.example
  2. +7 −0 src/camera.cpp
  3. +1 −0 src/defaultsettings.cpp
  4. +31 −15 src/game.cpp
View
@@ -1682,6 +1682,11 @@
## Client
# Static viewing range.
# Set this to true to disable automatic rendering range adjustment.
# type: bool
# static_viewing_range = false
# Minimum wanted FPS.
# The amount of rendered stuff is dynamically set according to this. and viewing range min and max.
# type: int
View
@@ -119,6 +119,8 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
m_cache_zoom_fov = g_settings->getFloat("zoom_fov");
m_cache_view_bobbing = g_settings->getBool("view_bobbing");
m_nametags.clear();
m_draw_control.wanted_range = g_settings->getFloat("viewing_range");
}
Camera::~Camera()
@@ -519,6 +521,9 @@ void Camera::updateViewingRange()
return;
}
if (g_settings->getBool("static_viewing_range")) {
m_draw_control.wanted_range = viewing_range;
} else {
// Get current viewing range and FPS settings
f32 viewing_range_min = viewing_range;
@@ -589,6 +594,8 @@ void Camera::updateViewingRange()
}
}
} // static_viewing_range
g_profiler->add("CM: wanted_range", m_draw_control.wanted_range);
const auto viewing_range_new = m_draw_control.wanted_range;
View
@@ -453,6 +453,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("fps_max", "60");
settings->setDefault("pause_fps_max", "20");
settings->setDefault("viewing_range", "100");
settings->setDefault("static_viewing_range", "false");
settings->setDefault("map_generation_limit", "31000");
settings->setDefault("screenW", "800");
settings->setDefault("screenH", "600");
View
@@ -3639,20 +3639,28 @@ void Game::toggleProfiler(float *statustext_time, u32 *profiler_current_page,
void Game::increaseViewRange(float *statustext_time)
{
s16 range = g_settings->getS16("viewing_range");
s16 range_new = range * 1.5;
s16 range_new;
int farmesh = g_settings->getS32("farmesh");
if (farmesh) {
range_new = range * 1.5;
} else {
range_new = range + 16;
}
// it's < 0 if it's outside the range of s16
// and increase it directly from 1 to 5 for less key pressing
if (range_new < 20)
range_new = 20;
// and increase it directly from 1 to 16 for less key pressing
if (range_new < 16)
range_new = 16;
// FMTODO: Add translations for this messages
if (range_new > 31000) {
range_new = 31000;
statustext = utf8_to_wide("Viewing range is at maximum: "
+ itos(range_new));
statustext = utf8_to_wide("Viewing range is at maximum: +"
+ itos(range_new/16) + " chunks");
} else {
statustext = utf8_to_wide("Viewing range changed to "
+ itos(range_new));
statustext = utf8_to_wide("Viewing range changed to +"
+ itos(range_new/16) + " chunks");
}
g_settings->set("viewing_range", itos(range_new));
*statustext_time = 0;
@@ -3662,15 +3670,23 @@ void Game::increaseViewRange(float *statustext_time)
void Game::decreaseViewRange(float *statustext_time)
{
s16 range = g_settings->getS16("viewing_range");
s16 range_new = range / 1.5;
s16 range_new;
int farmesh = g_settings->getS32("farmesh");
if (farmesh) {
range_new = range / 1.5;
} else {
range_new = range - 16;
}
if (range_new < 20) {
range_new = 20;
statustext = utf8_to_wide("Viewing range is at minimum: "
+ itos(range_new));
// FMTODO: Add translations for this messages
if (range_new < 16) {
range_new = 16;
statustext = utf8_to_wide("Viewing range is at minimum: +"
+ itos(range_new/16) + " chunks");
} else {
statustext = utf8_to_wide("Viewing range changed to "
+ itos(range_new));
statustext = utf8_to_wide("Viewing range changed to +"
+ itos(range_new/16) + " chunks");
}
g_settings->set("viewing_range", itos(range_new));
*statustext_time = 0;

0 comments on commit b72980e

Please sign in to comment.