@@ -222,73 +222,6 @@ bool CResource::CallExportedFunction ( const char * szFunctionName, CLuaArgument
222222}
223223
224224
225- //
226- // Quick integrity check of png, dff and txd files
227- //
228- static bool CheckFileForCorruption ( const SString &strPath, SString &strAppendix )
229- {
230- const char * szExt = strPath.c_str () + max<long >( 0 , strPath.length () - 4 );
231- bool bIsBad = false ;
232-
233- if ( stricmp ( szExt, " .PNG" ) == 0 )
234- {
235- // Open the file
236- if ( FILE* pFile = fopen ( strPath.c_str (), " rb" ) )
237- {
238- // This is what the png header should look like
239- unsigned char pGoodHeader [8 ] = { 0x89 , 0x50 , 0x4E , 0x47 , 0x0D , 0x0A , 0x1A , 0x0A };
240-
241- // Load the header
242- unsigned char pBuffer [8 ] = { 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 };
243- fread ( pBuffer, 1 , 8 , pFile );
244-
245- // Check header integrity
246- if ( memcmp ( pBuffer, pGoodHeader, 8 ) )
247- bIsBad = true ;
248-
249- // Close the file
250- fclose ( pFile );
251- }
252- }
253- else
254- if ( stricmp ( szExt, " .TXD" ) == 0 || stricmp ( szExt, " .DFF" ) == 0 )
255- {
256- // Open the file
257- if ( FILE* pFile = fopen ( strPath.c_str (), " rb" ) )
258- {
259- struct {
260- long id;
261- long size;
262- long ver;
263- } header = {0 ,0 ,0 };
264-
265- // Load the first header
266- fread ( &header, 1 , sizeof (header), pFile );
267- long pos = sizeof (header);
268- long validSize = header.size + pos;
269-
270- // Step through the sections
271- while ( pos < validSize )
272- {
273- if ( fread ( &header, 1 , sizeof (header), pFile ) != sizeof (header) )
274- break ;
275- fseek ( pFile, header.size , SEEK_CUR );
276- pos += header.size + sizeof (header);
277- }
278-
279- // Check integrity
280- if ( pos != validSize )
281- bIsBad = true ;
282-
283- // Close the file
284- fclose ( pFile );
285- }
286- }
287-
288- return bIsBad;
289- }
290-
291-
292225void CResource::AddPendingFileDownload ( const SString& strUrl, const SString& strFilename, double dDownloadSize )
293226{
294227 SPendingFileDownload item;
@@ -395,7 +328,7 @@ void CResource::Load ( void )
395328 }
396329 else
397330 {
398- HandleDownloadedFileTrouble ( pResourceFile, true );
331+ HandleDownloadedFileTrouble ( pResourceFile );
399332 }
400333 DECLARE_PROFILER_SECTION ( OnPostLoadScript )
401334 }
@@ -405,16 +338,10 @@ void CResource::Load ( void )
405338 // Check the file contents
406339 if ( CChecksum::GenerateChecksumFromFile ( pResourceFile->GetName () ) == pResourceFile->GetServerChecksum () )
407340 {
408- SString strError = " " ;
409- bool bIsBad = CheckFileForCorruption ( pResourceFile->GetName ( ), strError );
410- if ( bIsBad )
411- {
412- HandleDownloadedFileTrouble ( pResourceFile, false , strError );
413- }
414341 }
415342 else
416343 {
417- HandleDownloadedFileTrouble ( pResourceFile, true , " " );
344+ HandleDownloadedFileTrouble ( pResourceFile );
418345 }
419346 }
420347 }
@@ -564,28 +491,15 @@ void CResource::AddToElementGroup ( CClientEntity* pElement )
564491//
565492// Handle when things go wrong
566493//
567- void CResource::HandleDownloadedFileTrouble ( CResourceFile* pResourceFile, bool bCRCMismatch, const SString &strAppendix )
494+ void CResource::HandleDownloadedFileTrouble ( CResourceFile* pResourceFile )
568495{
569496 // Compose message
570497 SString strMessage;
571- if ( bCRCMismatch )
572- {
573- if ( g_pClientGame->IsUsingExternalHTTPServer () )
574- strMessage += " External " ;
575- strMessage += " HTTP server file mismatch" ;
576- }
577- else
578- strMessage += " Invalid file" ;
579- SString strFilename = ExtractFilename ( PathConform ( pResourceFile->GetShortName () ) );
580- strMessage += SString ( " (%s) %s %s" , GetName (), *strFilename, *strAppendix );
498+ if ( g_pClientGame->IsUsingExternalHTTPServer () )
499+ strMessage += " External " ;
581500
582- if ( !bCRCMismatch )
583- {
584- // For corrupt files, log to the client console
585- g_pClientGame->TellServerSomethingImportant ( 1000 , strMessage, true );
586- g_pCore->GetConsole ()->Printf ( " Download error: %s" , *strMessage );
587- return ;
588- }
501+ SString strFilename = ExtractFilename ( PathConform ( pResourceFile->GetShortName () ) );
502+ strMessage += SString ( " HTTP server file mismatch (%s) %s" , GetName (), *strFilename);
589503
590504 // If using external HTTP server, reconnect and use internal one
591505 if ( g_pClientGame->IsUsingExternalHTTPServer () && !g_pCore->ShouldUseInternalHTTPServer () )
0 commit comments