From 3f94d889aed3fc9aa2fc39ae80c3d00bc56f991f Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 5 Apr 2004 06:20:23 +0000 Subject: [PATCH] fixed very annoying '5 second timeout' bug in Host_ShutdownServer (the local client was timing out on the NetConn_SendToAll because the server was ignoring the client's reply packets, by setting sv.active = false too early) 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 | 1 + cl_input.c | 1 + cl_main.c | 9 ++------- host.c | 15 ++++++--------- host_cmd.c | 1 + netconn.c | 1 + 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/cl_demo.c b/cl_demo.c index 1024cf3a..85efe355 100644 --- 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(); diff --git a/cl_input.c b/cl_input.c index fac600f9..e3d964d8 100644 --- a/cl_input.c +++ b/cl_input.c @@ -465,6 +465,7 @@ void CL_SendMove(usercmd_t *cmd) { Con_Print("CL_SendMove: lost server connection\n"); CL_Disconnect(); + Host_ShutdownServer(false); } } diff --git a/cl_main.c b/cl_main.c index b861dc3b..511aa1be 100644 --- 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 61c9bb0b..4aea3260 100644 --- 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 // diff --git a/host_cmd.c b/host_cmd.c index 0552aff8..b5d43ffe 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -1673,6 +1673,7 @@ void Host_Stopdemo_f (void) if (!cls.demoplayback) return; CL_Disconnect (); + Host_ShutdownServer (false); } static void MaxPlayers_f(void) diff --git a/netconn.c b/netconn.c index 3226f763..39802582 100755 --- 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); -- 2.39.2