]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
Fixed some of the mess. Might work now...
[xonotic/darkplaces.git] / common.c
index 2c9c8cc11c07c6d42eba517bb339d6b651abeaca..e31b48d7605b8d089bd2c87dc3d472e9806ce31f 100644 (file)
--- a/common.c
+++ b/common.c
@@ -588,17 +588,18 @@ void MSG_WriteCoord (sizebuf_t *sb, float f)
        if (dpprotocol)
                MSG_WriteFloat(sb, f);
        else
-               MSG_WriteShort (sb, (int)(f*8));
+               MSG_WriteShort (sb, (int)(f*8.0f + 0.5f));
 }
 
 void MSG_WritePreciseAngle (sizebuf_t *sb, float f)
 {
-       MSG_WriteShort (sb, (int) (f*65536.0f/360) & 65535);
+       MSG_WriteShort (sb, (int)(f*(65536.0f/360.0f) + 0.5f) & 65535);
 }
 
+// LordHavoc: round to nearest value, rather than rounding down, fixes crosshair problem
 void MSG_WriteAngle (sizebuf_t *sb, float f)
 {
-       MSG_WriteByte (sb, ((int)f*256/360) & 255);
+       MSG_WriteByte (sb, (int)(f*(256.0f/360.0f) + 0.5f) & 255);
 }
 
 //