use only the latest ping time, not averaged
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 6 Jun 2005 07:24:26 +0000 (07:24 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 6 Jun 2005 07:24:26 +0000 (07:24 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5405 d7cf8633-e32d-0410-b094-e92efae38249

server.h
sv_user.c

index 606879b..c6ec424 100644 (file)
--- a/server.h
+++ b/server.h
@@ -94,8 +94,9 @@ typedef struct
        qbyte signon_buf[NET_MAXMESSAGE];
 } server_t;
 
+// if defined this does ping smoothing, otherwise it does not
+//#define NUM_PING_TIMES 16
 
-#define NUM_PING_TIMES 16
 #define NUM_SPAWN_PARMS 16
 
 typedef struct client_s
@@ -135,9 +136,11 @@ typedef struct client_s
        // PRVM_EDICT_NUM(clientnum+1)
        prvm_edict_t *edict;
 
+#ifdef NUM_PING_TIMES
        float ping_times[NUM_PING_TIMES];
        // ping_times[num_pings%NUM_PING_TIMES]
        int num_pings;
+#endif
        // LordHavoc: can be used for prediction or whatever...
        float ping;
 
index 37fe574..f251a8b 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -700,17 +700,22 @@ void SV_ReadClientMove (void)
 
 void SV_ApplyClientMove (void)
 {
+#ifdef NUM_PING_TIMES
        int i;
-       prvm_eval_t *val;
        float total;
+#endif
+       prvm_eval_t *val;
        usercmd_t *move = &host_client->cmd;
 
        // 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;