]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fixed pogostick/doublejump bug when running id1 qc with a client sending input packet...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 7 Mar 2006 10:49:16 +0000 (10:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 7 Mar 2006 10:49:16 +0000 (10:49 +0000)
moved ping time calculation out of SV_ApplyClientMove and back into SV_ReadClientMove

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6076 d7cf8633-e32d-0410-b094-e92efae38249

sv_user.c

index e152d4242b9814a9df30b6f6c136b8bcbb258827..7e8ea45a1019282a1702512f6b4c619f158ad84b 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -607,6 +607,9 @@ qboolean SV_ReadClientMove (void)
        qboolean kickplayer = false;
        int i;
        double oldmovetime;
+#ifdef NUM_PING_TIMES
+       double total;
+#endif
        usercmd_t *move = &host_client->cmd;
 
        oldmovetime = move->time;
@@ -624,6 +627,16 @@ qboolean SV_ReadClientMove (void)
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
        move->receivetime = sv.time;
 
+       // calculate average ping time
+       host_client->ping = move->receivetime - move->time;
+#ifdef NUM_PING_TIMES
+       host_client->ping_times[host_client->num_pings % NUM_PING_TIMES] = move->receivetime - move->time;
+       host_client->num_pings++;
+       for (i=0, total = 0;i < NUM_PING_TIMES;i++)
+               total += host_client->ping_times[i];
+       host_client->ping = total / NUM_PING_TIMES;
+#endif
+
        // read current angles
        for (i = 0;i < 3;i++)
        {
@@ -717,28 +730,19 @@ qboolean SV_ReadClientMove (void)
 
 void SV_ApplyClientMove (void)
 {
-#ifdef NUM_PING_TIMES
-       int i;
-       float total;
-#endif
        prvm_eval_t *val;
        usercmd_t *move = &host_client->cmd;
 
-       if (!move->receivetime || move->applied)
+       if (!move->receivetime)
                return;
 
+       // note: a move can be applied multiple times if the client packets are
+       // not coming as often as the physics is executed, and the move must be
+       // applied before running qc each time because the id1 qc had a bug where
+       // it clears self.button2 in PlayerJump, causing pogostick behavior if
+       // moves are not applied every time before calling qc
        move->applied = true;
 
-       // calculate average ping time
-       host_client->ping = move->receivetime - move->time;
-#ifdef NUM_PING_TIMES
-       host_client->ping_times[host_client->num_pings % NUM_PING_TIMES] = move->receivetime - move->time;
-       host_client->num_pings++;
-       for (i=0, total = 0;i < NUM_PING_TIMES;i++)
-               total += host_client->ping_times[i];
-       host_client->ping = total / NUM_PING_TIMES;
-#endif
-
        // set the edict fields
        host_client->edict->fields.server->button0 = move->buttons & 1;
        host_client->edict->fields.server->button2 = (move->buttons & 2)>>1;