fixed very annoying '5 second timeout' bug in Host_ShutdownServer (the local client...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 5 Apr 2004 06:20:23 +0000 (06:20 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 5 Apr 2004 06:20:23 +0000 (06:20 +0000)
added Host_ShutdownServer call near every CL_Disconnect call, for consistency
CL_Disconnect and Host_ShutdownServer now report their calls as dprints (previously they were entirely silent)

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

cl_demo.c
cl_input.c
cl_main.c
host.c
host_cmd.c
netconn.c

index 1024cf3..85efe35 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -319,6 +319,7 @@ void CL_PlayDemo_f (void)
 
        // disconnect from server
        CL_Disconnect ();
+       Host_ShutdownServer (false);
 
        // update networking ports (this is mainly just needed at startup)
        NetConn_ClientFrame();
index fac600f..e3d964d 100644 (file)
@@ -465,6 +465,7 @@ void CL_SendMove(usercmd_t *cmd)
        {
                Con_Print("CL_SendMove: lost server connection\n");
                CL_Disconnect();
+               Host_ShutdownServer(false);
        }
 }
 
index b861dc3..511aa1b 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -159,6 +159,8 @@ void CL_Disconnect(void)
        if (cls.state == ca_dedicated)
                return;
 
+       Con_DPrintf("CL_Disconnect\n");
+
 // stop sounds (especially looping!)
        S_StopAllSounds (true);
 
@@ -184,13 +186,6 @@ void CL_Disconnect(void)
                SZ_Clear(&cls.message);
                NetConn_Close(cls.netcon);
                cls.netcon = NULL;
-               // if running a local server, shut it down
-               if (sv.active)
-               {
-                       // prevent this code from executing again during Host_ShutdownServer
-                       cls.state = ca_disconnected;
-                       Host_ShutdownServer(false);
-               }
        }
        cls.state = ca_disconnected;
 
diff --git a/host.c b/host.c
index 61c9bb0..4aea326 100644 (file)
--- a/host.c
+++ b/host.c
@@ -111,8 +111,7 @@ void Host_EndGame (const char *format, ...)
        va_end (argptr);
        Con_DPrintf("Host_EndGame: %s\n",string);
 
-       if (sv.active)
-               Host_ShutdownServer (false);
+       Host_ShutdownServer (false);
 
        if (cls.state == ca_dedicated)
                Sys_Error ("Host_EndGame: %s\n",string);        // dedicated servers exit
@@ -168,8 +167,7 @@ void Host_Error (const char *error, ...)
 
        PRVM_ProcessError();
 
-       if (sv.active)
-               Host_ShutdownServer (false);
+       Host_ShutdownServer (false);
 
        if (cls.state == ca_dedicated)
                Sys_Error ("Host_Error: %s\n",hosterrorstring2);        // dedicated servers exit
@@ -507,14 +505,11 @@ void Host_ShutdownServer(qboolean crash)
        if (!sv.active)
                return;
 
+       Con_DPrintf("Host_ShutdownServer\n");
+
        // print out where the crash happened, if it was caused by QC
        PR_Crash();
 
-       sv.active = false;
-
-// stop all client sounds immediately
-       CL_Disconnect();
-
        NetConn_Heartbeat(2);
        NetConn_Heartbeat(2);
 
@@ -533,6 +528,8 @@ void Host_ShutdownServer(qboolean crash)
 
        NetConn_CloseServerPorts();
 
+       sv.active = false;
+
 //
 // clear structures
 //
index 0552aff..b5d43ff 100644 (file)
@@ -1673,6 +1673,7 @@ void Host_Stopdemo_f (void)
        if (!cls.demoplayback)
                return;
        CL_Disconnect ();
+       Host_ShutdownServer (false);
 }
 
 static void MaxPlayers_f(void)
index 3226f76..3980258 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -986,6 +986,7 @@ void NetConn_ClientFrame(void)
        {
                Con_Print("Connection timed out\n");
                CL_Disconnect();
+               Host_ShutdownServer (false);
        }
        for (conn = netconn_list;conn;conn = conn->next)
                NetConn_ReSendMessage(conn);