View range: Set maximum to 4000 nodes
authorRogier <rogier777@gmail.com>
Sat, 10 Dec 2016 23:23:32 +0000 (00:23 +0100)
committerparamat <mat.gregory@virginmedia.com>
Mon, 12 Dec 2016 07:20:50 +0000 (07:20 +0000)
The network protocol does not support larger than 255 mapblocks.

builtin/settingtypes.txt
minetest.conf.example
src/client.cpp
src/game.cpp

index 10db4787dbb7861143057f5a583397ff602b3991..822568af441aae59d9f4ed96d0bf9944a4ed29b1 100644 (file)
@@ -418,8 +418,7 @@ fps_max (Maximum FPS) int 60
 pause_fps_max (FPS in pause menu) int 20
 
 #    View distance in nodes.
-#    Min = 20
-viewing_range (Viewing range) int 100
+viewing_range (Viewing range) int 100 20 4000
 
 #    Width component of the initial window size.
 screenW (Screen width) int 800
index 90d7af0a3de9b9cbaef93d439d37649ded206a03..f0e5f1d479605c0d4520954ecfe1dc2ffebb9072 100644 (file)
 # pause_fps_max = 20
 
 #    View distance in nodes.
-#    Min = 20
-#    type: int
+#    type: int min: 20 max: 4000
 # viewing_range = 100
 
 #    Width component of the initial window size.
index 7e88e5562136ac4691751fe72641f332f038c9ab..5476aad0e2ebdff8748ee3093a05dd94b6eb32bc 100644 (file)
@@ -940,7 +940,8 @@ void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *
        u32 keyPressed   = myplayer->keyPressed;
        // scaled by 80, so that pi can fit into a u8
        u8 fov           = clientMap->getCameraFov() * 80;
-       u8 wanted_range  = std::ceil(clientMap->getControl().wanted_range / MAP_BLOCKSIZE);
+       u8 wanted_range  = MYMIN(255,
+                       std::ceil(clientMap->getControl().wanted_range / MAP_BLOCKSIZE));
 
        v3s32 position(pf.X, pf.Y, pf.Z);
        v3s32 speed(sf.X, sf.Y, sf.Z);
index 18b28c142763591316dfb8cd0839eefdeddfd9b4..ea07accf8de5085aede8a12bf1400e21061fd4f6 100644 (file)
@@ -3277,9 +3277,16 @@ void Game::increaseViewRange(float *statustext_time)
 {
        s16 range = g_settings->getS16("viewing_range");
        s16 range_new = range + 10;
+
+       if (range_new > 4000) {
+               range_new = 4000;
+               statustext = utf8_to_wide("Viewing range is at maximum: "
+                               + itos(range_new));
+       } else {
+               statustext = utf8_to_wide("Viewing range changed to "
+                               + itos(range_new));
+       }
        g_settings->set("viewing_range", itos(range_new));
-       statustext = utf8_to_wide("Viewing range changed to "
-                       + itos(range_new));
        *statustext_time = 0;
 }
 
@@ -3289,12 +3296,15 @@ void Game::decreaseViewRange(float *statustext_time)
        s16 range = g_settings->getS16("viewing_range");
        s16 range_new = range - 10;
 
-       if (range_new < 20)
+       if (range_new < 20) {
                range_new = 20;
-
+               statustext = utf8_to_wide("Viewing range is at minimum: "
+                               + itos(range_new));
+       } else {
+               statustext = utf8_to_wide("Viewing range changed to "
+                               + itos(range_new));
+       }
        g_settings->set("viewing_range", itos(range_new));
-       statustext = utf8_to_wide("Viewing range changed to "
-                       + itos(range_new));
        *statustext_time = 0;
 }