]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
improved server handling of multiple packets per client physics frame (as would be...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 15 Feb 2006 03:09:37 +0000 (03:09 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 15 Feb 2006 03:09:37 +0000 (03:09 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5984 d7cf8633-e32d-0410-b094-e92efae38249

sv_phys.c
sv_user.c

index d37dbbbf7514a94778c455964746ad7e3c39a9c9..3f91ff3ebec94cefbd580e810fb1b419b9daa163 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -1413,8 +1413,10 @@ static void SV_Physics_Entity (prvm_edict_t *ent, qboolean runmove)
        }
 }
 
        }
 }
 
+void SV_ApplyClientMove (void);
 void SV_Physics_ClientEntity (prvm_edict_t *ent)
 {
 void SV_Physics_ClientEntity (prvm_edict_t *ent)
 {
+       SV_ApplyClientMove();
        // make sure the velocity is sane (not a NaN)
        SV_CheckVelocity(ent);
        // LordHavoc: QuakeC replacement for SV_ClientThink (player movement)
        // make sure the velocity is sane (not a NaN)
        SV_CheckVelocity(ent);
        // LordHavoc: QuakeC replacement for SV_ClientThink (player movement)
index 77fc45dab8ea0ab833531c732d053dbfc20d5500..2525785abb91d432e9f601a18e815d85fd633e60 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -602,7 +602,6 @@ void SV_ClientThink(void)
 SV_ReadClientMove
 ===================
 */
 SV_ReadClientMove
 ===================
 */
-void SV_ApplyClientMove (void);
 void SV_ReadClientMove (void)
 {
        int i;
 void SV_ReadClientMove (void)
 {
        int i;
@@ -610,7 +609,6 @@ void SV_ReadClientMove (void)
        usercmd_t *move = &host_client->cmd;
 
        oldmovetime = move->time;
        usercmd_t *move = &host_client->cmd;
 
        oldmovetime = move->time;
-       memset(move, 0, sizeof(usercmd_t));
 
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
 
 
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
 
@@ -642,10 +640,12 @@ void SV_ReadClientMove (void)
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
 
        // read buttons
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
 
        // read buttons
+       // be sure to bitwise OR them into the move->buttons because we want to
+       // accumulate button presses from multiple packets per actual move
        if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5)
        if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5)
-               move->buttons = MSG_ReadByte ();
+               move->buttons |= MSG_ReadByte ();
        else
        else
-               move->buttons = MSG_ReadLong ();
+               move->buttons |= MSG_ReadLong ();
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
 
        // read impulse
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
 
        // read impulse
@@ -682,7 +682,6 @@ void SV_ReadClientMove (void)
        else
        {
                // apply the latest accepted move to the entity fields
        else
        {
                // apply the latest accepted move to the entity fields
-               SV_ApplyClientMove();
                host_client->movesequence = move->sequence;
                if (host_client->movesequence)
                {
                host_client->movesequence = move->sequence;
                if (host_client->movesequence)
                {
@@ -706,6 +705,9 @@ void SV_ApplyClientMove (void)
        prvm_eval_t *val;
        usercmd_t *move = &host_client->cmd;
 
        prvm_eval_t *val;
        usercmd_t *move = &host_client->cmd;
 
+       if (!move->receivetime)
+               return;
+
        // calculate average ping time
        host_client->ping = move->receivetime - move->time;
 #ifdef NUM_PING_TIMES
        // calculate average ping time
        host_client->ping = move->receivetime - move->time;
 #ifdef NUM_PING_TIMES
@@ -745,6 +747,8 @@ void SV_ApplyClientMove (void)
        if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_endpos))) VectorCopy(move->cursor_impact, val->vector);
        if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_ent))) val->edict = PRVM_EDICT_TO_PROG(PRVM_EDICT_NUM(move->cursor_entitynumber));
        if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ping))) val->_float = host_client->ping * 1000.0;
        if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_endpos))) VectorCopy(move->cursor_impact, val->vector);
        if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_ent))) val->edict = PRVM_EDICT_TO_PROG(PRVM_EDICT_NUM(move->cursor_entitynumber));
        if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ping))) val->_float = host_client->ping * 1000.0;
+
+       memset(move, 0, sizeof(*move));
 }
 
 void SV_FrameLost(int framenum)
 }
 
 void SV_FrameLost(int framenum)