@@ -28,7 +28,7 @@ void Diag::Begin ( void )
28
28
// obtain necessary environment variables and generate filepaths used for temporary files
29
29
GeneratePaths ();
30
30
31
- Log::Open ( files[0 ] ); // create the log file and open it
31
+ Log::Open ( files[FILE_LOG ] ); // create the log file and open it
32
32
33
33
Log::WriteStringToLog ( " MTADiag version" , VERSION, false );
34
34
Log::WriteStringToLog ( " by Towncivilian" );
@@ -43,7 +43,7 @@ void Diag::Begin ( void )
43
43
std::cout << std::endl;
44
44
45
45
// check whether DirectX is up to date (actually whether D3DX9_43.dll is present in %systemroot%\system32)
46
- if ( CheckForFile ( files[4 ].c_str () ) ) { std::cout << " DirectX is up-to-date." << std::endl << std::endl; }
46
+ if ( CheckForFile ( files[FILE_D3DX9_DLL ].c_str () ) ) { std::cout << " DirectX is up-to-date." << std::endl << std::endl; }
47
47
else { UpdateDirectX (); DXUpdated = 1 ; }
48
48
49
49
// remove any compatibility mode settings on gta_sa.exe and/or Multi Theft Auto.exe
@@ -79,12 +79,12 @@ void Diag::Begin ( void )
79
79
};
80
80
#endif
81
81
// check if MTA version matches the latest auto-update nightly
82
- if ( Curl::DownloadFile ( MTAVerURL, files[1 ].c_str () ) ) // download the version appropriation HTML
82
+ if ( Curl::DownloadFile ( MTAVerURL, files[FILE_TEMP ].c_str () ) ) // download the version appropriation HTML
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
86
// the version appropriation HTML has a 15 char string lacking two trailing zeros
87
- if ( FindInFile ( files[1 ].c_str (), ( MTAVersionTrim ) ) ) // look for the current MTA version string in it
87
+ if ( FindInFile ( files[FILE_TEMP ].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
90
90
{
@@ -113,7 +113,7 @@ void Diag::Begin ( void )
113
113
Log::WriteStringToLog ( " D3D9.dll present: " , D3D9Present );
114
114
115
115
// is DirectX up-to-date? (D3DX9_43.dll present)
116
- std::string DirectXState = ( CheckForFile ( files[4 ] ) ) ? " Yes" : " No" ;
116
+ std::string DirectXState = ( CheckForFile ( files[FILE_D3DX9_DLL ] ) ) ? " Yes" : " No" ;
117
117
Log::WriteStringToLog ( " DirectX up-to-date: " , DirectXState );
118
118
if ( DXUpdated == 1 )
119
119
Log::WriteStringToLog ( " DirectX was updated: Yes" );
@@ -207,7 +207,7 @@ void Diag::Begin ( void )
207
207
// upload to PasteBin
208
208
std::cout << " Log file generated. Uploading to Pastebin..." << std::endl;
209
209
210
- PasteBinResult = Curl::CreateMTAPasteBin ( files[0 ], logFileName ); // store the HTTP POST result into PasteBinResult
210
+ PasteBinResult = Curl::CreateMTAPasteBin ( files[FILE_LOG ], logFileName ); // store the HTTP POST result into PasteBinResult
211
211
212
212
// upload successful; copy URL to clipboard
213
213
if ( HasDigits ( PasteBinResult ) && !( strstr ( PasteBinResult.c_str (), " DOCTYPE" ) ) && !( strstr ( PasteBinResult.c_str (), " error" ) ) )
@@ -229,7 +229,7 @@ void Diag::Begin ( void )
229
229
std::cout << " Error code: \" " << PasteBinResult << " \" " << std::endl;
230
230
std::cout << " Please paste the contents of the opened Wordpad window at https://pastebin.mtasa.com" << std::endl;
231
231
std::cout << " Include the MTA Pastebin link in your forum post." << std::endl << std::endl;
232
- ShellExecute ( NULL , " open" , " wordpad.exe" , files[0 ].c_str (), NULL , SW_SHOW );
232
+ ShellExecute ( NULL , " open" , " wordpad.exe" , files[FILE_LOG ].c_str (), NULL , SW_SHOW );
233
233
}
234
234
}
235
235
@@ -243,7 +243,7 @@ void Diag::Cleanup ( bool deleteLog )
243
243
if ( deleteLog ) // do we need to delete our log? (if MTADiag quit prior to completing diagnostics)
244
244
{
245
245
Log::Close (); // close the log file for writing
246
- remove ( files[0 ].c_str () ); // remove the MTADiag log
246
+ remove ( files[FILE_LOG ].c_str () ); // remove the MTADiag log
247
247
}
248
248
}
249
249
@@ -449,11 +449,11 @@ void Diag::UpdateMTA ( void )
449
449
}
450
450
451
451
#ifndef SKIPUPDATE
452
- if ( Curl::DownloadFile ( url, files[2 ].c_str () ) ) // if the download was successful, open the installer
452
+ if ( Curl::DownloadFile ( url, files[FILE_NIGHTLY_INSTALLER ].c_str () ) ) // if the download was successful, open the installer
453
453
{
454
454
std::cout << std::endl << " Launching the installer..." << std::endl;
455
455
std::cout << " Run MTA once the installer has finished to see if it works now." << std::endl;
456
- system ( files[2 ].c_str () );
456
+ system ( files[FILE_NIGHTLY_INSTALLER ].c_str () );
457
457
}
458
458
else // if the download failed, open a browser window to start the download of the nightly
459
459
{
@@ -511,20 +511,20 @@ void Diag::UpdateDirectX ( void )
511
511
void Diag::DoSystemCommandWithOutput ( std::string command )
512
512
{
513
513
Log::WriteStringToLog ( " ----------------------------------------------------------------------------------" );
514
- int iCommandReturn = system ( ( command + files[1 ] ).c_str () ); // do the command
514
+ int iCommandReturn = system ( ( command + files[FILE_TEMP ] ).c_str () ); // do the command
515
515
516
516
std::stringstream ss;
517
517
ss << command << " (returned " << iCommandReturn << " )" ;
518
518
519
- Log::WriteFileToLog ( files[1 ], ss.str () ); // write the result to the log file with the passed command argument as a description
519
+ Log::WriteFileToLog ( files[FILE_TEMP ], ss.str () ); // write the result to the log file with the passed command argument as a description
520
520
}
521
521
522
522
void Diag::QueryWMIC ( std::string arg1, std::string arg2, std::string arg3, std::string arg4 )
523
523
{
524
524
std::string WMIC;
525
525
std::stringstream ss; // create a stringstream
526
526
527
- ss << " wmic " << arg1 << " " << arg2 << " " << arg3 << " " << arg4 << " >" << files[3 ].c_str (); // wmic <arg1> <arg2> <arg3> <arg4>
527
+ ss << " wmic " << arg1 << " " << arg2 << " " << arg3 << " " << arg4 << " >" << files[FILE_WMIC_UNI ].c_str (); // wmic <arg1> <arg2> <arg3> <arg4>
528
528
WMIC = ss.str ();
529
529
530
530
// clear the stringstream
@@ -533,19 +533,19 @@ void Diag::QueryWMIC ( std::string arg1, std::string arg2, std::string arg3, std
533
533
534
534
system ( WMIC.c_str () ); // do it
535
535
536
- ConvertUnicodeToASCII ( files[3 ], files[1 ] ); // convert the Unicode-encoded result to ASCII for proper display in the log file
536
+ ConvertUnicodeToASCII ( files[FILE_WMIC_UNI ], files[FILE_TEMP ] ); // convert the Unicode-encoded result to ASCII for proper display in the log file
537
537
538
- remove ( files[3 ].c_str () ); // delete the Unicode-encoded log file
538
+ remove ( files[FILE_WMIC_UNI ].c_str () ); // delete the Unicode-encoded log file
539
539
540
- Log::WriteFileToLog ( files[1 ], ( " WMIC " + arg1 + " " + arg2 + " " + arg3 + " " + arg4 ) ); // write the result to the log file with a description
540
+ Log::WriteFileToLog ( files[FILE_TEMP ], ( " WMIC " + arg1 + " " + arg2 + " " + arg3 + " " + arg4 ) ); // write the result to the log file with a description
541
541
}
542
542
543
543
void Diag::GetDir ( std::string directory )
544
544
{
545
545
std::string dirPath;
546
546
std::stringstream ss; // create a stringstream
547
547
548
- ss << " dir \" " << directory << " \" >\" " << files[1 ].c_str () << " \" " ; // dir "<filepath>"
548
+ ss << " dir \" " << directory << " \" >\" " << files[FILE_TEMP ].c_str () << " \" " ; // dir "<filepath>"
549
549
dirPath = ss.str ();
550
550
551
551
// clear the stringstream
@@ -554,5 +554,5 @@ void Diag::GetDir ( std::string directory )
554
554
555
555
system ( dirPath.c_str () ); // do it
556
556
557
- Log::WriteFileToLog ( files[1 ].c_str (), ( directory + " directory listing" ) ); // write the result to the log file with a description
557
+ Log::WriteFileToLog ( files[FILE_TEMP ].c_str (), ( directory + " directory listing" ) ); // write the result to the log file with a description
558
558
}
0 commit comments