From 7c6557af06758ed14c371f025635123e88321bd9 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 19 Feb 2007 23:17:21 +0000 Subject: [PATCH] moved cl.movesequence/cl.servermovesequence to cls. struct, this keeps the movesequence from level to level and fixes level change problems on old servers git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6872 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_input.c | 16 ++++++++-------- client.h | 6 ++++-- csprogs.c | 4 ++-- netconn.c | 3 +++ protocol.c | 2 +- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cl_input.c b/cl_input.c index 0fc37a56..9cf08ead 100644 --- a/cl_input.c +++ b/cl_input.c @@ -607,11 +607,11 @@ void CL_ClientMovement_Input(qboolean buttonjump, qboolean buttoncrouch) // remove stale queue items n = cl.movement_numqueue; cl.movement_numqueue = 0; - if (cl.servermovesequence) + if (cls.servermovesequence) { for (i = 0;i < n;i++) { - if (cl.movement_queue[i].sequence > cl.servermovesequence) + if (cl.movement_queue[i].sequence > cls.servermovesequence) cl.movement_queue[cl.movement_numqueue++] = cl.movement_queue[i]; else if (i == 0) cl.movement_replay_canjump = !cl.movement_queue[i].jump; // FIXME: this logic is quite broken @@ -631,7 +631,7 @@ void CL_ClientMovement_Input(qboolean buttonjump, qboolean buttoncrouch) if (cl.movement_numqueue < (int)(sizeof(cl.movement_queue)/sizeof(cl.movement_queue[0]))) { // add to input queue - cl.movement_queue[cl.movement_numqueue].sequence = cl.movesequence; + cl.movement_queue[cl.movement_numqueue].sequence = cls.movesequence; cl.movement_queue[cl.movement_numqueue].time = cl.movecmd[0].time; cl.movement_queue[cl.movement_numqueue].frametime = bound(0, cl.movecmd[0].time - cl.movecmd[1].time, 0.1); VectorCopy(cl.viewangles, cl.movement_queue[cl.movement_numqueue].viewangles); @@ -1147,7 +1147,7 @@ void CL_ClientMovement_Replay(void) s.movevars_airaccel_sideways_friction = cl_movement_airaccel_sideways_friction.value; } - cl.movement_predicted = (cl_movement.integer && !cls.demoplayback && cls.signon == SIGNONS && cl.stats[STAT_HEALTH] > 0 && !cl.intermission) && ((cls.protocol != PROTOCOL_DARKPLACES6 && cls.protocol != PROTOCOL_DARKPLACES7) || cl.servermovesequence); + cl.movement_predicted = (cl_movement.integer && !cls.demoplayback && cls.signon == SIGNONS && cl.stats[STAT_HEALTH] > 0 && !cl.intermission) && ((cls.protocol != PROTOCOL_DARKPLACES6 && cls.protocol != PROTOCOL_DARKPLACES7) || cls.servermovesequence); if (cl.movement_predicted) { //Con_Printf("%f: ", cl.movecmd[0].time); @@ -1374,9 +1374,9 @@ void CL_SendMove(void) cl.cmd.msec = 100; oldmsectime = msectime; - cl.movesequence++; + cls.movesequence++; if (cl_movement.integer) - cl.cmd.sequence = cl.movesequence; + cl.cmd.sequence = cls.movesequence; else cl.cmd.sequence = 0; @@ -1384,7 +1384,7 @@ void CL_SendMove(void) CL_UpdatePrydonCursor(); // always dump the first two messages, because they may contain leftover inputs from the last level - if (cl.movesequence > 2) + if (cls.movesequence > 2) { // update the cl.movecmd array which holds the most recent moves for (i = CL_MAX_USERCMDS - 1;i >= 1;i--) @@ -1507,7 +1507,7 @@ void CL_SendMove(void) for (j = 0, cmd = &cl.movecmd[maxusercmds-1];j < maxusercmds;j++, cmd--) { // don't repeat any stale moves - if (cmd->sequence && cmd->sequence < cl.servermovesequence) + if (cmd->sequence && cmd->sequence < cls.servermovesequence) continue; // 5/9 bytes MSG_WriteByte (&buf, clc_move); diff --git a/client.h b/client.h index f53943dc..60d605db 100644 --- a/client.h +++ b/client.h @@ -509,6 +509,10 @@ typedef struct client_static_s // (note: qw_download variables are also used) cl_downloadack_t dp_downloadack[CL_MAX_DOWNLOADACKS]; + // input sequence numbers are not reset on level change, only connect + int movesequence; + int servermovesequence; + // quakeworld stuff below // value of "qport" cvar at time of connection @@ -709,8 +713,6 @@ typedef struct client_state_s // queue of proposed moves int movement_numqueue; client_movementqueue_t movement_queue[256]; - int movesequence; - int servermovesequence; // whether the replay should allow a jump at the first sequence qboolean movement_replay_canjump; diff --git a/csprogs.c b/csprogs.c index 1268888d..661f2383 100644 --- a/csprogs.c +++ b/csprogs.c @@ -66,8 +66,8 @@ static void CSQC_SetGlobals (void) prog->globals.client->time = cl.time; prog->globals.client->frametime = cl.time - csqc_frametime; csqc_frametime = cl.time; - prog->globals.client->servercommandframe = cl.servermovesequence; - prog->globals.client->clientcommandframe = cl.movesequence; + prog->globals.client->servercommandframe = cls.servermovesequence; + prog->globals.client->clientcommandframe = cls.movesequence; VectorCopy(cl.viewangles, prog->globals.client->input_angles); VectorCopy(cl.viewangles, csqc_angles); prog->globals.client->input_buttons = cl.cmd.buttons; diff --git a/netconn.c b/netconn.c index eec93bcc..180c78e3 100755 --- a/netconn.c +++ b/netconn.c @@ -1092,6 +1092,9 @@ void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_t *peer cls.state = ca_connected; cls.signon = 0; // need all the signon messages before playing cls.protocol = initialprotocol; + // reset move sequence numbering on this new connection + cls.movesequence = 0; + cls.servermovesequence = 0; if (cls.protocol == PROTOCOL_QUAKEWORLD) Cmd_ForwardStringToServer("new"); if (cls.protocol == PROTOCOL_QUAKE) diff --git a/protocol.c b/protocol.c index cfa837bf..6e62bddb 100644 --- a/protocol.c +++ b/protocol.c @@ -2038,7 +2038,7 @@ void EntityFrame5_CL_ReadFrame(void) if (developer_networkentities.integer) Con_Printf("recv: svc_entities %i\n", cl.latestframenums[LATESTFRAMENUMS-1]); if (cls.protocol != PROTOCOL_QUAKE && cls.protocol != PROTOCOL_QUAKEDP && cls.protocol != PROTOCOL_NEHAHRAMOVIE && cls.protocol != PROTOCOL_DARKPLACES1 && cls.protocol != PROTOCOL_DARKPLACES2 && cls.protocol != PROTOCOL_DARKPLACES3 && cls.protocol != PROTOCOL_DARKPLACES4 && cls.protocol != PROTOCOL_DARKPLACES5 && cls.protocol != PROTOCOL_DARKPLACES6) - cl.servermovesequence = MSG_ReadLong(); + cls.servermovesequence = MSG_ReadLong(); // read entity numbers until we find a 0x8000 // (which would be remove world entity, but is actually a terminator) while ((n = (unsigned short)MSG_ReadShort()) != 0x8000 && !msg_badread) -- 2.39.2