20
20
// #define SKIPDXDIAG
21
21
// #define SKIPFILECHECK
22
22
// #define DEBUGOUTPUT // output contents of files vector
23
+ #define SKIP_MTA_UPDATE // Disabled until status page is fixed
23
24
24
25
std::vector<std::string> Diag::files;
25
26
@@ -32,6 +33,7 @@ void Diag::Begin ( void )
32
33
33
34
Log::WriteStringToLog ( " MTADiag version" , VERSION, false );
34
35
Log::WriteStringToLog ( " by Towncivilian" );
36
+ std::cout << " MTADiag version " VERSION << std::endl;
35
37
36
38
// poll all currently installed MTA versions; if there is more than one installed, ask the user to pick one
37
39
if ( !PollMTAVersions () ) // PollMTAVersions will return true if there is only one version of MTA installed
@@ -78,6 +80,7 @@ void Diag::Begin ( void )
78
80
exit ( EXIT_FAILURE ); // exit
79
81
};
80
82
#endif
83
+ #ifndef SKIP_MTA_UPDATE
81
84
// check if MTA version matches the latest auto-update nightly
82
85
if ( Curl::DownloadFile ( MTAVerURL, files[FILE_TEMP].c_str () ) ) // download the version appropriation HTML
83
86
{
@@ -92,6 +95,7 @@ void Diag::Begin ( void )
92
95
UpdateMTA (); // update MTA to latest nightly / unstable build, depending on MTA's major version
93
96
}
94
97
}
98
+ #endif
95
99
96
100
// write some information to the log file
97
101
Log::WriteStringToLog ( " MTA path: " , MTAPath );
@@ -284,6 +288,22 @@ void Diag::GeneratePaths ( void )
284
288
bQuit = false ; // initialize quit bool, used in GTA files checking
285
289
MTAUpdated = false ; // initialize MTAUpdated bool
286
290
291
+ // Try to use 'MTA San Andreas All\MTADiag' as a temp dir first, so non admin can peek at it
292
+ {
293
+ std::string altTempDir = programData + " \\ MTA San Andreas All\\ MTADiag" ;
294
+ SHCreateDirectoryEx ( NULL , altTempDir.c_str (), NULL );
295
+ // Check can write there
296
+ std::string altTempDirTest = altTempDir + " \\ test.txt" ;
297
+ std::ofstream file;
298
+ file.open ( altTempDirTest.c_str (), std::ios::out );
299
+ if ( file )
300
+ {
301
+ tempDir = altTempDir;
302
+ file.close ();
303
+ remove ( altTempDirTest.c_str () );
304
+ }
305
+ }
306
+
287
307
// generate MTADiag log file path
288
308
std::stringstream ss;
289
309
@@ -479,7 +499,7 @@ void Diag::UpdateMTA ( void )
479
499
{
480
500
std::cout << std::endl << " Launching the installer..." << std::endl;
481
501
std::cout << " Run MTA once the installer has finished to see if it works now." << std::endl;
482
- system ( files[FILE_NIGHTLY_INSTALLER].c_str () );
502
+ system ( QuoteFilename ( files[FILE_NIGHTLY_INSTALLER] ) .c_str () );
483
503
}
484
504
else // if the download failed, open a browser window to start the download of the nightly
485
505
{
@@ -521,7 +541,7 @@ void Diag::UpdateDirectX ( void )
521
541
if ( Curl::DownloadFile ( DXWebSetupURL.c_str (), DXWebSetupPath.c_str () ) ) // success! open the file
522
542
{
523
543
std::cout << std::endl << " Follow the instructions to update DirectX." << std::endl << std::endl;
524
- system ( DXWebSetupPath.c_str () );
544
+ system ( QuoteFilename ( DXWebSetupPath ) .c_str () );
525
545
}
526
546
else // failure; open a browser window to start the download of DXWebSetup
527
547
{
@@ -613,7 +633,14 @@ void Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWOR
613
633
else
614
634
{
615
635
// Apply time limit for command to complete
616
- DWORD status = WaitForSingleObject ( pi.hProcess , maxTimeMs );
636
+ DWORD status = 1 ;
637
+ for ( unsigned int i = 0 ; i < maxTimeMs ; i += 100 )
638
+ {
639
+ status = WaitForSingleObject ( pi.hProcess , 100 );
640
+ if ( status != WAIT_TIMEOUT )
641
+ break ;
642
+ ProgressBarInc ();
643
+ }
617
644
if ( status == WAIT_TIMEOUT )
618
645
{
619
646
TerminateProcess ( pi.hProcess , 1 );
0 commit comments