X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=com_msg.c;h=f2110d17f05fefcafb6a9d5901c86d7e9d23fe3f;hb=e4147673fc518d5d80fdb8b16fb736712600fc50;hp=0de4fc677032e548d7da4969da6138edc069156c;hpb=7d917e0a7817da5998432cf9b7e779a623ef1bb3;p=xonotic%2Fdarkplaces.git diff --git a/com_msg.c b/com_msg.c index 0de4fc67..f2110d17 100644 --- a/com_msg.c +++ b/com_msg.c @@ -1,5 +1,6 @@ /* Copyright (C) 1996-1997 Id Software, Inc. +Copyright (C) 2000-2020 DarkPlaces contributors This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -182,18 +183,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 +218,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)