X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=com_msg.c;h=0c4542bb467772bb4fce7950b0474f4495af6667;hb=1b92049622062956a04f1766f66f072350773acb;hp=a39dcac5037d89f3b5d643ce2f0c54d2c371934f;hpb=1e7db685dd4b29600b9cde43536c82673322f35b;p=xonotic%2Fdarkplaces.git diff --git a/com_msg.c b/com_msg.c index a39dcac5..0c4542bb 100644 --- a/com_msg.c +++ b/com_msg.c @@ -182,18 +182,12 @@ void MSG_WriteUnterminatedString (sizebuf_t *sb, const char *s) void MSG_WriteCoord13i (sizebuf_t *sb, float f) { - if (f >= 0) - MSG_WriteShort (sb, (int)(f * 8.0 + 0.5)); - else - MSG_WriteShort (sb, (int)(f * 8.0 - 0.5)); + MSG_WriteShort (sb, Q_rint(f*8)); } void MSG_WriteCoord16i (sizebuf_t *sb, float f) { - if (f >= 0) - MSG_WriteShort (sb, (int)(f + 0.5)); - else - MSG_WriteShort (sb, (int)(f - 0.5)); + MSG_WriteShort (sb, Q_rint(f)); } void MSG_WriteCoord32f (sizebuf_t *sb, float f) @@ -223,18 +217,12 @@ void MSG_WriteVector (sizebuf_t *sb, const vec3_t v, protocolversion_t protocol) // LadyHavoc: round to nearest value, rather than rounding toward zero, fixes crosshair problem void MSG_WriteAngle8i (sizebuf_t *sb, float f) { - if (f >= 0) - MSG_WriteByte (sb, (int)(f*(256.0/360.0) + 0.5) & 255); - else - MSG_WriteByte (sb, (int)(f*(256.0/360.0) - 0.5) & 255); + MSG_WriteByte (sb, (int)Q_rint(f*(256.0/360.0)) & 255); } void MSG_WriteAngle16i (sizebuf_t *sb, float f) { - if (f >= 0) - MSG_WriteShort (sb, (int)(f*(65536.0/360.0) + 0.5) & 65535); - else - MSG_WriteShort (sb, (int)(f*(65536.0/360.0) - 0.5) & 65535); + MSG_WriteShort (sb, (int)Q_rint(f*(65536.0/360.0)) & 65535); } void MSG_WriteAngle32f (sizebuf_t *sb, float f) @@ -422,4 +410,4 @@ float MSG_ReadAngle (sizebuf_t *sb, protocolversion_t protocol) return MSG_ReadAngle8i (sb); else return MSG_ReadAngle16i (sb); -} \ No newline at end of file +}