]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
323
[xonotic/darkplaces.git] / common.c
index 587aa08c8169e9070b345fedababb5e78f03fab5..5c72b72f1dcbe51fe3b99574b9317234af0372ec 100644 (file)
--- a/common.c
+++ b/common.c
@@ -193,17 +193,17 @@ void MSG_WriteString (sizebuf_t *sb, const char *s)
 void MSG_WriteCoord13i (sizebuf_t *sb, float f)
 {
        if (f >= 0)
-               MSG_WriteShort (sb, (int)(f * 8.0f + 0.5f));
+               MSG_WriteShort (sb, (int)(f * 8.0 + 0.5));
        else
-               MSG_WriteShort (sb, (int)(f * 8.0f - 0.5f));
+               MSG_WriteShort (sb, (int)(f * 8.0 - 0.5));
 }
 
 void MSG_WriteCoord16i (sizebuf_t *sb, float f)
 {
        if (f >= 0)
-               MSG_WriteShort (sb, (int)(f + 0.5f));
+               MSG_WriteShort (sb, (int)(f + 0.5));
        else
-               MSG_WriteShort (sb, (int)(f - 0.5f));
+               MSG_WriteShort (sb, (int)(f - 0.5));
 }
 
 void MSG_WriteCoord32f (sizebuf_t *sb, float f)
@@ -234,17 +234,17 @@ void MSG_WriteVector (sizebuf_t *sb, float *v, int protocol)
 void MSG_WriteAngle8i (sizebuf_t *sb, float f)
 {
        if (f >= 0)
-               MSG_WriteByte (sb, (int)(f*(256.0f/360.0f) + 0.5f) & 255);
+               MSG_WriteByte (sb, (int)(f*(256.0/360.0) + 0.5) & 255);
        else
-               MSG_WriteByte (sb, (int)(f*(256.0f/360.0f) - 0.5f) & 255);
+               MSG_WriteByte (sb, (int)(f*(256.0/360.0) - 0.5) & 255);
 }
 
 void MSG_WriteAngle16i (sizebuf_t *sb, float f)
 {
        if (f >= 0)
-               MSG_WriteShort (sb, (int)(f*(65536.0f/360.0f) + 0.5f) & 65535);
+               MSG_WriteShort (sb, (int)(f*(65536.0/360.0) + 0.5) & 65535);
        else
-               MSG_WriteShort (sb, (int)(f*(65536.0f/360.0f) - 0.5f) & 65535);
+               MSG_WriteShort (sb, (int)(f*(65536.0/360.0) - 0.5) & 65535);
 }
 
 void MSG_WriteAngle32f (sizebuf_t *sb, float f)
@@ -252,6 +252,13 @@ void MSG_WriteAngle32f (sizebuf_t *sb, float f)
        MSG_WriteFloat (sb, f);
 }
 
+void MSG_WriteAngle (sizebuf_t *sb, float f, int protocol)
+{
+       if (protocol == PROTOCOL_DARKPLACES5)
+               MSG_WriteAngle16i (sb, f);
+       else
+               MSG_WriteAngle8i (sb, f);
+}
 
 //
 // reading functions
@@ -363,7 +370,7 @@ int MSG_ReadBytes (int numbytes, unsigned char *out)
 
 float MSG_ReadCoord13i (void)
 {
-       return MSG_ReadLittleShort() * (1.0f/8.0f);
+       return MSG_ReadLittleShort() * (1.0/8.0);
 }
 
 float MSG_ReadCoord16i (void)
@@ -398,12 +405,12 @@ void MSG_ReadVector (float *v, int protocol)
 // LordHavoc: round to nearest value, rather than rounding toward zero, fixes crosshair problem
 float MSG_ReadAngle8i (void)
 {
-       return MSG_ReadByte () * (360.0f/256.0f);
+       return MSG_ReadByte () * (360.0/256.0);
 }
 
 float MSG_ReadAngle16i (void)
 {
-       return MSG_ReadShort () * (360.0f/65536.0f);
+       return (unsigned short)MSG_ReadShort () * (360.0/65536.0);
 }
 
 float MSG_ReadAngle32f (void)
@@ -411,6 +418,14 @@ float MSG_ReadAngle32f (void)
        return MSG_ReadFloat ();
 }
 
+float MSG_ReadAngle (int protocol)
+{
+       if (protocol == PROTOCOL_DARKPLACES5)
+               return MSG_ReadAngle16i ();
+       else
+               return MSG_ReadAngle8i ();
+}
+
 
 //===========================================================================
 
@@ -504,7 +519,7 @@ void Com_HexDumpToConsole(const qbyte *data, int size)
                                *cur++ = ' ';
                                *cur++ = ' ';
                        }
-                       if ((j & 3) == 0)
+                       if ((j & 3) == 3)
                                *cur++ = ' ';
                }
                // print text