From 422fb4674a07160b87442406e2c0e5c04d4702b8 Mon Sep 17 00:00:00 2001 From: sezero Date: Sun, 20 Jun 2010 15:00:57 +0000 Subject: [PATCH] * net_main.c: Fix NET_SendToAll() so that it really skips non-connected clients. While we're at it, change the type of the blocktime argument to double (the comparison is against a double.) Rename the cryptic state1 and state2 variables to something more indicative of thei purpose, ie. msg_init and msg_sent. from uhexen2. * net.h, host.c, sv_main.c: Adjust for the NET_SendToAll() argument type change. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@200 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/host.c | 2 +- Quake/net.h | 2 +- Quake/net_main.c | 33 ++++++++++++++++++--------------- Quake/sv_main.c | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Quake/host.c b/Quake/host.c index c6a12c8f..7278fe48 100644 --- a/Quake/host.c +++ b/Quake/host.c @@ -500,7 +500,7 @@ void Host_ShutdownServer(qboolean crash) buf.maxsize = 4; buf.cursize = 0; MSG_WriteByte(&buf, svc_disconnect); - count = NET_SendToAll(&buf, 5); + count = NET_SendToAll(&buf, 5.0); if (count) Con_Printf("Host_ShutdownServer: NET_SendToAll failed for %u clients\n", count); diff --git a/Quake/net.h b/Quake/net.h index 9fed4781..3d2c2f54 100644 --- a/Quake/net.h +++ b/Quake/net.h @@ -293,7 +293,7 @@ int NET_SendUnreliableMessage (struct qsocket_s *sock, sizebuf_t *data); // returns 1 if the message was sent properly // returns -1 if the connection died -int NET_SendToAll(sizebuf_t *data, int blocktime); +int NET_SendToAll(sizebuf_t *data, double blocktime); // This is a reliable *blocking* send to all attached clients. diff --git a/Quake/net_main.c b/Quake/net_main.c index f8e15d05..1a3af75e 100644 --- a/Quake/net_main.c +++ b/Quake/net_main.c @@ -623,35 +623,38 @@ qboolean NET_CanSendMessage (qsocket_t *sock) } -int NET_SendToAll(sizebuf_t *data, int blocktime) +int NET_SendToAll (sizebuf_t *data, double blocktime) { double start; int i; int count = 0; - qboolean state1 [MAX_SCOREBOARD]; - qboolean state2 [MAX_SCOREBOARD]; + qboolean msg_init[MAX_SCOREBOARD]; /* can we send */ + qboolean state2[MAX_SCOREBOARD]; /* did we send */ - for (i=0, host_client = svs.clients ; inetconnection) continue; if (host_client->active) + */ + if (host_client->netconnection && host_client->active) { - if (host_client->netconnection->driver == 0) + if (host_client->netconnection->driver == 0) /* Loop */ { NET_SendMessage(host_client->netconnection, data); - state1[i] = true; - state2[i] = true; + msg_init[i] = true; + msg_sent[i] = true; continue; } count++; - state1[i] = false; - state2[i] = false; + msg_init[i] = false; + msg_sent[i] = false; } else { - state1[i] = true; - state2[i] = true; + msg_init[i] = true; + msg_sent[i] = true; } } @@ -661,11 +664,11 @@ int NET_SendToAll(sizebuf_t *data, int blocktime) count = 0; for (i=0, host_client = svs.clients ; inetconnection)) { - state1[i] = true; + msg_init[i] = true; NET_SendMessage(host_client->netconnection, data); } else @@ -676,11 +679,11 @@ int NET_SendToAll(sizebuf_t *data, int blocktime) continue; } - if (! state2[i]) + if (! msg_sent[i]) { if (NET_CanSendMessage (host_client->netconnection)) { - state2[i] = true; + msg_sent[i] = true; } else { diff --git a/Quake/sv_main.c b/Quake/sv_main.c index 413ed70c..43f8c34b 100644 --- a/Quake/sv_main.c +++ b/Quake/sv_main.c @@ -1229,7 +1229,7 @@ void SV_SendReconnect (void) MSG_WriteChar (&msg, svc_stufftext); MSG_WriteString (&msg, "reconnect\n"); - NET_SendToAll (&msg, 5); + NET_SendToAll (&msg, 5.0); if (cls.state != ca_dedicated) Cmd_ExecuteString ("reconnect\n", src_command);