Send player FOV across the network as floatig point.

This commit is contained in:
nashmuhandes 2017-08-31 08:20:25 +08:00 committed by Christoph Oelckers
parent 2a291165ee
commit c885b6aa35
4 changed files with 10 additions and 10 deletions

View file

@ -399,19 +399,19 @@ CUSTOM_CVAR (Int, dmflags, 0, CVAR_SERVERINFO)
// If nofov is set, force everybody to the arbitrator's FOV. // If nofov is set, force everybody to the arbitrator's FOV.
if ((self & DF_NO_FOV) && consoleplayer == Net_Arbitrator) if ((self & DF_NO_FOV) && consoleplayer == Net_Arbitrator)
{ {
uint8_t fov; double fov;
Net_WriteByte (DEM_FOV); Net_WriteByte (DEM_FOV);
// If the game is started with DF_NO_FOV set, the arbitrator's // If the game is started with DF_NO_FOV set, the arbitrator's
// DesiredFOV will not be set when this callback is run, so // DesiredFOV will not be set when this callback is run, so
// be sure not to transmit a 0 FOV. // be sure not to transmit a 0 FOV.
fov = (uint8_t)players[consoleplayer].DesiredFOV; fov = players[consoleplayer].DesiredFOV;
if (fov == 0) if (fov == 0)
{ {
fov = 90; fov = 90;
} }
Net_WriteByte (fov); Net_WriteFloat (fov);
} }
} }

View file

@ -2465,7 +2465,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_FOV: case DEM_FOV:
{ {
float newfov = (float)ReadByte (stream); float newfov = ReadFloat (stream);
if (newfov != players[consoleplayer].DesiredFOV) if (newfov != players[consoleplayer].DesiredFOV)
{ {
@ -2485,7 +2485,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
break; break;
case DEM_MYFOV: case DEM_MYFOV:
players[player].DesiredFOV = (float)ReadByte (stream); players[player].DesiredFOV = ReadFloat (stream);
break; break;
case DEM_RUNSCRIPT: case DEM_RUNSCRIPT:
@ -2775,6 +2775,8 @@ void Net_SkipCommand (int type, uint8_t **stream)
break; break;
case DEM_INVUSE: case DEM_INVUSE:
case DEM_FOV:
case DEM_MYFOV:
skip = 4; skip = 4;
break; break;
@ -2784,8 +2786,6 @@ void Net_SkipCommand (int type, uint8_t **stream)
case DEM_GENERICCHEAT: case DEM_GENERICCHEAT:
case DEM_DROPPLAYER: case DEM_DROPPLAYER:
case DEM_FOV:
case DEM_MYFOV:
case DEM_ADDCONTROLLER: case DEM_ADDCONTROLLER:
case DEM_DELCONTROLLER: case DEM_DELCONTROLLER:
skip = 1; skip = 1;

View file

@ -116,8 +116,8 @@ enum EDemoCommand
DEM_UNDONE5, // 24 DEM_UNDONE5, // 24
DEM_UNDONE6, // 25 DEM_UNDONE6, // 25
DEM_SUMMON, // 26 String: Thing to fabricate DEM_SUMMON, // 26 String: Thing to fabricate
DEM_FOV, // 27 Byte: New FOV for all players DEM_FOV, // 27 Float: New FOV for all players
DEM_MYFOV, // 28 Byte: New FOV for this player DEM_MYFOV, // 28 Float: New FOV for this player
DEM_CHANGEMAP2, // 29 Byte: Position in new map, String: name of new map DEM_CHANGEMAP2, // 29 Byte: Position in new map, String: name of new map
DEM_UNDONE7, // 30 DEM_UNDONE7, // 30
DEM_UNDONE8, // 31 DEM_UNDONE8, // 31

View file

@ -614,7 +614,7 @@ void player_t::SetFOV(float fov)
{ {
Net_WriteByte(DEM_MYFOV); Net_WriteByte(DEM_MYFOV);
} }
Net_WriteByte((uint8_t)clamp<float>(fov, 5.f, 179.f)); Net_WriteFloat(clamp<float>(fov, 5.f, 179.f));
} }
} }