summaryrefslogtreecommitdiff
path: root/src/clientiface.cpp
diff options
context:
space:
mode:
authorlhofhansl <lhofhansl@yahoo.com>2016-11-30 00:13:14 -0800
committerZeno- <kde.psych@gmail.com>2016-11-30 18:13:14 +1000
commit5dc61988788e44bc87e8c57c0beded97d4efdf05 (patch)
treecc812fe691ba6ad62dbe65745d89c86cd974e817 /src/clientiface.cpp
parentc38985825f299999135cc01aaf0052ec9138135a (diff)
downloadminetest-5dc61988788e44bc87e8c57c0beded97d4efdf05.tar.gz
minetest-5dc61988788e44bc87e8c57c0beded97d4efdf05.tar.bz2
minetest-5dc61988788e44bc87e8c57c0beded97d4efdf05.zip
Optimize/adjust blocks/ActiveObjects sent at the server based on client settings. (#4811)
Optimize/adjust blocks and active blocks sent at the server based on client settings.
Diffstat (limited to 'src/clientiface.cpp')
-rw-r--r--src/clientiface.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/clientiface.cpp b/src/clientiface.cpp
index bdc16f31c..abe878ecc 100644
--- a/src/clientiface.cpp
+++ b/src/clientiface.cpp
@@ -173,12 +173,20 @@ void RemoteClient::GetNextBlocks (
*/
s32 new_nearest_unsent_d = -1;
- const s16 full_d_max = g_settings->getS16("max_block_send_distance");
- const s16 d_opt = g_settings->getS16("block_send_optimize_distance");
+ // get view range and camera fov from the client
+ s16 wanted_range = sao->getWantedRange();
+ float camera_fov = sao->getFov();
+ // if FOV, wanted_range are not available (old client), fall back to old default
+ if (wanted_range <= 0) wanted_range = 1000;
+ if (camera_fov <= 0) camera_fov = (72.0*M_PI/180) * 4./3.;
+
+ const s16 full_d_max = MYMIN(g_settings->getS16("max_block_send_distance"), wanted_range);
+ const s16 d_opt = MYMIN(g_settings->getS16("block_send_optimize_distance"), wanted_range);
const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE;
+ //infostream << "Fov from client " << camera_fov << " full_d_max " << full_d_max << std::endl;
s16 d_max = full_d_max;
- s16 d_max_gen = g_settings->getS16("max_block_generate_distance");
+ s16 d_max_gen = MYMIN(g_settings->getS16("max_block_generate_distance"), wanted_range);
// Don't loop very much at a time
s16 max_d_increment_at_time = 2;
@@ -242,7 +250,6 @@ void RemoteClient::GetNextBlocks (
FOV setting. The default of 72 degrees is fine.
*/
- float camera_fov = (72.0*M_PI/180) * 4./3.;
if(isBlockInSight(p, camera_pos, camera_dir, camera_fov, d_blocks_in_sight) == false)
{
continue;