@@ -59,16 +59,16 @@ void Diag::Begin ( void )
59
59
std::cout << " Checking for missing GTA files, please wait..." << std::endl;
60
60
61
61
for ( unsigned int i = 0 ; i < ( sizeof ( fileList ) / sizeof ( fileList[0 ] ) ); i++ )
62
- {
63
- std::string szFilename = fileList[i].szFilename ;
62
+ {
63
+ std::string szFilename = fileList[i].szFilename ;
64
64
65
65
if ( !( CheckForFile ( GTAPath + szFilename ) ) )
66
66
{
67
67
std::cout << " Missing GTA file: " << fileList[i].szFilename << std::endl; // output any messed up file
68
68
// bQuit = true; // we need to quit since the user's GTA install is probably screwed up
69
69
}
70
70
std::cout << " \r Checking " << ( i + 1 ) << " out of " << ( sizeof ( fileList ) / sizeof ( fileList[0 ] ) ) << " ..." ;
71
- }
71
+ }
72
72
std::cout << std::endl;
73
73
if ( bQuit )
74
74
{
@@ -83,7 +83,7 @@ void Diag::Begin ( void )
83
83
{
84
84
std::string MTAVersionTrim = MTAVersion; // copy the MTAVersion string
85
85
MTAVersionTrim.resize ( 15 ); // trim the MTAVersion string stored in registry to 15 characters
86
- // the version appropriation HTML has a 15 char string lacking two trailing zeros
86
+ // the version appropriation HTML has a 15 char string lacking two trailing zeros
87
87
if ( FindInFile ( files[1 ].c_str (), ( MTAVersionTrim ) ) ) // look for the current MTA version string in it
88
88
std::cout << " MTA is up-to-date." << std::endl << std::endl; // we've found it, hooray, we don't need to update MTA
89
89
else
@@ -127,9 +127,9 @@ void Diag::Begin ( void )
127
127
std::cout << " Checking for modified or nonstandard GTA files, please wait..." << std::endl;
128
128
129
129
for ( unsigned int i = 0 ; i < ( sizeof ( fileList ) / sizeof ( fileList[0 ] ) ); i++ )
130
- {
130
+ {
131
131
std::string szMd5 = fileList[i].szMd5 ;
132
- std::string szFilename = fileList[i].szFilename ;
132
+ std::string szFilename = fileList[i].szFilename ;
133
133
134
134
if ( !( CompareFileMD5 ( szMd5, ( GTAPath + szFilename ) ) ) )
135
135
{
@@ -141,7 +141,7 @@ void Diag::Begin ( void )
141
141
Log::WriteStringToLog ( " " );
142
142
}
143
143
std::cout << " \r Checking " << ( i + 1 ) << " out of " << ( sizeof ( fileList ) / sizeof ( fileList[0 ] ) ) << " ..." ;
144
- }
144
+ }
145
145
std::cout << std::endl;
146
146
#endif
147
147
// collect more information and output to log file
@@ -159,11 +159,11 @@ void Diag::Begin ( void )
159
159
// write some of MTA's logs to our log
160
160
Log::WriteFileToLog ( MTAPath + " \\ MTA\\ core.log" , " core.log" );
161
161
162
- // 1.4
162
+ // 1.4
163
163
Log::WriteFileToLog ( MTAPath + " \\ MTA\\ logfile.txt" , " logfile.txt" );
164
164
Log::WriteFileToLog ( MTAPath + " \\ MTA\\ logfile_old.txt" , " logfile_old.txt" );
165
165
Log::WriteFileToLog ( MTAPath + " \\ MTA\\ CEGUI.log" , " CEGUI.log" );
166
- // 1.5
166
+ // 1.5
167
167
Log::WriteFileToLog ( MTAPath + " \\ MTA\\ logs\\ logfile.txt" , " logfile.txt" );
168
168
Log::WriteFileToLog ( MTAPath + " \\ MTA\\ logs\\ logfile.txt.1" , " logfile.txt.1" );
169
169
Log::WriteFileToLog ( MTAPath + " \\ MTA\\ logs\\ CEGUI.log" , " CEGUI.log" );
@@ -335,14 +335,23 @@ void Diag::UserPickVersion ( void )
335
335
std::cout << " [" << i << " ] 1." << i << std::endl;
336
336
}
337
337
// have the user pick between the versions
338
+ bool success;
338
339
do {
340
+ success = true ;
339
341
std::cout << " Enter version choice: " ;
340
342
std::cin >> MTAVerChoice;
341
343
342
- if ( MTAVersionsInstalled[MTAVerChoice].empty () || MTAVerChoice > CUR_MTA_VERSIONS )
344
+ if ( std::cin.fail () ) {
345
+ std::cerr << " Invalid choice entered." << std::endl;
346
+ std::cin.clear ();
347
+ std::cin.ignore ( std::numeric_limits<std::streamsize>::max (), ' \n ' );
348
+ success = false ;
349
+ } else if ( MTAVersionsInstalled[MTAVerChoice].empty () || MTAVerChoice > CUR_MTA_VERSIONS ) {
343
350
std::cout << " Invalid choice entered." << std::endl;
351
+ success = false ;
352
+ }
344
353
345
- } while ( MTAVersionsInstalled[MTAVerChoice]. empty () || MTAVerChoice > CUR_MTA_VERSIONS );
354
+ } while ( !success );
346
355
}
347
356
348
357
std::string Diag::GetMTAPath ( void )
0 commit comments