]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
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 606879b9bc14638084409f86da4ef33cefcaf36f..c6ec424e14f83f91376b5f9d6c971aca8926180d 100644 (file)
--- a/server.h
+++ b/server.h
@@ -94,8 +94,9 @@ typedef struct
        qbyte signon_buf[NET_MAXMESSAGE];
 } server_t;
 
        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
 #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;
 
        // 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;
        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;
 
        // LordHavoc: can be used for prediction or whatever...
        float ping;
 
index 37fe57417d88e4d27b4421e0bfb80f17aa0c1338..f251a8bc0c4db2c7ac019596679eccb98a69fb92 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -700,17 +700,22 @@ void SV_ReadClientMove (void)
 
 void SV_ApplyClientMove (void)
 {
 
 void SV_ApplyClientMove (void)
 {
+#ifdef NUM_PING_TIMES
        int i;
        int i;
-       prvm_eval_t *val;
        float total;
        float total;
+#endif
+       prvm_eval_t *val;
        usercmd_t *move = &host_client->cmd;
 
        // calculate average ping time
        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;
        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;
 
        // set the edict fields
        host_client->edict->fields.server->button0 = move->buttons & 1;