From d4ae231f34ef157f549e181f3159799efffcd645 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 21 Nov 2010 14:27:43 +0900 Subject: [PATCH] sezero's NET_SendToAll fix Here's a patch to NET_SendToAll() which was always broken: it never skipped non-connected clients. Depending on the compiler, it would wait the whole 5 seconds of its blocktime before it gave up. While there, changed its blocktime argument to double (the comparison is against a double.) --- include/netmain.h | 2 +- libs/net/net_main.c | 10 ++++------ nq/source/host.c | 2 +- nq/source/sv_main.c | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/netmain.h b/include/netmain.h index 10d3d0bf8..2ebc26a7f 100644 --- a/include/netmain.h +++ b/include/netmain.h @@ -287,7 +287,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/libs/net/net_main.c b/libs/net/net_main.c index 570cb52de..1ed65c06c 100644 --- a/libs/net/net_main.c +++ b/libs/net/net_main.c @@ -736,19 +736,17 @@ NET_CanSendMessage (qsocket_t * sock) int -NET_SendToAll (sizebuf_t *data, int blocktime) +NET_SendToAll (sizebuf_t *data, double blocktime) { double start; int i; int count = 0; - qboolean state1[MAX_SCOREBOARD]; - qboolean state2[MAX_SCOREBOARD]; + qboolean state1[MAX_SCOREBOARD]; /* can we send */ + qboolean state2[MAX_SCOREBOARD]; /* did we send */ for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++) { - if (!host_client->netconnection) - continue; - if (host_client->active) { + if (host_client->netconnection && host_client->active) { if (host_client->netconnection->driver == 0) { NET_SendMessage (host_client->netconnection, data); state1[i] = true; diff --git a/nq/source/host.c b/nq/source/host.c index c51872026..422516e6f 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -487,7 +487,7 @@ 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) Sys_Printf ("Host_ShutdownServer: NET_SendToAll failed for %u clients\n", diff --git a/nq/source/sv_main.c b/nq/source/sv_main.c index 553e1689b..b9c5e8f2c 100644 --- a/nq/source/sv_main.c +++ b/nq/source/sv_main.c @@ -858,7 +858,7 @@ SV_SendReconnect (void) MSG_WriteByte (&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);