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

Method ProcessDownloadRequestMessage

neo/framework/async/AsyncServer.cpp:2653–2791  ·  view source on GitHub ↗

=============== idAsyncServer::ProcessDownloadRequestMessage =============== */

Source from the content-addressed store, hash-verified

2651===============
2652*/
2653void idAsyncServer::ProcessDownloadRequestMessage( const netadr_t from, const idBitMsg &msg ) {
2654 int challenge, clientId, iclient, numPaks, i;
2655 int dlPakChecksum;
2656 int dlSize[ MAX_PURE_PAKS ]; // sizes
2657 idStrList pakNames; // relative path
2658 idStrList pakURLs; // game URLs
2659 char pakbuf[ MAX_STRING_CHARS ];
2660 idStr paklist;
2661 byte msgBuf[ MAX_MESSAGE_SIZE ];
2662 byte tmpBuf[ MAX_MESSAGE_SIZE ];
2663 idBitMsg outMsg, tmpMsg;
2664 int dlRequest;
2665 int voidSlots = 0; // to count and verbose the right number of paks requested for downloads
2666
2667 challenge = msg.ReadInt();
2668 clientId = msg.ReadShort();
2669 dlRequest = msg.ReadInt();
2670
2671 if ( ( iclient = ValidateChallenge( from, challenge, clientId ) ) == -1 ) {
2672 return;
2673 }
2674
2675 if ( challenges[ iclient ].authState != CDK_PUREWAIT ) {
2676 common->DPrintf( "client %s: got download request message, not in CDK_PUREWAIT\n", Sys_NetAdrToString( from ) );
2677 return;
2678 }
2679
2680 pakNames.Append( pakbuf );
2681 numPaks = 1;
2682
2683 // read the checksums, build path names and pass that to the game code
2684 dlPakChecksum = msg.ReadInt();
2685 while ( dlPakChecksum ) {
2686 if ( !( dlSize[ numPaks ] = fileSystem->ValidateDownloadPakForChecksum( dlPakChecksum, pakbuf ) ) ) {
2687 // we pass an empty token to the game so our list doesn't get offset
2688 common->Warning( "client requested an unknown pak 0x%x", dlPakChecksum );
2689 pakbuf[ 0 ] = '\0';
2690 voidSlots++;
2691 }
2692 pakNames.Append( pakbuf );
2693 numPaks++;
2694 dlPakChecksum = msg.ReadInt();
2695 }
2696
2697 for ( i = 0; i < pakNames.Num(); i++ ) {
2698 if ( i > 0 ) {
2699 paklist += ";";
2700 }
2701 paklist += pakNames[ i ].c_str();
2702 }
2703
2704 // read the message and pass it to the game code
2705 common->DPrintf( "got download request for %d paks - %s\n", numPaks - voidSlots, paklist.c_str() );
2706
2707 outMsg.Init( msgBuf, sizeof( msgBuf ) );
2708 outMsg.WriteShort( CONNECTIONLESS_MESSAGE_ID );
2709 outMsg.WriteString( "downloadInfo" );
2710 outMsg.WriteInt( dlRequest );

Callers

nothing calls this directly

Calls 15

BeginWritingMethod · 0.80
GetRemainingSpaceMethod · 0.80
Sys_NetAdrToStringFunction · 0.50
ReadIntMethod · 0.45
ReadShortMethod · 0.45
DPrintfMethod · 0.45
AppendMethod · 0.45
WarningMethod · 0.45
NumMethod · 0.45
c_strMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected