From c885b6aa351ff26a3dffdaa1ef1a3d4fd9dfdfb4 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Thu, 31 Aug 2017 08:20:25 +0800 Subject: [PATCH] Send player FOV across the network as floatig point. --- src/d_main.cpp | 6 +++--- src/d_net.cpp | 8 ++++---- src/d_protocol.h | 4 ++-- src/p_user.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 5a97637ff..f982cc5fb 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -399,19 +399,19 @@ CUSTOM_CVAR (Int, dmflags, 0, CVAR_SERVERINFO) // If nofov is set, force everybody to the arbitrator's FOV. if ((self & DF_NO_FOV) && consoleplayer == Net_Arbitrator) { - uint8_t fov; + double fov; Net_WriteByte (DEM_FOV); // If the game is started with DF_NO_FOV set, the arbitrator's // DesiredFOV will not be set when this callback is run, so // be sure not to transmit a 0 FOV. - fov = (uint8_t)players[consoleplayer].DesiredFOV; + fov = players[consoleplayer].DesiredFOV; if (fov == 0) { fov = 90; } - Net_WriteByte (fov); + Net_WriteFloat (fov); } } diff --git a/src/d_net.cpp b/src/d_net.cpp index 77a560e60..04269f1d8 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2465,7 +2465,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player) case DEM_FOV: { - float newfov = (float)ReadByte (stream); + float newfov = ReadFloat (stream); if (newfov != players[consoleplayer].DesiredFOV) { @@ -2485,7 +2485,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player) break; case DEM_MYFOV: - players[player].DesiredFOV = (float)ReadByte (stream); + players[player].DesiredFOV = ReadFloat (stream); break; case DEM_RUNSCRIPT: @@ -2775,6 +2775,8 @@ void Net_SkipCommand (int type, uint8_t **stream) break; case DEM_INVUSE: + case DEM_FOV: + case DEM_MYFOV: skip = 4; break; @@ -2784,8 +2786,6 @@ void Net_SkipCommand (int type, uint8_t **stream) case DEM_GENERICCHEAT: case DEM_DROPPLAYER: - case DEM_FOV: - case DEM_MYFOV: case DEM_ADDCONTROLLER: case DEM_DELCONTROLLER: skip = 1; diff --git a/src/d_protocol.h b/src/d_protocol.h index f5bcf10fb..ddae331a6 100644 --- a/src/d_protocol.h +++ b/src/d_protocol.h @@ -116,8 +116,8 @@ enum EDemoCommand DEM_UNDONE5, // 24 DEM_UNDONE6, // 25 DEM_SUMMON, // 26 String: Thing to fabricate - DEM_FOV, // 27 Byte: New FOV for all players - DEM_MYFOV, // 28 Byte: New FOV for this player + DEM_FOV, // 27 Float: New FOV for all players + DEM_MYFOV, // 28 Float: New FOV for this player DEM_CHANGEMAP2, // 29 Byte: Position in new map, String: name of new map DEM_UNDONE7, // 30 DEM_UNDONE8, // 31 diff --git a/src/p_user.cpp b/src/p_user.cpp index f9b9dd4a6..104e7d241 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -614,7 +614,7 @@ void player_t::SetFOV(float fov) { Net_WriteByte(DEM_MYFOV); } - Net_WriteByte((uint8_t)clamp(fov, 5.f, 179.f)); + Net_WriteFloat(clamp(fov, 5.f, 179.f)); } }