Skip to content

Commit 0205e17

Browse files
committed
Check for missing GTA files first, then MD5sums later
1 parent 672a0ed commit 0205e17

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

MTADiag/Diag.cpp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,26 @@ void Diag::Begin ( void )
5454
// and I can't seem to query non-Wow6432Node keys - maybe I'm doing something wrong?
5555
if ( !bIsWOW64 ) { CompatRemoved2 = DeleteCompatibilityEntries ( CompatModeRegKey, HKEY_LOCAL_MACHINE ); }
5656

57-
// check for any modified or nonstandard GTA files
58-
std::cout << "Checking GTA files, please wait..." << std::endl;
57+
// check for any missing GTA files
58+
std::cout << "Checking for missing GTA files, please wait..." << std::endl;
5959

6060
for ( unsigned int i = 0; i < ( sizeof ( fileList ) / sizeof ( fileList[0] ) ); i++ )
6161
{
62-
std::string szMd5 = fileList[i].szMd5;
6362
std::string szFilename = fileList[i].szFilename;
6463

65-
if ( !( CompareFileMD5 ( szMd5, ( GTAPath + szFilename ) ) ) )
64+
if ( !( CheckForFile ( GTAPath + szFilename ) ) )
6665
{
67-
std::cout << "Nonstandard GTA file: " << fileList[i].szFilename << std::endl; // output any messed up file file
66+
std::cout << "Missing GTA file: " << fileList[i].szFilename << std::endl; // output any messed up file
6867
bQuit = true; // we need to quit since the user's GTA install is probably screwed up
6968
}
69+
std::cout << szFilename << std::endl;
70+
printf ( "Checking %i out of %i...\r", i, ( sizeof ( fileList ) / sizeof ( fileList[0] ) ) );
71+
fflush ( stdout );
7072
}
73+
std::cout << std::endl;
7174
if ( bQuit )
7275
{
73-
std::cout << "Your Grand Theft Auto installation is unclean." << std::endl << "Please reinstall GTA and see if MTA works then." << std::endl;
76+
std::cout << "Your Grand Theft Auto installation is missing one or more files." << std::endl << "Please reinstall GTA and see if MTA works then." << std::endl;
7477
Cleanup ( true ); // clean up any temporary files that might have been created, along with the MTADiag log
7578
system ( "pause" );
7679
exit ( EXIT_FAILURE ); // exit
@@ -121,6 +124,25 @@ void Diag::Begin ( void )
121124
Log::WriteStringToLog ( "Compat. mode deleted: Yes");
122125
Log::WriteStringToLog ( "" );
123126

127+
// check for any modified or nonstandard GTA files
128+
for ( unsigned int i = 0; i < ( sizeof ( fileList ) / sizeof ( fileList[0] ) ); i++ )
129+
{
130+
std::string szMd5 = fileList[i].szMd5;
131+
std::string szFilename = fileList[i].szFilename;
132+
133+
if ( !( CompareFileMD5 ( szMd5, ( GTAPath + szFilename ) ) ) )
134+
{
135+
std::cout << "Nonstandard GTA file: " << fileList[i].szFilename << std::endl;
136+
137+
Log::WriteStringToLog ( "Nonstandard GTA file: ", szFilename );
138+
Log::WriteStringToLog ( GetFileMD5 ( GTAPath + szFilename ) );
139+
Log::WriteStringToLog ( "Value should be: ", szMd5 );
140+
Log::WriteStringToLog ( "" );
141+
}
142+
printf ( "Checking %i out of %i...\r", i, ( sizeof ( fileList ) / sizeof ( fileList[0] ) ) );
143+
fflush ( stdout );
144+
}
145+
124146
// collect more information and output to log file
125147
std::cout << "Gathering information. Please wait..." << std::endl;
126148
ProgressBar ( 0 );
@@ -154,11 +176,9 @@ void Diag::Begin ( void )
154176

155177
ProgressBar ( 60 );
156178

157-
// get relevant MD5sums
179+
// get relevant MD5sum( s)
158180
Log::WriteStringToLog ( GetFileMD5 ( GTAPath + "\\gta_sa.exe" ) );
159181
Log::WriteStringToLog ( "Value should be: 170b3a9108687b26da2d8901c6948a18 (HOODLUM 1.0)" );
160-
Log::WriteStringToLog ( GetFileMD5 ( GTAPath + "\\models\\gta3.img" ) );
161-
Log::WriteStringToLog ( "Value should be: 9282e0df8d7eee3c4a49b44758dd694d" );
162182
Log::WriteStringToLog ( "" );
163183

164184
ProgressBar ( 80 );

MTADiag/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ bool CompareFileMD5 ( std::string MD5sum, std::string filename )
248248

249249
if ( fp == NULL ) // we can't open it
250250
{
251-
return ( false );
251+
return false;
252252
}
253253

254254
MD5 md5; // initialize MD5

0 commit comments

Comments
 (0)