]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Make connections atomic. Disconnect before trying to connect.
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 20 May 2020 15:22:06 +0000 (15:22 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 20 May 2020 15:22:06 +0000 (15:22 +0000)
Fixes an issue where a demo freezes in place if you try to connect while one is
running. This also has the side effect of eliminating a duplicate call to
CL_StopPlayback, which is called by both CL_EstablishConnection and
CL_Disconnect (which is itself called by NetConn_ConnectionEstablished).

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12544 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
netconn.c

index 7af224e045bb68c1aa496b123f3eaeefde0771a7..b0c913d054fa1e0092262e219ba89f46c56b8664 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -427,15 +427,13 @@ void CL_EstablishConnection(const char *host, int firstarg)
 #ifdef CONFIG_MENU
        M_Update_Return_Reason("");
 #endif
-       cls.demonum = -1;
-
-       // stop demo loop in case this fails
-       if (cls.demoplayback)
-               CL_StopPlayback();
 
        // if downloads are running, cancel their finishing action
        Curl_Clear_forthismap();
 
+       // Disconnect from the current server, or stop a running demo.
+       CL_Disconnect();
+
        // make sure the client ports are open before attempting to connect
        NetConn_UpdateSockets();
 
index 28b9a57520230184c311ed2199202b51230050bb..95b6a8a3a342f98e06d7ce3acfd353bab9facd92 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -1513,8 +1513,6 @@ static void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_
 #ifdef CONFIG_MENU
        M_Update_Return_Reason("");
 #endif
-       // the connection request succeeded, stop current connection and set up a new connection
-       CL_Disconnect();
        // if we're connecting to a remote server, shut down any local server
        if (LHNETADDRESS_GetAddressType(peeraddress) != LHNETADDRESSTYPE_LOOP && sv.active)
        {