| 1378 | //----------------------------------------------------------------------------- |
| 1379 | |
| 1380 | static void handleMasterServerListResponse( BitStream* stream, U32 key, U8 /*flags*/ ) |
| 1381 | { |
| 1382 | U8 packetIndex, packetTotal; |
| 1383 | U32 i; |
| 1384 | U16 serverCount, port; |
| 1385 | U8 netNum[4]; |
| 1386 | char addressBuffer[256]; |
| 1387 | NetAddress addr; |
| 1388 | |
| 1389 | stream->read( &packetIndex ); |
| 1390 | // Validate the packet key: |
| 1391 | U32 packetKey = gMasterServerPing.key; |
| 1392 | if ( gGotFirstListPacket ) |
| 1393 | { |
| 1394 | for ( i = 0; i < (U32)gPacketStatusList.size(); i++ ) |
| 1395 | { |
| 1396 | if ( gPacketStatusList[i].index == packetIndex ) |
| 1397 | { |
| 1398 | packetKey = gPacketStatusList[i].key; |
| 1399 | break; |
| 1400 | } |
| 1401 | } |
| 1402 | } |
| 1403 | |
| 1404 | U32 testKey = ( gPingSession << 16 ) | ( packetKey & 0xFFFF ); |
| 1405 | if ( testKey != key ) |
| 1406 | return; |
| 1407 | |
| 1408 | stream->read( &packetTotal ); |
| 1409 | stream->read( &serverCount ); |
| 1410 | |
| 1411 | Con::printf( "Received server list packet %d of %d from the master server (%d servers).", ( packetIndex + 1 ), packetTotal, serverCount ); |
| 1412 | |
| 1413 | // Enter all of the servers in this packet into the ping list: |
| 1414 | for ( i = 0; i < serverCount; i++ ) |
| 1415 | { |
| 1416 | stream->read( &netNum[0] ); |
| 1417 | stream->read( &netNum[1] ); |
| 1418 | stream->read( &netNum[2] ); |
| 1419 | stream->read( &netNum[3] ); |
| 1420 | stream->read( &port ); |
| 1421 | |
| 1422 | dSprintf( addressBuffer, sizeof( addressBuffer ), "IP:%d.%d.%d.%d:%d", netNum[0], netNum[1], netNum[2], netNum[3], port ); |
| 1423 | Net::stringToAddress( addressBuffer, &addr ); |
| 1424 | pushPingRequest( &addr ); |
| 1425 | } |
| 1426 | |
| 1427 | // If this is the first list packet we have received, fill the packet status list |
| 1428 | // and start processing: |
| 1429 | if ( !gGotFirstListPacket ) |
| 1430 | { |
| 1431 | gGotFirstListPacket = true; |
| 1432 | gMasterServerQueryAddress = gMasterServerPing.address; |
| 1433 | U32 currentTime = Platform::getVirtualMilliseconds(); |
| 1434 | for ( i = 0; i < packetTotal; i++ ) |
| 1435 | { |
| 1436 | if ( i != packetIndex ) |
| 1437 | { |
no test coverage detected