| 1779 | //----------------------------------------------------------------------------- |
| 1780 | |
| 1781 | static void handleGamePingRequest( const NetAddress* address, U32 key, U8 flags ) |
| 1782 | { |
| 1783 | // Do not respond if a mission is not running: |
| 1784 | if ( GNet->doesAllowConnections() ) |
| 1785 | { |
| 1786 | // Do not respond if this is a single-player game: |
| 1787 | if ( dStricmp( Con::getVariable( "Server::ServerType" ), "SinglePlayer" ) == 0 ) |
| 1788 | return; |
| 1789 | |
| 1790 | // Do not respond to offline queries if this is an online server: |
| 1791 | if ( flags & ServerFilter::OfflineQuery ) |
| 1792 | return; |
| 1793 | |
| 1794 | // some banning code here (?) |
| 1795 | |
| 1796 | BitStream *out = BitStream::getPacketStream(); |
| 1797 | out->clearStringBuffer(); |
| 1798 | |
| 1799 | out->write( U8( NetInterface::GamePingResponse ) ); |
| 1800 | out->write( flags ); |
| 1801 | out->write( key ); |
| 1802 | if ( flags & ServerFilter::NoStringCompress ) |
| 1803 | writeCString( out, versionString ); |
| 1804 | else |
| 1805 | out->writeString( versionString ); |
| 1806 | out->write( GameConnection::CurrentProtocolVersion ); |
| 1807 | out->write( GameConnection::MinRequiredProtocolVersion ); |
| 1808 | out->write( getVersionNumber() ); |
| 1809 | |
| 1810 | // Enforce a 24-character limit on the server name: |
| 1811 | char serverName[25]; |
| 1812 | dStrncpy( serverName, Con::getVariable( "pref::Server::Name" ), 24 ); |
| 1813 | serverName[24] = 0; |
| 1814 | if ( flags & ServerFilter::NoStringCompress ) |
| 1815 | writeCString( out, serverName ); |
| 1816 | else |
| 1817 | out->writeString( serverName ); |
| 1818 | |
| 1819 | BitStream::sendPacketStream(address); |
| 1820 | } |
| 1821 | } |
| 1822 | |
| 1823 | //----------------------------------------------------------------------------- |
| 1824 |
no test coverage detected