| 1821 | //----------------------------------------------------------------------------- |
| 1822 | |
| 1823 | static void handleGameInfoRequest( const NetAddress* address, U32 key, U8 flags ) |
| 1824 | { |
| 1825 | // Do not respond unless there is a server running: |
| 1826 | if ( GNet->doesAllowConnections() ) |
| 1827 | { |
| 1828 | // Do not respond to offline queries if this is an online server: |
| 1829 | if ( flags & ServerFilter::OfflineQuery ) |
| 1830 | return; |
| 1831 | |
| 1832 | bool compressStrings = !( flags & ServerFilter::NoStringCompress ); |
| 1833 | BitStream *out = BitStream::getPacketStream(); |
| 1834 | |
| 1835 | out->write( U8( NetInterface::GameInfoResponse ) ); |
| 1836 | out->write( flags ); |
| 1837 | out->write( key ); |
| 1838 | |
| 1839 | if ( compressStrings ) { |
| 1840 | out->writeString( Con::getVariable( "Server::GameType" ) ); |
| 1841 | out->writeString( Con::getVariable( "Server::MissionType" ) ); |
| 1842 | out->writeString( Con::getVariable( "Server::MissionName" ) ); |
| 1843 | } |
| 1844 | else { |
| 1845 | writeCString( out, Con::getVariable( "Server::GameType" ) ); |
| 1846 | writeCString( out, Con::getVariable( "Server::MissionType" ) ); |
| 1847 | writeCString( out, Con::getVariable( "Server::MissionName" ) ); |
| 1848 | } |
| 1849 | |
| 1850 | U8 status = 0; |
| 1851 | #if defined(TORQUE_OS_LINUX) || defined(TORQUE_OS_OPENBSD) |
| 1852 | status |= ServerInfo::Status_Linux; |
| 1853 | #endif |
| 1854 | if ( Con::getBoolVariable( "Server::Dedicated" ) ) |
| 1855 | status |= ServerInfo::Status_Dedicated; |
| 1856 | if ( dStrlen( Con::getVariable( "Pref::Server::Password" ) ) ) |
| 1857 | status |= ServerInfo::Status_Passworded; |
| 1858 | out->write( status ); |
| 1859 | |
| 1860 | out->write( U8( Con::getIntVariable( "Server::PlayerCount" ) ) ); |
| 1861 | out->write( U8( Con::getIntVariable( "Pref::Server::MaxPlayers" ) ) ); |
| 1862 | out->write( U8( Con::getIntVariable( "Server::BotCount" ) ) ); |
| 1863 | out->write( U16( PlatformSystemInfo.processor.mhz ) ); |
| 1864 | if ( compressStrings ) |
| 1865 | out->writeString( Con::getVariable( "Pref::Server::Info" ) ); |
| 1866 | else |
| 1867 | writeCString( out, Con::getVariable( "Pref::Server::Info" ) ); |
| 1868 | writeLongCString( out, Con::evaluate( "onServerInfoQuery();" ) ); |
| 1869 | |
| 1870 | BitStream::sendPacketStream(address); |
| 1871 | } |
| 1872 | } |
| 1873 | |
| 1874 | //----------------------------------------------------------------------------- |
| 1875 |
no test coverage detected