| 1145 | //----------------------------------------------------------------------------- |
| 1146 | |
| 1147 | static void processMasterServerQuery( U32 session ) |
| 1148 | { |
| 1149 | if ( session != gPingSession || !sgServerQueryActive ) |
| 1150 | return; |
| 1151 | |
| 1152 | if ( !gGotFirstListPacket ) |
| 1153 | { |
| 1154 | bool keepGoing = true; |
| 1155 | U32 time = Platform::getVirtualMilliseconds(); |
| 1156 | char addressString[256]; |
| 1157 | |
| 1158 | if ( gMasterServerPing.time + gMasterServerTimeout < time ) |
| 1159 | { |
| 1160 | Net::addressToString( &gMasterServerPing.address, addressString ); |
| 1161 | if ( !gMasterServerPing.tryCount ) |
| 1162 | { |
| 1163 | // The query timed out. |
| 1164 | Con::printf( "Server list request to %s timed out.", addressString ); |
| 1165 | |
| 1166 | // Remove this server from the list: |
| 1167 | for ( U32 i = 0; i < gMasterServerList.size(); i++ ) |
| 1168 | { |
| 1169 | if ( Net::compareAddresses( &gMasterServerList[i].address, &gMasterServerPing.address ) ) |
| 1170 | { |
| 1171 | gMasterServerList.erase( i ); |
| 1172 | break; |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | // Pick a new master server to try: |
| 1177 | keepGoing = pickMasterServer(); |
| 1178 | if ( keepGoing ) |
| 1179 | { |
| 1180 | Con::executef( "onServerQueryStatus", "update", "Switching master servers...", "0" ); |
| 1181 | Net::addressToString( &gMasterServerPing.address, addressString ); |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | if ( keepGoing ) |
| 1186 | { |
| 1187 | gMasterServerPing.tryCount--; |
| 1188 | gMasterServerPing.time = time; |
| 1189 | gMasterServerPing.key = gKey++; |
| 1190 | |
| 1191 | // Send a request to the master server for the server list: |
| 1192 | BitStream *out = BitStream::getPacketStream(); |
| 1193 | out->clearStringBuffer(); |
| 1194 | |
| 1195 | out->write( U8( NetInterface::MasterServerListRequest ) ); |
| 1196 | |
| 1197 | out->write( U8( sActiveFilter.queryFlags) ); |
| 1198 | out->write( ( gMasterServerPing.session << 16 ) | ( gMasterServerPing.key & 0xFFFF ) ); |
| 1199 | out->write( U8( 255 ) ); |
| 1200 | |
| 1201 | writeCString( out, sActiveFilter.gameType ); |
| 1202 | writeCString( out, sActiveFilter.missionType ); |
| 1203 | out->write( sActiveFilter.minPlayers ); |
| 1204 | out->write( sActiveFilter.maxPlayers ); |
no test coverage detected