MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ValidatePureServerChecksums

Method ValidatePureServerChecksums

neo/framework/async/AsyncClient.cpp:1380–1468  ·  view source on GitHub ↗

================== idAsyncClient::ValidatePureServerChecksums ================== */

Source from the content-addressed store, hash-verified

1378==================
1379*/
1380bool 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 }

Callers

nothing calls this directly

Calls 15

vaFunction · 0.85
BufferCommandTextMethod · 0.80
SetRestartChecksumsMethod · 0.80
GetIntegerMethod · 0.80
Sys_NetAdrToStringFunction · 0.50
ReadIntMethod · 0.45
WarningMethod · 0.45
GetStringMethod · 0.45
GetLanguageDictMethod · 0.45
c_strMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected