================== idAsyncClient::ValidatePureServerChecksums ================== */
| 1378 | ================== |
| 1379 | */ |
| 1380 | bool idAsyncClient::ValidatePureServerChecksums( const netadr_t from, const idBitMsg &msg ) { |
| 1381 | int i, numChecksums, numMissingChecksums; |
| 1382 | int inChecksums[ MAX_PURE_PAKS ]; |
| 1383 | int missingChecksums[ MAX_PURE_PAKS ]; |
| 1384 | idBitMsg dlmsg; |
| 1385 | byte msgBuf[MAX_MESSAGE_SIZE]; |
| 1386 | |
| 1387 | // read checksums |
| 1388 | // pak checksums, in a 0-terminated list |
| 1389 | numChecksums = 0; |
| 1390 | do { |
| 1391 | i = msg.ReadInt( ); |
| 1392 | inChecksums[ numChecksums++ ] = i; |
| 1393 | // just to make sure a broken message doesn't crash us |
| 1394 | if ( numChecksums >= MAX_PURE_PAKS ) { |
| 1395 | common->Warning( "MAX_PURE_PAKS ( %d ) exceeded in idAsyncClient::ProcessPureMessage\n", MAX_PURE_PAKS ); |
| 1396 | return false; |
| 1397 | } |
| 1398 | } while ( i ); |
| 1399 | inChecksums[ numChecksums ] = 0; |
| 1400 | |
| 1401 | fsPureReply_t reply = fileSystem->SetPureServerChecksums( inChecksums, missingChecksums ); |
| 1402 | switch ( reply ) { |
| 1403 | case PURE_RESTART: |
| 1404 | // need to restart the filesystem with a different pure configuration |
| 1405 | cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" ); |
| 1406 | // restart with the right FS configuration and get back to the server |
| 1407 | clientState = CS_PURERESTART; |
| 1408 | fileSystem->SetRestartChecksums( inChecksums ); |
| 1409 | cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reloadEngine" ); |
| 1410 | return false; |
| 1411 | case PURE_MISSING: { |
| 1412 | |
| 1413 | idStr checksums; |
| 1414 | |
| 1415 | i = 0; |
| 1416 | while ( missingChecksums[ i ] ) { |
| 1417 | checksums += va( "0x%x ", missingChecksums[ i++ ] ); |
| 1418 | } |
| 1419 | numMissingChecksums = i; |
| 1420 | |
| 1421 | if ( idAsyncNetwork::clientDownload.GetInteger() == 0 ) { |
| 1422 | // never any downloads |
| 1423 | idStr message = va( common->GetLanguageDict()->GetString( "#str_07210" ), Sys_NetAdrToString( from ) ); |
| 1424 | |
| 1425 | if ( numMissingChecksums > 0 ) { |
| 1426 | message += va( common->GetLanguageDict()->GetString( "#str_06751" ), numMissingChecksums, checksums.c_str() ); |
| 1427 | } |
| 1428 | |
| 1429 | common->Printf( "%s", message.c_str() ); |
| 1430 | cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" ); |
| 1431 | session->MessageBox( MSG_OK, message, common->GetLanguageDict()->GetString( "#str_06735" ), true ); |
| 1432 | } else { |
| 1433 | if ( clientState >= CS_CONNECTED ) { |
| 1434 | // we are already connected, reconnect to negociate the paks in connectionless mode |
| 1435 | cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reconnect" ); |
| 1436 | return false; |
| 1437 | } |
nothing calls this directly
no test coverage detected