@@ -222,73 +222,6 @@ bool CResource::CallExportedFunction ( const char * szFunctionName, CLuaArgument
222
222
}
223
223
224
224
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
-
292
225
void CResource::AddPendingFileDownload ( const SString& strUrl, const SString& strFilename, double dDownloadSize )
293
226
{
294
227
SPendingFileDownload item;
@@ -395,7 +328,7 @@ void CResource::Load ( void )
395
328
}
396
329
else
397
330
{
398
- HandleDownloadedFileTrouble ( pResourceFile, true );
331
+ HandleDownloadedFileTrouble ( pResourceFile );
399
332
}
400
333
DECLARE_PROFILER_SECTION ( OnPostLoadScript )
401
334
}
@@ -405,16 +338,10 @@ void CResource::Load ( void )
405
338
// Check the file contents
406
339
if ( CChecksum::GenerateChecksumFromFile ( pResourceFile->GetName () ) == pResourceFile->GetServerChecksum () )
407
340
{
408
- SString strError = " " ;
409
- bool bIsBad = CheckFileForCorruption ( pResourceFile->GetName ( ), strError );
410
- if ( bIsBad )
411
- {
412
- HandleDownloadedFileTrouble ( pResourceFile, false , strError );
413
- }
414
341
}
415
342
else
416
343
{
417
- HandleDownloadedFileTrouble ( pResourceFile, true , " " );
344
+ HandleDownloadedFileTrouble ( pResourceFile );
418
345
}
419
346
}
420
347
}
@@ -564,28 +491,15 @@ void CResource::AddToElementGroup ( CClientEntity* pElement )
564
491
//
565
492
// Handle when things go wrong
566
493
//
567
- void CResource::HandleDownloadedFileTrouble ( CResourceFile* pResourceFile, bool bCRCMismatch, const SString &strAppendix )
494
+ void CResource::HandleDownloadedFileTrouble ( CResourceFile* pResourceFile )
568
495
{
569
496
// Compose message
570
497
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 " ;
581
500
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);
589
503
590
504
// If using external HTTP server, reconnect and use internal one
591
505
if ( g_pClientGame->IsUsingExternalHTTPServer () && !g_pCore->ShouldUseInternalHTTPServer () )
0 commit comments