#define MASTER_PORT 27950
-cvar_t sv_public = {0, "sv_public", "0"};
+cvar_t sv_public = {0, "sv_public", "1"};
static cvar_t sv_heartbeatperiod = {CVAR_SAVE, "sv_heartbeatperiod", "180"};
// FIXME: resolve DNS on masters whenever their value changes and cache it (to avoid major delays in active servers when they heartbeat)
// returns true if A should be inserted before B
static qboolean _HostCache_SortTest( hostcache_t *A, hostcache_t *B )
{
- int result = 0; // > 0 if for numbers A > B and for text if A < B
+ int result = 0; // > 0 if for numbers A > B and for text if A < B
if( hostcache_sortbyfield == HCIF_PING )
result = A->info.ping - B->info.ping;
result = strcmp( B->info.mod, A->info.mod );
else if( hostcache_sortbyfield == HCIF_NAME )
result = strcmp( B->info.name, A->info.name );
-
+
if( hostcache_sortdescending )
return result > 0;
return result < 0;
else if( op == HCMO_EQUAL )
return strcmp( A, B ) == 0;
else if( op == HCMO_GREATER )
- return strcmp( A, B ) > 0;
+ return strcmp( A, B ) > 0;
else if( op == HCMO_NOTEQUAL )
return strcmp( A, B ) != 0;
else // HCMO_GREATEREQUAL
if( hostcache_viewcount == HOSTCACHE_VIEWCACHESIZE )
return;
// now check whether it passes through the masks mask
- for( start = 0 ; hostcache_andmasks[start].active && start < HOSTCACHE_ANDMASKCOUNT ; start++ )
+ for( start = 0 ; hostcache_andmasks[start].active && start < HOSTCACHE_ANDMASKCOUNT ; start++ )
if( !_HostCache_TestMask( &hostcache_andmasks[start], &entry->info ) )
return;
if( _HostCache_SortTest( entry, hostcache_viewset[mid] ) )
// the item has to be in the upper half
end = mid;
- else
+ else
// the item has to be in the lower half
start = mid;
}
void HostCache_RebuildViewSet(void)
{
int i;
-
+
hostcache_viewcount = 0;
for( i = 0 ; i < hostcache_cachecount ; i++ )
if( hostcache_cache[i].finished )
hostcache_viewcount = 0;
hostcache_consoleoutput = false;
NetConn_QueryMasters();
-
- //_HostCache_Test();
+
+ //_HostCache_Test();
}
// rest
hostcache_info_t *info;
int i, n;
double pingtime;
-
+
string += 13;
// hostcache only uses text addresses
LHNETADDRESS_ToString(peeraddress, cname, sizeof(cname), true);
while (length >= 7 && data[0] == '\\' && (data[1] != 0xFF || data[2] != 0xFF || data[3] != 0xFF || data[4] != 0xFF) && data[5] * 256 + data[6] != 0)
{
serverquerycount++;
-
+
dpsnprintf (ipstring, sizeof (ipstring), "%u.%u.%u.%u:%u", data[1], data[2], data[3], data[4], (data[5] << 8) | data[6]);
if (developer.integer)
- Con_Printf("Requesting info from server %s\n", ipstring);
+ Con_Printf("Requesting info from server %s\n", ipstring);
// ignore the rest of the message if the hostcache is full
if( hostcache_cachecount == HOSTCACHE_TOTALSIZE )
break;
int i;
int masternum;
lhnetaddress_t masteraddress;
+ lhnetaddress_t broadcastaddress;
char request[256];
if (hostcache_cachecount >= HOSTCACHE_TOTALSIZE)
return;
+ // 26000 is the default quake server port, servers on other ports will not
+ // be found
+ // note this is IPv4-only, I doubt there are IPv6-only LANs out there
+ LHNETADDRESS_FromString(&broadcastaddress, "255.255.255.255", 26000);
+
for (i = 0;i < cl_numsockets;i++)
{
if (cl_sockets[i])
{
-#if 0
- // search LAN
-#if 1
- UDP_Broadcast(UDP_controlSock, "\377\377\377\377getinfo", 11);
-#else
+ // search LAN for Quake servers
SZ_Clear(&net_message);
// save space for the header, filled in later
MSG_WriteLong(&net_message, 0);
MSG_WriteString(&net_message, "QUAKE");
MSG_WriteByte(&net_message, NET_PROTOCOL_VERSION);
*((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
- UDP_Broadcast(UDP_controlSock, net_message.data, net_message.cursize);
+ NetConn_Write(cl_sockets[i], net_message.data, net_message.cursize, &broadcastaddress);
SZ_Clear(&net_message);
-#endif
-#endif
- // build the getservers
+ // search LAN for DarkPlaces servers
+ NetConn_WriteString(cl_sockets[i], "\377\377\377\377getinfo", &broadcastaddress);
+
+ // build the getservers message to send to the master servers
dpsnprintf(request, sizeof(request), "\377\377\377\377getservers %s %u empty full\x0A", gamename, NET_PROTOCOL_VERSION);
// search internet