diff options
author | Rogier <rogier777@gmail.com> | 2016-12-11 00:23:32 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-12-12 07:20:50 +0000 |
commit | 02112f84e2102182816ffa48d5444a7321730936 (patch) | |
tree | 4ebcb70c6bc3401354489c33c2cc00b4e4091fcb /src | |
parent | 38abc91802ec12996d4fbb1e2f0ba4365d86b545 (diff) | |
download | minetest-02112f84e2102182816ffa48d5444a7321730936.tar.gz minetest-02112f84e2102182816ffa48d5444a7321730936.tar.bz2 minetest-02112f84e2102182816ffa48d5444a7321730936.zip |
View range: Set maximum to 4000 nodes
The network protocol does not support larger than 255 mapblocks.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 3 | ||||
-rw-r--r-- | src/game.cpp | 22 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/client.cpp b/src/client.cpp index 7e88e5562..5476aad0e 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -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); diff --git a/src/game.cpp b/src/game.cpp index 18b28c142..ea07accf8 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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; } |