From f6f6c5c8c754f78be1c1f70c1aebf7420012cf89 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Mon, 29 Mar 2021 20:55:12 +0000 Subject: [PATCH] server: Remove unused/broken ping smoothing feature Removes unused ping smoothing feature (didn't actually compile so safe to say nobody is using it). It could cause problems for QC mods that use ping for antilag purposes, and QC can easily average pings if desired. From bones_was_here git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13101 d7cf8633-e32d-0410-b094-e92efae38249 --- protocol.h | 5 ++--- server.h | 8 -------- sv_main.c | 5 ----- sv_user.c | 18 ++++-------------- 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/protocol.h b/protocol.h index 170db5b9..e637ea54 100644 --- a/protocol.h +++ b/protocol.h @@ -388,9 +388,8 @@ typedef struct usercmd_s vec_t cursor_fraction; int cursor_entitynumber; - double time; // time the move is executed for (cl_movement: clienttime, non-cl_movement: receivetime) - double receivetime; // time the move was received at - double clienttime; // time to which server state the move corresponds to + double time; // time the move is executed for (non-cl_movement is executed at receivetime) + double receivetime; // time the move was received at (used for ping) int msec; // for predicted moves int buttons; int impulse; diff --git a/server.h b/server.h index 9a9a6d9b..503d1b14 100644 --- a/server.h +++ b/server.h @@ -179,9 +179,6 @@ typedef struct csqcentityframedb_s int sendflags[NUM_CSQCENTITIES_PER_FRAME]; } csqcentityframedb_t; -// if defined this does ping smoothing, otherwise it does not -//#define NUM_PING_TIMES 16 - #define NUM_SPAWN_PARMS 16 typedef struct client_s @@ -225,11 +222,6 @@ 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 /// LadyHavoc: can be used for prediction or whatever... float ping; diff --git a/sv_main.c b/sv_main.c index 2aa9a987..1a48d15b 100644 --- a/sv_main.c +++ b/sv_main.c @@ -910,11 +910,6 @@ void SV_SendServerinfo (client_t *client) client->movesequence = 0; client->movement_highestsequence_seen = 0; memset(&client->movement_count, 0, sizeof(client->movement_count)); -#ifdef NUM_PING_TIMES - for (i = 0;i < NUM_PING_TIMES;i++) - client->ping_times[i] = 0; - client->num_pings = 0; -#endif client->ping = 0; // allow the client some time to send his keepalives, even if map loading took ages diff --git a/sv_user.c b/sv_user.c index 1e3d581f..f3115088 100644 --- a/sv_user.c +++ b/sv_user.c @@ -654,7 +654,7 @@ static void SV_ReadClientMove (void) // read ping time if (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_NEHAHRABJP && sv.protocol != PROTOCOL_NEHAHRABJP2 && sv.protocol != PROTOCOL_NEHAHRABJP3 && sv.protocol != PROTOCOL_DARKPLACES1 && sv.protocol != PROTOCOL_DARKPLACES2 && sv.protocol != PROTOCOL_DARKPLACES3 && sv.protocol != PROTOCOL_DARKPLACES4 && sv.protocol != PROTOCOL_DARKPLACES5 && sv.protocol != PROTOCOL_DARKPLACES6) move->sequence = MSG_ReadLong(&sv_message); - move->time = move->clienttime = MSG_ReadFloat(&sv_message); + move->time = MSG_ReadFloat(&sv_message); if (sv_message.badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__); move->receivetime = (float)sv.time; @@ -779,9 +779,7 @@ static void SV_ExecuteClientMoves(void) double moveframetime; double oldframetime; double oldframetime2; -#ifdef NUM_PING_TIMES - double total; -#endif + if (sv_numreadmoves < 1) return; // only start accepting input once the player is spawned @@ -886,17 +884,9 @@ static void SV_ExecuteClientMoves(void) host_client->movesequence = 0; // make sure that normal physics takes over immediately host_client->clmovement_inputtimeout = 0; + // update ping time + host_client->ping = host_client->cmd.receivetime - sv_readmoves[sv_numreadmoves-1].time; } - - // calculate average ping time - host_client->ping = host_client->cmd.receivetime - host_client->cmd.clienttime; -#ifdef NUM_PING_TIMES - host_client->ping_times[host_client->num_pings % NUM_PING_TIMES] = host_client->cmd.receivetime - host_client->cmd.clienttime; - 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 } void SV_ApplyClientMove (void) -- 2.39.2