aboutsummaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorANAND <ClobberXD@gmail.com>2020-05-02 16:22:11 +0530
committerGitHub <noreply@github.com>2020-05-02 12:52:11 +0200
commite0ea87f1f32273dba2eb5421c2a8c890479ba078 (patch)
treef4a64ef33340f60707f7cbe7b937bc183d0562c3 /src/network
parentac368af4fe27f61f5a4209cdfe90956ff745993c (diff)
downloadminetest-e0ea87f1f32273dba2eb5421c2a8c890479ba078.tar.gz
minetest-e0ea87f1f32273dba2eb5421c2a8c890479ba078.tar.bz2
minetest-e0ea87f1f32273dba2eb5421c2a8c890479ba078.zip
set_fov: Add support for time-based transitions (#9705)
Diffstat (limited to 'src/network')
-rw-r--r--src/network/clientpackethandler.cpp15
-rw-r--r--src/network/networkprotocol.h3
2 files changed, 15 insertions, 3 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index d19dc3818..6428ed752 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/client.h"
#include "util/base64.h"
+#include "client/camera.h"
#include "chatmessage.h"
#include "client/clientmedia.h"
#include "log.h"
@@ -530,11 +531,21 @@ void Client::handleCommand_Movement(NetworkPacket* pkt)
void Client::handleCommand_Fov(NetworkPacket *pkt)
{
f32 fov;
- bool is_multiplier;
+ bool is_multiplier = false;
+ f32 transition_time = 0.0f;
+
*pkt >> fov >> is_multiplier;
+ // Wrap transition_time extraction within a
+ // try-catch to preserve backwards compat
+ try {
+ *pkt >> transition_time;
+ } catch (PacketError &e) {};
+
LocalPlayer *player = m_env.getLocalPlayer();
- player->setFov({ fov, is_multiplier });
+ assert(player);
+ player->setFov({ fov, is_multiplier, transition_time });
+ m_camera->notifyFovChange();
}
void Client::handleCommand_HP(NetworkPacket *pkt)
diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h
index 4b7345b15..73523ea42 100644
--- a/src/network/networkprotocol.h
+++ b/src/network/networkprotocol.h
@@ -384,8 +384,9 @@ enum ToClientCommand
/*
Sends an FOV override/multiplier to client.
- float fov
+ f32 fov
bool is_multiplier
+ f32 transition_time
*/
TOCLIENT_DEATHSCREEN = 0x37,