summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorAnand S <ClobberXD@gmail.com>2018-07-15 05:56:30 +0530
committersfan5 <sfan5@live.de>2019-09-19 20:14:16 +0200
commit47da640d7763ee1e00badb7476ac5afc4f864367 (patch)
treed12bee2e2cfc1b1c4a4a51e318d692b11ee5fbaf /src/client
parent5c9983400fb085167bf11f8a0483b8e8f6dd8a24 (diff)
downloadminetest-47da640d7763ee1e00badb7476ac5afc4f864367.tar.gz
minetest-47da640d7763ee1e00badb7476ac5afc4f864367.tar.bz2
minetest-47da640d7763ee1e00badb7476ac5afc4f864367.zip
Add support for per-player FOV overrides and multipliers
Diffstat (limited to 'src/client')
-rw-r--r--src/client/camera.cpp20
-rw-r--r--src/client/client.h1
-rw-r--r--src/client/game.cpp2
3 files changed, 19 insertions, 4 deletions
diff --git a/src/client/camera.cpp b/src/client/camera.cpp
index 025bd081d..d1e76026d 100644
--- a/src/client/camera.cpp
+++ b/src/client/camera.cpp
@@ -448,12 +448,26 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
if (m_camera_mode != CAMERA_MODE_FIRST)
m_camera_position = my_cp;
- // Get FOV
+ /*
+ * Apply server-sent FOV. If server doesn't enforce FOV,
+ * check for zoom and set to zoom FOV.
+ * Otherwise, default to m_cache_fov
+ */
+
f32 fov_degrees;
- // Disable zoom with zoom FOV = 0
- if (player->getPlayerControl().zoom && player->getZoomFOV() > 0.001f) {
+ PlayerFovSpec fov_spec = player->getFov();
+ if (fov_spec.fov > 0.0f) {
+ // If server-sent FOV is a multiplier, multiply
+ // it with m_cache_fov instead of overriding
+ if (fov_spec.is_multiplier)
+ fov_degrees = m_cache_fov * fov_spec.fov;
+ else
+ fov_degrees = fov_spec.fov;
+ } else if (player->getPlayerControl().zoom && player->getZoomFOV() > 0.001f) {
+ // Player requests zoom, apply zoom FOV
fov_degrees = player->getZoomFOV();
} else {
+ // Set to client's selected FOV
fov_degrees = m_cache_fov;
}
fov_degrees = rangelim(fov_degrees, 1.0f, 160.0f);
diff --git a/src/client/client.h b/src/client/client.h
index dee60b6d5..e3c931837 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -193,6 +193,7 @@ public:
void handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt);
void handleCommand_ActiveObjectMessages(NetworkPacket* pkt);
void handleCommand_Movement(NetworkPacket* pkt);
+ void handleCommand_Fov(NetworkPacket *pkt);
void handleCommand_HP(NetworkPacket* pkt);
void handleCommand_Breath(NetworkPacket* pkt);
void handleCommand_MovePlayer(NetworkPacket* pkt);
diff --git a/src/client/game.cpp b/src/client/game.cpp
index ef846fe18..042b61a78 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -2332,7 +2332,7 @@ void Game::toggleFullViewRange()
void Game::checkZoomEnabled()
{
LocalPlayer *player = client->getEnv().getLocalPlayer();
- if (player->getZoomFOV() < 0.001f)
+ if (player->getZoomFOV() < 0.001f || player->getFov().fov > 0.0f)
m_game_ui->showTranslatedStatusText("Zoom currently disabled by game or mod");
}