mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 15:31:39 +00:00
* 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
This commit is contained in:
parent
6b798a2ffa
commit
422fb4674a
4 changed files with 21 additions and 18 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
||||
|
|
|
@ -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 ; i<svs.maxclients ; i++, host_client++)
|
||||
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)
|
||||
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 ; i<svs.maxclients ; i++, host_client++)
|
||||
{
|
||||
if (! state1[i])
|
||||
if (! msg_init[i])
|
||||
{
|
||||
if (NET_CanSendMessage (host_client->netconnection))
|
||||
{
|
||||
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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue