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

Method SetPureServerChecksums

neo/framework/FileSystem.cpp:2520–2614  ·  view source on GitHub ↗

===================== idFileSystemLocal::SetPureServerChecksums set the pure paks according to what the server asks if that's not possible, identify why and build an answer can be: loadedFileFromDir - some files were loaded from directories instead of paks (a restart in pure pak-only is required) missing/wrong checksums - some pak files would need to be installed/updated (downloaded for instan

Source from the content-addressed store, hash-verified

2518=====================
2519*/
2520fsPureReply_t idFileSystemLocal::SetPureServerChecksums( const int pureChecksums[ MAX_PURE_PAKS ], int missingChecksums[ MAX_PURE_PAKS ] ) {
2521 pack_t *pack;
2522 int i, j, imissing;
2523 bool success = true;
2524 bool canPrepend = true;
2525
2526 imissing = 0;
2527 missingChecksums[ 0 ] = 0;
2528
2529 if ( pureChecksums[ 0 ] == 0 ) {
2530 ClearPureChecksums();
2531 return PURE_OK;
2532 }
2533
2534 if ( !serverPaks.Num() ) {
2535 // there was no pure lockdown yet - lock to what we already have
2536 UpdatePureServerChecksums();
2537 }
2538 i = 0; j = 0;
2539 while ( pureChecksums[ i ] ) {
2540 if ( j < serverPaks.Num() && serverPaks[ j ]->checksum == pureChecksums[ i ] ) {
2541 canPrepend = false; // once you start matching into the list there is no prepending anymore
2542 i++; j++; // the pak is matched, is in the right order, continue..
2543 } else {
2544 pack = GetPackForChecksum( pureChecksums[ i ], true );
2545 if ( pack && pack->addon && !pack->addon_search ) {
2546 // this is an addon pack, and it's not on our current search list
2547 // setting success to false meaning that a restart including this addon is required
2548 if ( fs_debug.GetBool() ) {
2549 common->Printf( "pak %s checksumed 0x%x is on addon list. Restart required.\n", pack->pakFilename.c_str(), pack->checksum );
2550 }
2551 success = false;
2552 }
2553 if ( pack && pack->isNew ) {
2554 // that's a downloaded pack, we will need to restart
2555 if ( fs_debug.GetBool() ) {
2556 common->Printf( "pak %s checksumed 0x%x is a newly downloaded file. Restart required.\n", pack->pakFilename.c_str(), pack->checksum );
2557 }
2558 success = false;
2559 }
2560 if ( pack ) {
2561 if ( canPrepend ) {
2562 // we still have a chance
2563 if ( fs_debug.GetBool() ) {
2564 common->Printf( "prepend pak %s checksumed 0x%x at index %d\n", pack->pakFilename.c_str(), pack->checksum, j );
2565 }
2566 // NOTE: there is a light possibility this adds at the end of the list if UpdatePureServerChecksums didn't set anything
2567 serverPaks.Insert( pack, j );
2568 i++; j++; // continue..
2569 } else {
2570 success = false;
2571 if ( fs_debug.GetBool() ) {
2572 // verbose the situation
2573 if ( serverPaks.Find( pack ) ) {
2574 common->Printf( "pak %s checksumed 0x%x is in the pure list at wrong index. Current index is %d, found at %d\n", pack->pakFilename.c_str(), pack->checksum, j, serverPaks.FindIndex( pack ) );
2575 } else {
2576 common->Printf( "pak %s checksumed 0x%x can't be added to pure list because of search order\n", pack->pakFilename.c_str(), pack->checksum );
2577 }

Callers 1

Calls 7

NumMethod · 0.45
GetBoolMethod · 0.45
PrintfMethod · 0.45
c_strMethod · 0.45
InsertMethod · 0.45
FindMethod · 0.45
FindIndexMethod · 0.45

Tested by

no test coverage detected