| 1001 | //----------------------------------------------------------------------------- |
| 1002 | |
| 1003 | static void processMasterServerQuery( U32 session ) |
| 1004 | { |
| 1005 | if ( session != gPingSession || !sgServerQueryActive ) |
| 1006 | return; |
| 1007 | |
| 1008 | if ( !gGotFirstListPacket ) |
| 1009 | { |
| 1010 | bool keepGoing = true; |
| 1011 | U32 time = Platform::getVirtualMilliseconds(); |
| 1012 | char addressString[256]; |
| 1013 | |
| 1014 | if ( gMasterServerPing.time + gMasterServerTimeout < time ) |
| 1015 | { |
| 1016 | Net::addressToString( &gMasterServerPing.address, addressString ); |
| 1017 | if ( !gMasterServerPing.tryCount ) |
| 1018 | { |
| 1019 | // The query timed out. |
| 1020 | Con::printf( "Server list request to %s timed out.", addressString ); |
| 1021 | |
| 1022 | // Remove this server from the list: |
| 1023 | for ( U32 i = 0; i < (U32)gMasterServerList.size(); i++ ) |
| 1024 | { |
| 1025 | if ( Net::compareAddresses( &gMasterServerList[i].address, &gMasterServerPing.address ) ) |
| 1026 | { |
| 1027 | gMasterServerList.erase( i ); |
| 1028 | break; |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | // Pick a new master server to try: |
| 1033 | keepGoing = pickMasterServer(); |
| 1034 | if ( keepGoing ) |
| 1035 | { |
| 1036 | Con::executef( 4, "onServerQueryStatus", "update", "Switching master servers...", "0" ); |
| 1037 | Net::addressToString( &gMasterServerPing.address, addressString ); |
| 1038 | } |
| 1039 | } |
| 1040 | |
| 1041 | if ( keepGoing ) |
| 1042 | { |
| 1043 | gMasterServerPing.tryCount--; |
| 1044 | gMasterServerPing.time = time; |
| 1045 | gMasterServerPing.key = gKey++; |
| 1046 | |
| 1047 | // Send a request to the master server for the server list: |
| 1048 | BitStream *out = BitStream::getPacketStream(); |
| 1049 | |
| 1050 | out->write( U8( NetInterface::MasterServerListRequest ) ); |
| 1051 | |
| 1052 | out->write( U8( sActiveFilter.queryFlags) ); |
| 1053 | out->write( ( gMasterServerPing.session << 16 ) | ( gMasterServerPing.key & 0xFFFF ) ); |
| 1054 | out->write( U8( 255 ) ); |
| 1055 | |
| 1056 | writeCString( out, sActiveFilter.gameType ); |
| 1057 | writeCString( out, sActiveFilter.missionType ); |
| 1058 | out->write( sActiveFilter.minPlayers ); |
| 1059 | out->write( sActiveFilter.maxPlayers ); |
| 1060 | out->write( sActiveFilter.regionMask ); |
no test coverage detected