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

Function handleGameInfoRequest

Engine/source/app/net/serverQuery.cpp:1976–2027  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

handleInfoPacketMethod · 0.85

Calls 11

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

Tested by

no test coverage detected