From: lordhavoc Date: Thu, 26 Oct 2000 11:54:41 +0000 (+0000) Subject: changes to dpprotocol code (precise aiming mainly) X-Git-Tag: RELEASE_0_2_0_RC1~957 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9f880106429414ac1dd6024c83c49f5d2d49641c;p=xonotic%2Fdarkplaces.git changes to dpprotocol code (precise aiming mainly) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@63 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_input.c b/cl_input.c index bc6cbb1a..f3432d22 100644 --- a/cl_input.c +++ b/cl_input.c @@ -382,8 +382,16 @@ void CL_SendMove (usercmd_t *cmd) MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times - for (i=0 ; i<3 ; i++) - MSG_WriteAngle (&buf, cl.viewangles[i]); + if (dpprotocol) + { + for (i=0 ; i<3 ; i++) + MSG_WritePreciseAngle (&buf, cl.viewangles[i]); + } + else + { + for (i=0 ; i<3 ; i++) + MSG_WriteAngle (&buf, cl.viewangles[i]); + } MSG_WriteShort (&buf, forwardmove); MSG_WriteShort (&buf, sidemove); diff --git a/common.c b/common.c index 27fd8bf8..2c9c8cc1 100644 --- a/common.c +++ b/common.c @@ -583,44 +583,10 @@ void MSG_WriteString (sizebuf_t *sb, char *s) SZ_Write (sb, s, strlen(s)+1); } -/* -void MSG_WriteCoord (sizebuf_t *sb, float f) -{ - if (dpprotocol) - { - byte *buf; - int c = (int)f; - buf = SZ_GetSpace (sb, 3); - buf[0] = c & 0xff; - buf[1] = (c >> 8) & 0xff; - buf[2] = (c >> 16) & 0xff; - } - else - MSG_WriteShort (sb, (int)(f*8)); -} -*/ - void MSG_WriteCoord (sizebuf_t *sb, float f) { if (dpprotocol) MSG_WriteFloat(sb, f); - /* - { - int i = (int) (f * 16.0f), j = 0, k, l; - // 1 sign bit, 5bit exponent, 10bit mantissa with implicit 1 - if (i < 0) - { - i = -i; - j = 0x8000; - } - - // LordHavoc: lets hope the compiler is good, if not it will still perform tolerably - for (k = 31,l = 0x80000000;!(i & l);k--,l >>= 1); - j |= k << 10 | ((i >> (k - 10)) & 0x3FF); - - MSG_WriteShort(sb, j); - } - */ else MSG_WriteShort (sb, (int)(f*8)); } @@ -764,93 +730,12 @@ char *MSG_ReadString (void) return string; } -/* -float MSG_ReadAbsoluteCoord (void) -{ - if (dpprotocol) - { - int c; - - if (msg_readcount+3 > net_message.cursize) - { - msg_badread = true; - return 0; - } - - c = net_message.data[msg_readcount ]; - c |= net_message.data[msg_readcount+1] << 8; - c |= net_message.data[msg_readcount+2] << 16; - if (c & 0x800000) - c |= ~0xFFFFFF; // sign extend - - msg_readcount += 3; - - return (float) c * (1.0f / 16.0f); - } - else - { - int c; - - if (msg_readcount+2 > net_message.cursize) - { - msg_badread = true; - return 0; - } - - c = (short) (net_message.data[msg_readcount ] |= net_message.data[msg_readcount+1] << 8); - - msg_readcount += 2; - - return (float) c * (1.0f / 8.0f); -// return MSG_ReadShort() * (1.0f/8.0f); - } -} -*/ - float MSG_ReadCoord (void) { if (dpprotocol) return MSG_ReadFloat(); - /* - { - int c, i; - - if (msg_readcount+2 > net_message.cursize) - { - msg_badread = true; - return 0; - } - - c = net_message.data[msg_readcount ] |= net_message.data[msg_readcount+1] << 8; - - msg_readcount += 2; - - if (!c) - return 0.0f; - // 1 sign bit, 5bit exponent, 10bit mantissa with implicit 1 - i = ((c & 0x03FF) | (0x0400)) << (((c & 0x7C00) >> 10) - 10); - if (c & 0x8000) - i = -i; - return i * (1.0f / 16.0f); - } - */ else - { - int c; - - if (msg_readcount+2 > net_message.cursize) - { - msg_badread = true; - return 0; - } - - c = (short) (net_message.data[msg_readcount ] | (net_message.data[msg_readcount+1] << 8)); - - msg_readcount += 2; - - return ((float) c * (1.0f / 8.0f)); -// return MSG_ReadShort() * (1.0f/8.0f); - } + return MSG_ReadShort() * (1.0f/8.0f); } /* @@ -863,12 +748,12 @@ float MSG_ReadAngle (void) { return MSG_ReadChar() * (360.0f/256.0f); } -*/ float MSG_ReadPreciseAngle (void) { return MSG_ReadShort() * (360.0f/65536); } +*/ //=========================================================================== diff --git a/common.h b/common.h index 8f171931..152112cb 100644 --- a/common.h +++ b/common.h @@ -113,6 +113,7 @@ void MSG_WriteFloat (sizebuf_t *sb, float f); void MSG_WriteString (sizebuf_t *sb, char *s); void MSG_WriteCoord (sizebuf_t *sb, float f); void MSG_WriteAngle (sizebuf_t *sb, float f); +void MSG_WritePreciseAngle (sizebuf_t *sb, float f); extern int msg_readcount; extern qboolean msg_badread; // set if a read goes beyond end of message @@ -133,7 +134,8 @@ char *MSG_ReadString (void); float MSG_ReadCoord (void); //float MSG_ReadAngle (void); -#define MSG_ReadAngle() (dpprotocol ? MSG_ReadShort() * (360.0f / 65536.0f) : MSG_ReadByte() * (360.0f / 256.0f)) +#define MSG_ReadAngle() (MSG_ReadByte() * (360.0f / 256.0f)) +#define MSG_ReadPreciseAngle() (MSG_ReadShort() * (360.0f / 65536.0f)) extern qboolean dpprotocol; diff --git a/sv_user.c b/sv_user.c index 7b286dd2..12ef6157 100644 --- a/sv_user.c +++ b/sv_user.c @@ -459,13 +459,22 @@ void SV_ReadClientMove (usercmd_t *move) for (i=0, total = 0;i < NUM_PING_TIMES;i++) total += host_client->ping_times[i]; host_client->ping = total / NUM_PING_TIMES; // can be used for prediction - host_client->latency = host_client->ping + sv_frametime; // push ahead by ticrate + if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) ) // if paused for any reason, don't predict + host_client->latency = host_client->ping + sv_frametime; // push ahead by ticrate if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_ping))) val->_float = host_client->ping * 1000.0; -// read current angles - for (i=0 ; i<3 ; i++) - angle[i] = MSG_ReadAngle (); +// read current angles + if (dpprotocol) + { + for (i=0 ; i<3 ; i++) + angle[i] = MSG_ReadPreciseAngle (); + } + else + { + for (i=0 ; i<3 ; i++) + angle[i] = MSG_ReadAngle (); + } VectorCopy (angle, host_client->edict->v.v_angle);