| 1973 | //----------------------------------------------------------------------------- |
| 1974 | |
| 1975 | static void handleGameInfoRequest( const NetAddress* address, U32 key, U8 flags ) |
| 1976 | { |
| 1977 | // Do not respond unless there is a server running: |
| 1978 | if ( GNet->doesAllowConnections() ) |
| 1979 | { |
| 1980 | // Do not respond to offline queries if this is an online server: |
| 1981 | if ( flags & ServerFilter::OfflineQuery ) |
| 1982 | return; |
| 1983 | |
| 1984 | bool compressStrings = !( flags & ServerFilter::NoStringCompress ); |
| 1985 | BitStream *out = BitStream::getPacketStream(); |
| 1986 | out->clearStringBuffer(); |
| 1987 | |
| 1988 | out->write( U8( NetInterface::GameInfoResponse ) ); |
| 1989 | out->write( flags ); |
| 1990 | out->write( key ); |
| 1991 | |
| 1992 | if ( compressStrings ) { |
| 1993 | out->writeString( Con::getVariable( "Server::GameType" ) ); |
| 1994 | out->writeString( Con::getVariable( "Server::MissionType" ) ); |
| 1995 | out->writeString( Con::getVariable( "Server::MissionName" ) ); |
| 1996 | } |
| 1997 | else { |
| 1998 | writeCString( out, Con::getVariable( "Server::GameType" ) ); |
| 1999 | writeCString( out, Con::getVariable( "Server::MissionType" ) ); |
| 2000 | writeCString( out, Con::getVariable( "Server::MissionName" ) ); |
| 2001 | } |
| 2002 | |
| 2003 | U8 status = 0; |
| 2004 | #if defined(TORQUE_OS_LINUX) || defined(TORQUE_OS_OPENBSD) |
| 2005 | status |= ServerInfo::Status_Linux; |
| 2006 | #endif |
| 2007 | #if defined(TORQUE_OS_XENON) |
| 2008 | status |= ServerInfo::Status_Xenon; |
| 2009 | #endif |
| 2010 | if ( Con::getBoolVariable( "Server::Dedicated" ) ) |
| 2011 | status |= ServerInfo::Status_Dedicated; |
| 2012 | if ( dStrlen( Con::getVariable( "pref::Server::Password" ) ) ) |
| 2013 | status |= ServerInfo::Status_Passworded; |
| 2014 | out->write( status ); |
| 2015 | |
| 2016 | out->write( U8( Con::getIntVariable( "Server::PlayerCount" ) ) ); |
| 2017 | out->write( U8( Con::getIntVariable( "pref::Server::MaxPlayers" ) ) ); |
| 2018 | out->write( U8( Con::getIntVariable( "Server::BotCount" ) ) ); |
| 2019 | out->write( U16( Platform::SystemInfo.processor.mhz ) ); |
| 2020 | if ( compressStrings ) |
| 2021 | out->writeString( Con::getVariable( "pref::Server::Info" ) ); |
| 2022 | else |
| 2023 | writeCString( out, Con::getVariable( "pref::Server::Info" ) ); |
| 2024 | writeLongCString( out, Con::evaluate( "onServerInfoQuery();" ) ); |
| 2025 | |
| 2026 | BitStream::sendPacketStream(address); |
| 2027 | } |
| 2028 | } |
| 2029 | |
| 2030 | //----------------------------------------------------------------------------- |
| 2031 |
no test coverage detected