aboutsummaryrefslogtreecommitdiff
path: root/src/network/serverpackethandler.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/network/serverpackethandler.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/network/serverpackethandler.cpp')
-rw-r--r--src/network/serverpackethandler.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index 70eb0a828..5e50bb865 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -782,6 +782,7 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
v3s32 ps, ss;
s32 f32pitch, f32yaw;
+ u8 f32fov;
*pkt >> ps;
*pkt >> ss;
@@ -792,8 +793,18 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
f32 yaw = (f32)f32yaw / 100.0;
u32 keyPressed = 0;
+ // default behavior (in case an old client doesn't send these)
+ f32 fov = (72.0*M_PI/180) * 4./3.;
+ u8 wanted_range = 0;
+
if (pkt->getRemainingBytes() >= 4)
*pkt >> keyPressed;
+ if (pkt->getRemainingBytes() >= 1) {
+ *pkt >> f32fov;
+ fov = (f32)f32fov / 80.0;
+ }
+ if (pkt->getRemainingBytes() >= 1)
+ *pkt >> wanted_range;
v3f position((f32)ps.X / 100.0, (f32)ps.Y / 100.0, (f32)ps.Z / 100.0);
v3f speed((f32)ss.X / 100.0, (f32)ss.Y / 100.0, (f32)ss.Z / 100.0);
@@ -805,6 +816,8 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
player->setSpeed(speed);
playersao->setPitch(pitch);
playersao->setYaw(yaw);
+ playersao->setFov(fov);
+ playersao->setWantedRange(wanted_range);
player->keyPressed = keyPressed;
player->control.up = (keyPressed & 1);
player->control.down = (keyPressed & 2);