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

Function processServerListPackets

engine/source/network/serverQuery.cc:1224–1288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1222//-----------------------------------------------------------------------------
1223
1224static void processServerListPackets( U32 session )
1225{
1226 if ( session != gPingSession || !sgServerQueryActive )
1227 return;
1228
1229 U32 currentTime = Platform::getVirtualMilliseconds();
1230
1231 // Loop through the packet status list and resend packet requests where necessary:
1232 for ( U32 i = 0; i < (U32)gPacketStatusList.size(); i++ )
1233 {
1234 PacketStatus &p = gPacketStatusList[i];
1235 if ( p.time + gPacketTimeout < currentTime )
1236 {
1237 if ( !p.tryCount )
1238 {
1239 // Packet timed out :(
1240 Con::printf( "Server list packet #%d timed out.", p.getIndex() + 1 );
1241 gPacketStatusList.erase( i );
1242 }
1243 else
1244 {
1245 // Try again...
1246 Con::printf( "Rerequesting server list packet #%d...", p.getIndex() + 1 );
1247 p.tryCount--;
1248 p.time = currentTime;
1249 p.key = gKey++;
1250
1251 BitStream *out = BitStream::getPacketStream();
1252 bool extendedPacket = (sActiveFilter.queryFlags & ServerFilter::NewStyleResponse) != 0;
1253
1254
1255 if ( extendedPacket )
1256 out->write( U8( NetInterface::MasterServerExtendedListRequest ) );
1257 else
1258 out->write( U8( NetInterface::MasterServerListRequest ) );
1259
1260 out->write( U8( sActiveFilter.queryFlags ) ); // flags
1261 out->write( ( session << 16) | ( p.key & 0xFFFF ) );
1262
1263 if ( extendedPacket )
1264 out->write( p.getOldIndex() ); // packet index
1265 else
1266 out->write( p.getIndex() ); // packet index
1267
1268 out->write( U8( 0 ) ); // game type
1269 out->write( U8( 0 ) ); // mission type
1270 out->write( U8( 0 ) ); // minPlayers
1271 out->write( U8( 0 ) ); // maxPlayers
1272 out->write( U32( 0 ) ); // region mask
1273 out->write( U32( 0 ) ); // version
1274 out->write( U8( 0 ) ); // filter flags
1275 out->write( U8( 0 ) ); // max bots
1276 out->write( U16( 0 ) ); // min CPU
1277 out->write( U8( 0 ) ); // buddy count
1278
1279 BitStream::sendPacketStream(&gMasterServerQueryAddress);
1280 }
1281 }

Callers 3

processMethod · 0.85

Calls 10

printfFunction · 0.85
getRootGroupFunction · 0.85
getCurrentTimeFunction · 0.85
processPingsAndQueriesFunction · 0.85
getOldIndexMethod · 0.80
postEventFunction · 0.50
sizeMethod · 0.45
getIndexMethod · 0.45
eraseMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected