MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / handleGameInfoRequest

Function handleGameInfoRequest

engine/source/network/serverQuery.cc:1823–1872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1821//-----------------------------------------------------------------------------
1822
1823static 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

Callers 1

handleInfoPacketMethod · 0.85

Calls 10

getVariableFunction · 0.85
writeCStringFunction · 0.85
getBoolVariableFunction · 0.85
getIntVariableFunction · 0.85
writeLongCStringFunction · 0.85
evaluateFunction · 0.85
doesAllowConnectionsMethod · 0.80
dStrlenFunction · 0.50
writeMethod · 0.45
writeStringMethod · 0.45

Tested by

no test coverage detected