From cbb6c7c5b3dadfa4bf3bf06285722a69e4f93f51 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 11 Feb 2006 04:24:19 +0000 Subject: [PATCH] removed crash parameter from Host_ShudownServer, eliminated NetConn_SendToAll and SV_SendReconnect git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5962 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_demo.c | 2 +- cl_input.c | 2 +- cl_main.c | 2 +- host.c | 20 +++++--------------- host_cmd.c | 4 ++-- netconn.c | 41 ++--------------------------------------- netconn.h | 1 - quakedef.h | 2 +- sv_main.c | 34 +++------------------------------- 9 files changed, 16 insertions(+), 92 deletions(-) diff --git a/cl_demo.c b/cl_demo.c index 3a655ea0..3cb13425 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -328,7 +328,7 @@ void CL_PlayDemo_f (void) // disconnect from server CL_Disconnect (); - Host_ShutdownServer (false); + Host_ShutdownServer (); // update networking ports (this is mainly just needed at startup) NetConn_ClientFrame(); diff --git a/cl_input.c b/cl_input.c index 41513eca..de203112 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1009,7 +1009,7 @@ void CL_SendMove(void) { Con_Print("CL_SendMove: lost server connection\n"); CL_Disconnect(); - Host_ShutdownServer(false); + Host_ShutdownServer(); } } diff --git a/cl_main.c b/cl_main.c index 346ebdd4..32c7d61a 100644 --- a/cl_main.c +++ b/cl_main.c @@ -328,7 +328,7 @@ void CL_Disconnect_f(void) { CL_Disconnect (); if (sv.active) - Host_ShutdownServer (false); + Host_ShutdownServer (); } diff --git a/host.c b/host.c index 180bb66c..5cc6c41a 100644 --- a/host.c +++ b/host.c @@ -147,7 +147,7 @@ void Host_Error (const char *error, ...) PRVM_Crash(); - Host_ShutdownServer (false); + Host_ShutdownServer (); if (cls.state == ca_dedicated) Sys_Error ("Host_Error: %s",hosterrorstring2); // dedicated servers exit @@ -489,11 +489,9 @@ Host_ShutdownServer 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"); @@ -504,18 +502,10 @@ void Host_ShutdownServer(qboolean crash) 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(); @@ -1121,7 +1111,7 @@ void Host_Shutdown(void) CL_Disconnect(); // shut down local server if active - Host_ShutdownServer (false); + Host_ShutdownServer (); // Shutdown menu if(MR_Shutdown) diff --git a/host_cmd.c b/host_cmd.c index f047ac75..d816a7f3 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -267,7 +267,7 @@ void Host_Map_f (void) 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; @@ -1901,7 +1901,7 @@ void Host_Stopdemo_f (void) if (!cls.demoplayback) return; CL_Disconnect (); - Host_ShutdownServer (false); + Host_ShutdownServer (); } void Host_SendCvar_f (void) diff --git a/netconn.c b/netconn.c index 2f50f4d1..de4d467d 100755 --- a/netconn.c +++ b/netconn.c @@ -933,7 +933,7 @@ void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_t *peer 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); @@ -1327,7 +1327,7 @@ void NetConn_ClientFrame(void) { Con_Print("Connection timed out\n"); CL_Disconnect(); - Host_ShutdownServer (false); + Host_ShutdownServer (); } for (conn = netconn_list;conn;conn = conn->next) NetConn_ReSendMessage(conn); @@ -1932,43 +1932,6 @@ void NetConn_Heartbeat(int priority) } } -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) diff --git a/netconn.h b/netconn.h index 61d6f57c..b8247a19 100755 --- a/netconn.h +++ b/netconn.h @@ -317,7 +317,6 @@ void NetConn_ServerFrame(void); 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); diff --git a/quakedef.h b/quakedef.h index cac305b8..fcba8db0 100644 --- a/quakedef.h +++ b/quakedef.h @@ -241,7 +241,7 @@ void Host_Error(const char *error, ...); 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); diff --git a/sv_main.c b/sv_main.c index 39a9d48a..8e68234b 100644 --- a/sv_main.c +++ b/sv_main.c @@ -1606,36 +1606,6 @@ void SV_CreateBaseline (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 @@ -1748,8 +1718,10 @@ void SV_SpawnServer (const char *server) // 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 -- 2.39.2