From 2425b04e3baeed1d530be91ea9a3d0ac615931b5 Mon Sep 17 00:00:00 2001 From: Joseph Carter Date: Thu, 10 Feb 2000 09:43:27 +0000 Subject: [PATCH] Host_ShutdownServer -> SV_Shutdown --- common/cl_main.c | 4 +- common/host.c | 4 +- old_headers/standalone/quakedef.h | 2 +- uquake/host_cmd.c | 4 +- uquake/sv_main.c | 69 +++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 7 deletions(-) diff --git a/common/cl_main.c b/common/cl_main.c index 90f2eff..337b21e 100644 --- a/common/cl_main.c +++ b/common/cl_main.c @@ -569,7 +569,7 @@ void CL_Disconnect (void) cls.demoplayback = cls.demorecording = cls.timedemo = false; #ifdef UQUQKE if (sv.active) - Host_ShutdownServer(false); + SV_Shutdown(false); #endif } #ifdef QUAKEWORLD @@ -593,7 +593,7 @@ void CL_Disconnect_f (void) CL_Disconnect (); #ifdef UQUQKE if (sv.active) - Host_ShutdownServer (false); + SV_Shutdown (false); #endif } diff --git a/common/host.c b/common/host.c index 64a09fc..0c99df2 100644 --- a/common/host.c +++ b/common/host.c @@ -145,7 +145,7 @@ Host_EndGame ( char *message, ... ) longjmp (host_abort, 1); #elif UQUAKE if ( sv.active ) - Host_ShutdownServer (false); + SV_Shutdown (false); if ( cls.state == ca_dedicated ) Sys_Error ("Host_EndGame: %s\n",string); // dedicated servers exit @@ -421,7 +421,7 @@ Host_Error ( char *error, ... ) #ifdef UQUAKE if (sv.active) - Host_ShutdownServer (false); + SV_Shutdown (false); if (cls.state == ca_dedicated) Sys_Error ("Host_Error: %s\n",string); // dedicated servers exit diff --git a/old_headers/standalone/quakedef.h b/old_headers/standalone/quakedef.h index 821aef1..b4c5e48 100644 --- a/old_headers/standalone/quakedef.h +++ b/old_headers/standalone/quakedef.h @@ -309,7 +309,7 @@ void Host_EndGame (char *message, ...); void Host_Frame (float time); void Host_Quit_f (void); void Host_ClientCommands (char *fmt, ...); -void Host_ShutdownServer (qboolean crash); +void SV_Shutdown (qboolean crash); extern qboolean msg_suppress_1; // suppresses resolution and cache size console output // an fullscreen DIB focus gain/loss diff --git a/uquake/host_cmd.c b/uquake/host_cmd.c index 27027ef..73877a7 100644 --- a/uquake/host_cmd.c +++ b/uquake/host_cmd.c @@ -60,7 +60,7 @@ void Host_Quit_f (void) return; } CL_Disconnect (); - Host_ShutdownServer(false); + SV_Shutdown(false); Sys_Quit (); } @@ -282,7 +282,7 @@ void Host_Map_f (void) cls.demonum = -1; // stop demo loop in case this fails CL_Disconnect (); - Host_ShutdownServer(false); + SV_Shutdown(false); key_dest = key_game; // remove console or menu SCR_BeginLoadingPlaque (); diff --git a/uquake/sv_main.c b/uquake/sv_main.c index 730f7a9..4043119 100644 --- a/uquake/sv_main.c +++ b/uquake/sv_main.c @@ -43,6 +43,75 @@ char localmodels[MAX_MODELS][5]; // inline model names for precache //============================================================================ +/* +================== +SV_Shutdown + +This only happens at the end of a game, not between levels +================== +*/ +void SV_Shutdown(qboolean crash) +{ + int i; + int count; + sizebuf_t buf; + char message[4]; + double start; + + if (!sv.active) + return; + + sv.active = false; + +// stop all client sounds immediately + if (cls.state >= ca_connected) + CL_Disconnect (); + +// flush any pending messages - like the score!!! + start = Sys_DoubleTime(); + do + { + count = 0; + for (i=0, host_client = svs.clients ; iactive && host_client->message.cursize) + { + if (NET_CanSendMessage (host_client->netconnection)) + { + NET_SendMessage(host_client->netconnection, &host_client->message); + SZ_Clear (&host_client->message); + } + else + { + NET_GetMessage(host_client->netconnection); + count++; + } + } + } + if ((Sys_DoubleTime() - start) > 3.0) + break; + } + while (count); + +// make sure all the clients know we're disconnecting + buf.data = message; + buf.maxsize = 4; + buf.cursize = 0; + MSG_WriteByte(&buf, svc_disconnect); + count = NET_SendToAll(&buf, 5); + if (count) + Con_Printf("SV_ShutdownServer: NET_SendToAll failed for %u clients\n", count); + + for (i=0, host_client = svs.clients ; iactive) + SV_DropClient(crash); + +// +// clear structures +// + memset (&sv, 0, sizeof(sv)); + memset (svs.clients, 0, svs.maxclientslimit*sizeof(client_t)); +} /* =============== SV_Init