cvar_t net_messagetimeout = {0, "net_messagetimeout","300"};
cvar_t hostname = {CVAR_SAVE, "hostname", "UNNAMED"};
+cvar_t developer_networking = {0, "developer_networking", "0"};
qboolean configRestored = false;
if (hostCacheCount)
Con_Printf("== end list ==\n\n");
else
- {
- if (gamemode == GAME_TRANSFUSION)
- Con_Printf("No Transfusion servers found.\n\n");
- else
- Con_Printf("No Quake servers found.\n\n");
- }
+ Con_Printf("No %s servers found.\n\n", gamename);
}
if (! slistSilent)
{
- if (gamemode == GAME_TRANSFUSION)
- Con_Printf("Looking for Transfusion servers...\n");
- else
- Con_Printf("Looking for Quake servers...\n");
+ Con_Printf("Looking for %s servers...\n", gamename);
PrintSlistHeader();
}
int NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
{
int r;
-
+
if (!sock)
return -1;
int NET_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
{
int r;
-
+
if (!sock)
return -1;
qboolean NET_CanSendMessage (qsocket_t *sock)
{
int r;
-
+
if (!sock)
return false;
SetNetTime();
r = sfunc.CanSendMessage(sock);
-
+
return r;
}
double start;
int i;
int count = 0;
- qboolean state1 [MAX_SCOREBOARD];
- qboolean state2 [MAX_SCOREBOARD];
+ qbyte state [MAX_SCOREBOARD];
- 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)
+ state[i] = 2;
+ if (host_client->netconnection && host_client->active)
{
if (host_client->netconnection->driver == 0)
- {
NET_SendMessage(host_client->netconnection, data);
- state1[i] = true;
- state2[i] = true;
- continue;
- }
- count++;
- state1[i] = false;
- state2[i] = false;
- }
- else
- {
- state1[i] = true;
- state2[i] = true;
+ else
+ state[i] = 0;
}
}
+ // for every player (simultaneously) wait for the first CanSendMessage
+ // and send the message, then wait for a second CanSendMessage (verifying
+ // it was received)
start = Sys_DoubleTime();
- while (count)
+ do
{
count = 0;
- 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 (! state1[i])
+ if (state[i] < 2)
{
- if (NET_CanSendMessage (host_client->netconnection))
- {
- state1[i] = true;
- NET_SendMessage(host_client->netconnection, data);
- }
- else
- {
- NET_GetMessage (host_client->netconnection);
- }
count++;
- continue;
- }
-
- if (! state2[i])
- {
+ // need to send to this one
if (NET_CanSendMessage (host_client->netconnection))
{
- state2[i] = true;
+ if (state[i] == 0 && NET_SendMessage (host_client->netconnection, data) == -1)
+ state[i] = 2; // connection lost
+ state[i]++;
}
else
- {
NET_GetMessage (host_client->netconnection);
- }
- count++;
- continue;
}
}
- if ((Sys_DoubleTime() - start) > blocktime)
- break;
}
+ while (count && (Sys_DoubleTime() - start) < blocktime);
return count;
}
Cvar_RegisterVariable (&net_messagetimeout);
Cvar_RegisterVariable (&hostname);
+ Cvar_RegisterVariable (&developer_networking);
Cmd_AddCommand ("net_slist", NET_Slist_f);
Cmd_AddCommand ("net_inetslist", NET_InetSlist_f);