Skip to content

Commit

Permalink
View range: Set maximum to 4000 nodes
Browse files Browse the repository at this point in the history
The network protocol does not support larger than 255 mapblocks.
  • Loading branch information
Rogier-5 authored and paramat committed Dec 12, 2016
1 parent 38abc91 commit 02112f8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
3 changes: 1 addition & 2 deletions builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions minetest.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@
# 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.
Expand Down
3 changes: 2 additions & 1 deletion src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 16 additions & 6 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 02112f8

Please sign in to comment.