]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
netconn: Move the timeout checks to new function SV_CheckTimeouts
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 Oct 2020 12:54:27 +0000 (12:54 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 Oct 2020 12:54:27 +0000 (12:54 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13006 d7cf8633-e32d-0410-b094-e92efae38249

netconn.c
sv_main.c

index 234eec60a26ccfe05c9dbb4d1654c13b15839487..1b48ac691764de43cc3e0a79bc44bd9d50e281c9 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -3610,15 +3610,6 @@ void NetConn_ServerFrame(void)
        for (i = 0;i < sv_numsockets;i++)
                while (sv_sockets[i] && (length = NetConn_Read(sv_sockets[i], readbuffer, sizeof(readbuffer), &peeraddress)) > 0)
                        NetConn_ServerParsePacket(sv_sockets[i], readbuffer, length, &peeraddress);
-       for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
-       {
-               // never timeout loopback connections
-               if (host_client->netconnection && host.realtime > host_client->netconnection->timeout && LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) != LHNETADDRESSTYPE_LOOP)
-               {
-                       Con_Printf("Client \"%s\" connection timed out\n", host_client->name);
-                       SV_DropClient(false);
-               }
-       }
 }
 
 void NetConn_SleepMicroseconds(int microseconds)
index 9f2a3f1f4c8e2ecf194b6c7be0caaa102498d4c7..a5fc047f587421c3fe72a582042a09a9f4f1ed33 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -2403,6 +2403,21 @@ static void SV_VM_Setup(void)
        SV_Prepare_CSQC();
 }
 
+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)
+               {
+                       Con_Printf("Client \"%s\" connection timed out\n", host_client->name);
+                       SV_DropClient(false);
+               }
+       }
+}
+
 extern cvar_t host_maxwait;
 extern cvar_t host_framerate;
 extern cvar_t cl_maxphysicsframesperserverframe;
@@ -2456,7 +2471,10 @@ double SV_Frame(double time)
                 * be undersleeping due to select() detecting a new packet
                 */
                if (sv.active)
+               {
                        NetConn_ServerFrame();
+                       SV_CheckTimeouts();
+               }
        }
 
        /*
@@ -2635,7 +2653,10 @@ static int SV_ThreadFunc(void *voiddata)
 
                // get new packets
                if (sv.active)
+               {
                        NetConn_ServerFrame();
+                       SV_CheckTimeouts();
+               }
 
                // if the accumulators haven't become positive yet, wait a while
                wait = sv_timer * -1000000.0;