Host_ShutdownServer -> SV_Shutdown

This commit is contained in:
Joseph Carter 2000-02-10 09:43:27 +00:00
parent df559eaf9f
commit 2425b04e3b
5 changed files with 76 additions and 7 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -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 ();

View file

@ -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 ; i<svs.maxclients ; i++, host_client++)
{
if (host_client->active && 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 ; i<svs.maxclients ; i++, host_client++)
if (host_client->active)
SV_DropClient(crash);
//
// clear structures
//
memset (&sv, 0, sizeof(sv));
memset (svs.clients, 0, svs.maxclientslimit*sizeof(client_t));
}
/*
===============
SV_Init