From 919fbb05eeafd41c867b1f39bb2cc9e5dd61077e Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 6 Jun 2005 07:24:26 +0000 Subject: [PATCH] use only the latest ping time, not averaged git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5405 d7cf8633-e32d-0410-b094-e92efae38249 --- server.h | 5 ++++- sv_user.c | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server.h b/server.h index 606879b9..c6ec424e 100644 --- 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; diff --git a/sv_user.c b/sv_user.c index 37fe5741..f251a8bc 100644 --- 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; -- 2.39.2