]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Small networking cleanup
authorbones_was_here <bones_was_here@xa.org.au>
Mon, 22 Mar 2021 16:57:27 +0000 (02:57 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Sun, 28 Mar 2021 11:15:05 +0000 (21:15 +1000)
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.

Removes comment about never timing out loopback.
The check preventing loopback timeouts was removed when SV_CheckTimeouts
was added and IMO timeouts SHOULD apply on loopback. Someone can run a
server on their PC and connect to it and if their client fails or is
killed abruptly, it shouldn't occupy a slot forever.

protocol.h
server.h
sv_main.c
sv_user.c

index 170db5b9ecb5e5158da187a7635731c721af7dcb..da32ab782d1b67e9edeb525e0b4b63684d33c5de 100644 (file)
@@ -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)
+       float receivetime; // time the move was received at (used for ping)
        int msec; // for predicted moves
        int buttons;
        int impulse;
index 9a9a6d9b4ffb9c4b80e4b5959d5878c00d623e0c..503d1b146aac2320fea96c8f8bfeebda599d5bad 100644 (file)
--- 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;
 
index 22a1f8827a4f3de160cdcfd6805d750b04268ade..8619331d3b93c8aa4f228e2d6d1f064ac06b9afe 100644 (file)
--- 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
@@ -2459,7 +2454,6 @@ static void SV_CheckTimeouts(void)
 {
        int i;
 
-       // never timeout loopback connections
        for (i = (host_isclient.integer ? 1 : 0), host_client = &svs.clients[i]; i < svs.maxclients; i++, host_client++)
        {
                if (host_client->netconnection && host.realtime > host_client->netconnection->timeout)
index 76231f65bfbf4fe9552dad17e2519a78d04bb6a4..db864081ee1f24e0da996ffb78bf8418289f5c3f 100644 (file)
--- 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;
 
@@ -663,7 +663,7 @@ static void SV_ReadClientMove (void)
 #endif
        // limit reported time to current time
        // (incase the client is trying to cheat)
-       move->time = min(move->time, move->receivetime + sv.frametime);
+       move->time = min(move->time, sv.time + sv.frametime);
 
        // read current angles
        for (i = 0;i < 3;i++)
@@ -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
@@ -842,8 +840,6 @@ static void SV_ExecuteClientMoves(void)
                                //  with this approach, and if they don't send input for a while they
                                //  start moving anyway, so the longest 'lagaport' possible is
                                //  determined by the sv_clmovement_inputtimeout cvar)
-                               if (moveframetime <= 0)
-                                       continue;
                                oldframetime = PRVM_serverglobalfloat(frametime);
                                oldframetime2 = sv.frametime;
                                // update ping time for qc to see while executing this move
@@ -888,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)