diff options
author | thilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2009-06-23 00:59:47 +0000 |
---|---|---|
committer | thilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2009-06-23 00:59:47 +0000 |
commit | 6b933415d6c20935c98b0b3748724aa2485d82a9 (patch) | |
tree | a2347b064364515e6754b89a621def6877cd1738 | |
parent | d19f5c00e3d1eb1de800cdcfb36dc0bb77f61cbd (diff) | |
download | ioquake3-aero-6b933415d6c20935c98b0b3748724aa2485d82a9.tar.gz ioquake3-aero-6b933415d6c20935c98b0b3748724aa2485d82a9.zip |
- fix typo in previous commit to net_ip.c
- Make servers send heartbeats to master servers in ipv4 as well as ipv6 if master server has both protocols
git-svn-id: svn://svn.icculus.org/quake3/trunk@1578 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r-- | code/qcommon/net_ip.c | 2 | ||||
-rw-r--r-- | code/server/sv_main.c | 79 |
2 files changed, 58 insertions, 23 deletions
diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c index 5647414..2cbd52b 100644 --- a/code/qcommon/net_ip.c +++ b/code/qcommon/net_ip.c @@ -285,7 +285,7 @@ static qboolean Sys_StringToSockaddr(const char *s, struct sockaddr *sadr, int s if(family == AF_UNSPEC) { // Decide here and now which protocol family to use - if((net_enabled->integer & NET_PRIOV6) + if(net_enabled->integer & NET_PRIOV6) { if(net_enabled->integer & NET_ENABLEV6) search = SearchAddrInfo(res, AF_INET6); diff --git a/code/server/sv_main.c b/code/server/sv_main.c index 23dc50f..5d3c7ff 100644 --- a/code/server/sv_main.c +++ b/code/server/sv_main.c @@ -234,56 +234,91 @@ but not on every player enter or exit. #define HEARTBEAT_MSEC 300*1000 #define HEARTBEAT_GAME "QuakeArena-1" void SV_MasterHeartbeat( void ) { - static netadr_t adr[MAX_MASTER_SERVERS]; + static netadr_t adr[MAX_MASTER_SERVERS][2]; // [2] for v4 and v6 address for the same address string. int i; int res; + int netenabled; + + netenabled = Cvar_VariableIntegerValue("net_enabled"); // "dedicated 1" is for lan play, "dedicated 2" is for inet public play - if ( !com_dedicated || com_dedicated->integer != 2 ) { + if (!com_dedicated || com_dedicated->integer != 2 || !(netenabled & (NET_ENABLEV4 | NET_ENABLEV6))) return; // only dedicated servers send heartbeats - } // if not time yet, don't send anything - if ( svs.time < svs.nextHeartbeatTime ) { + if ( svs.time < svs.nextHeartbeatTime ) return; - } - svs.nextHeartbeatTime = svs.time + HEARTBEAT_MSEC; + svs.nextHeartbeatTime = svs.time + HEARTBEAT_MSEC; // send to group masters - for ( i = 0 ; i < MAX_MASTER_SERVERS ; i++ ) { - if ( !sv_master[i]->string[0] ) { + for (i = 0; i < MAX_MASTER_SERVERS; i++) + { + if(!sv_master[i]->string[0]) continue; - } // see if we haven't already resolved the name // resolving usually causes hitches on win95, so only // do it when needed - if ( sv_master[i]->modified ) { + if(sv_master[i]->modified || (adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD)) + { sv_master[i]->modified = qfalse; - - Com_Printf( "Resolving %s\n", sv_master[i]->string ); - res = NET_StringToAdr( sv_master[i]->string, &adr[i], NA_UNSPEC ); - if ( !res ) { + + if(netenabled & NET_ENABLEV4) + { + Com_Printf("Resolving %s (IPv4)\n", sv_master[i]->string); + res = NET_StringToAdr(sv_master[i]->string, &adr[i][0], NA_IP); + + if(res == 2) + { + // if no port was specified, use the default master port + adr[i][0].port = BigShort(PORT_MASTER); + } + + if(res) + Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToStringwPort(adr[i][0])); + else + Com_Printf( "%s has no IPv4 address.\n", sv_master[i]->string); + } + + if(netenabled & NET_ENABLEV6) + { + Com_Printf("Resolving %s (IPv6)\n", sv_master[i]->string); + res = NET_StringToAdr(sv_master[i]->string, &adr[i][1], NA_IP6); + + if(res == 2) + { + // if no port was specified, use the default master port + adr[i][1].port = BigShort(PORT_MASTER); + } + + if(res) + Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToStringwPort(adr[i][1])); + else + Com_Printf( "%s has no IPv6 address.\n", sv_master[i]->string); + } + + if(adr[i][0].type == NA_BAD && adr[i][1].type == NA_BAD) + { // if the address failed to resolve, clear it // so we don't take repeated dns hits - Com_Printf( "Couldn't resolve address: %s\n", sv_master[i]->string ); - Cvar_Set( sv_master[i]->name, "" ); + Com_Printf("Couldn't resolve address: %s\n", sv_master[i]->string); + Cvar_Set(sv_master[i]->name, ""); sv_master[i]->modified = qfalse; continue; } - if ( res == 2 ) { - // if no port was specified, use the default master port - adr[i].port = BigShort( PORT_MASTER ); - } - Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToStringwPort(adr[i])); } Com_Printf ("Sending heartbeat to %s\n", sv_master[i]->string ); + // this command should be changed if the server info / status format // ever incompatably changes - NET_OutOfBandPrint( NS_SERVER, adr[i], "heartbeat %s\n", HEARTBEAT_GAME ); + + if(adr[i][0].type != NA_BAD) + NET_OutOfBandPrint( NS_SERVER, adr[i][0], "heartbeat %s\n", HEARTBEAT_GAME ); + if(adr[i][1].type != NA_BAD) + NET_OutOfBandPrint( NS_SERVER, adr[i][1], "heartbeat %s\n", HEARTBEAT_GAME ); } } |