// disconnect from server
CL_Disconnect ();
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
// update networking ports (this is mainly just needed at startup)
NetConn_ClientFrame();
{
Con_Print("CL_SendMove: lost server connection\n");
CL_Disconnect();
- Host_ShutdownServer(false);
+ Host_ShutdownServer();
}
}
{
CL_Disconnect ();
if (sv.active)
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
}
PRVM_Crash();
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
if (cls.state == ca_dedicated)
Sys_Error ("Host_Error: %s",hosterrorstring2); // dedicated servers exit
This only happens at the end of a game, not between levels
==================
*/
-void Host_ShutdownServer(qboolean crash)
+void Host_ShutdownServer(void)
{
- int i, count;
- sizebuf_t buf;
- unsigned char message[4];
+ int i;
Con_DPrintf("Host_ShutdownServer\n");
NetConn_Heartbeat(2);
// make sure all the clients know we're disconnecting
- buf.data = message;
- buf.maxsize = 4;
- buf.cursize = 0;
- MSG_WriteByte(&buf, svc_disconnect);
- count = NetConn_SendToAll(&buf, 5);
- if (count)
- Con_Printf("Host_ShutdownServer: NetConn_SendToAll failed for %u clients\n", count);
-
SV_VM_Begin();
for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
if (host_client->active)
- SV_DropClient(crash); // server shutdown
+ SV_DropClient(false); // server shutdown
SV_VM_End();
NetConn_CloseServerPorts();
CL_Disconnect();
// shut down local server if active
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
// Shutdown menu
if(MR_Shutdown)
cls.demonum = -1; // stop demo loop in case this fails
CL_Disconnect ();
- Host_ShutdownServer(false);
+ Host_ShutdownServer();
// remove console or menu
key_dest = key_game;
if (!cls.demoplayback)
return;
CL_Disconnect ();
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
}
void Host_SendCvar_f (void)
CL_Disconnect();
// if we're connecting to a remote server, shut down any local server
if (LHNETADDRESS_GetAddressType(peeraddress) != LHNETADDRESSTYPE_LOOP && sv.active)
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
// allocate a net connection to keep track of things
cls.netcon = NetConn_Open(mysocket, peeraddress);
Con_Printf("Connection accepted to %s\n", cls.netcon->address);
{
Con_Print("Connection timed out\n");
CL_Disconnect();
- Host_ShutdownServer (false);
+ Host_ShutdownServer ();
}
for (conn = netconn_list;conn;conn = conn->next)
NetConn_ReSendMessage(conn);
}
}
-int NetConn_SendToAll(sizebuf_t *data, double blocktime)
-{
- int i, count = 0;
- unsigned char sent[MAX_SCOREBOARD];
-
- memset(sent, 0, sizeof(sent));
-
- // simultaneously wait for the first CanSendMessage and send the message,
- // then wait for a second CanSendMessage (verifying it was received), or
- // the client drops and is no longer counted
- // the loop aborts when either it runs out of clients to send to, or a
- // timeout expires
- blocktime += Sys_DoubleTime();
- do
- {
- count = 0;
- // run a network frame to check for packets
- NetConn_ClientFrame();SV_VM_Begin();NetConn_ServerFrame();SV_VM_End();
- for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
- {
- if (host_client->netconnection)
- {
- if (NetConn_CanSendMessage(host_client->netconnection))
- {
- if (!sent[i])
- NetConn_SendReliableMessage(host_client->netconnection, data);
- sent[i] = true;
- }
- if (!NetConn_CanSendMessage(host_client->netconnection))
- count++;
- }
- }
- }
- while (count && Sys_DoubleTime() < blocktime);
- return count;
-}
-
static void Net_Heartbeat_f(void)
{
if (sv.active)
void NetConn_QueryMasters(void);
void NetConn_Heartbeat(int priority);
void NetConn_QueryQueueFrame(void);
-int NetConn_SendToAll(sizebuf_t *data, double blocktime);
void Net_Stats_f(void);
void Net_Slist_f(void);
void Host_Frame(float time);
void Host_Quit_f(void);
void Host_ClientCommands(const char *fmt, ...);
-void Host_ShutdownServer(qboolean crash);
+void Host_ShutdownServer(void);
void Host_Reconnect_f(void);
void Host_AbortCurrentFrame(void);
}
-/*
-================
-SV_SendReconnect
-
-Tell all the clients that the server is changing levels
-================
-*/
-void SV_SendReconnect (void)
-{
-#if 1
- MSG_WriteByte(&sv.reliable_datagram, svc_stufftext);
- MSG_WriteString(&sv.reliable_datagram, "reconnect\n");
-#else
- unsigned char data[128];
- sizebuf_t msg;
-
- msg.data = data;
- msg.cursize = 0;
- msg.maxsize = sizeof(data);
-
- MSG_WriteChar (&msg, svc_stufftext);
- MSG_WriteString (&msg, "reconnect\n");
- NetConn_SendToAll (&msg, 5);
-
- if (cls.state != ca_dedicated)
- Cmd_ExecuteString ("reconnect\n", src_command);
-#endif
-}
-
-
/*
================
SV_SaveSpawnparms
//
if (sv.active)
{
+ // Tell all the clients that the server is changing levels
SV_VM_Begin();
- SV_SendReconnect();
+ MSG_WriteByte(&sv.reliable_datagram, svc_stufftext);
+ MSG_WriteString(&sv.reliable_datagram, "reconnect\n");
SV_VM_End();
}
else