From 2053fe002dd150fc624bdd621181786b66fd8f73 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 15 Mar 2005 00:12:19 +0000 Subject: [PATCH] now searchs LAN for servers (using a broadcast message to port 26000) like Quake did git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5086 d7cf8633-e32d-0410-b094-e92efae38249 --- netconn.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/netconn.c b/netconn.c index f93865c0..3ec5d28f 100755 --- a/netconn.c +++ b/netconn.c @@ -1587,20 +1587,22 @@ void NetConn_QueryMasters(void) 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); @@ -1608,12 +1610,13 @@ void NetConn_QueryMasters(void) 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 -- 2.39.2