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.)
This commit is contained in:
Bill Currie 2010-11-21 14:27:43 +09:00
parent 1dfb914c46
commit d4ae231f34
4 changed files with 7 additions and 9 deletions

View file

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

View file

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

View file

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

View file

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