MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / handleGamePingRequest

Function handleGamePingRequest

Engine/source/app/net/serverQuery.cpp:1781–1821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1779//-----------------------------------------------------------------------------
1780
1781static 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

Callers 1

handleInfoPacketMethod · 0.85

Calls 9

dStricmpFunction · 0.85
getVariableFunction · 0.85
writeCStringFunction · 0.85
getVersionNumberFunction · 0.85
dStrncpyFunction · 0.85
doesAllowConnectionsMethod · 0.80
clearStringBufferMethod · 0.80
writeMethod · 0.45
writeStringMethod · 0.45

Tested by

no test coverage detected