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

Method VerifyChecksumMessage

neo/framework/async/AsyncServer.cpp:1873–1908  ·  view source on GitHub ↗

================== idAsyncServer::VerifyChecksumMessage ================== */

Source from the content-addressed store, hash-verified

1871==================
1872*/
1873bool idAsyncServer::VerifyChecksumMessage( int clientNum, const netadr_t *from, const idBitMsg &msg, idStr &reply ) {
1874 int i, numChecksums;
1875 int checksums[ MAX_PURE_PAKS ];
1876 int serverChecksums[ MAX_PURE_PAKS ];
1877
1878 // pak checksums, in a 0-terminated list
1879 numChecksums = 0;
1880 do {
1881 i = msg.ReadInt( );
1882 checksums[ numChecksums++ ] = i;
1883 // just to make sure a broken client doesn't crash us
1884 if ( numChecksums >= MAX_PURE_PAKS ) {
1885 common->Warning( "MAX_PURE_PAKS ( %d ) exceeded in idAsyncServer::ProcessPureMessage\n", MAX_PURE_PAKS );
1886 sprintf( reply, "#str_07144" );
1887 return false;
1888 }
1889 } while ( i );
1890 numChecksums--;
1891
1892 fileSystem->GetPureServerChecksums( serverChecksums );
1893 assert( serverChecksums[ 0 ] );
1894
1895 for ( i = 0; serverChecksums[ i ] != 0; i++ ) {
1896 if ( checksums[ i ] != serverChecksums[ i ] ) {
1897 common->DPrintf( "client %s: pak missing ( 0x%x )\n", from ? Sys_NetAdrToString( *from ) : va( "%d", clientNum ), serverChecksums[ i ] );
1898 sprintf( reply, "pak missing ( 0x%x )\n", serverChecksums[ i ] );
1899 return false;
1900 }
1901 }
1902 if ( checksums[ i ] != 0 ) {
1903 common->DPrintf( "client %s: extra pak file referenced ( 0x%x )\n", from ? Sys_NetAdrToString( *from ) : va( "%d", clientNum ), checksums[ i ] );
1904 sprintf( reply, "extra pak file referenced ( 0x%x )\n", checksums[ i ] );
1905 return false;
1906 }
1907 return true;
1908}
1909
1910/*
1911==================

Callers

nothing calls this directly

Calls 7

sprintfFunction · 0.85
vaFunction · 0.85
Sys_NetAdrToStringFunction · 0.50
ReadIntMethod · 0.45
WarningMethod · 0.45
DPrintfMethod · 0.45

Tested by

no test coverage detected