Skip to content

Commit e603227

Browse files
committed
Fixed accidental deletion of D3DX9_43.dll; fewer temporary files are generated
1 parent d6cfada commit e603227

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

MTADiag/Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
#include <vector>
2323
#include "Log.h"
2424

25-
#define VERSION "2.3.1"
25+
#define VERSION "2.3.2"
2626

2727
#endif

MTADiag/Diag.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void Diag::Begin ( void )
4444
OriginalMTAVersion = GetMTAVersion(); // store the original version to dump in the log file later on
4545

4646
// check whether DirectX is up to date (actually whether D3DX9_43.dll is present in %systemroot%\system32)
47-
if ( CheckForFile( files[5].c_str() ) ) { std::cout << "DirectX is up-to-date." << std::endl << std::endl; }
47+
if ( CheckForFile( files[4].c_str() ) ) { std::cout << "DirectX is up-to-date." << std::endl << std::endl; }
4848
else { UpdateDirectX(); DXUpdated = 1; }
4949

5050
// update MTA to latest nightly/unstable build, depending on the version
@@ -58,7 +58,7 @@ void Diag::Begin ( void )
5858
std::string D3D9Present = ( CheckForFile ( GTAPath + "\\D3D9.dll" ) ) ? "Yes" : "No";
5959
Log::WriteStringToLog ( "D3D9.dll present: ", D3D9Present );
6060

61-
std::string DirectXState = ( CheckForFile ( files[5] ) ) ? "Yes" : "No";
61+
std::string DirectXState = ( CheckForFile ( files[4] ) ) ? "Yes" : "No";
6262
Log::WriteStringToLog ( "DirectX up-to-date: ", DirectXState );
6363
if ( DXUpdated == 1 )
6464
Log::WriteStringToLog ( "DirectX was updated: Yes");
@@ -80,10 +80,10 @@ void Diag::Begin ( void )
8080

8181
QueryWMIC ( "Path", "Win32_VideoController", "Get" );
8282

83-
ExportRegKeyToFile ( CompatModeRegKey1, files[4] );
84-
TrimCompatabilityExport ( files[4] );
85-
ExportRegKeyToFile ( CompatModeRegKey2, files[4] );
86-
TrimCompatabilityExport ( files[4] );
83+
ExportRegKeyToFile ( CompatModeRegKey1 );
84+
TrimCompatabilityExport ( files[1] );
85+
ExportRegKeyToFile ( CompatModeRegKey2 );
86+
TrimCompatabilityExport ( files[1] );
8787

8888
GetDir ( ( MTAPath + "\\MTA" ) );
8989
GetDir ( GTAPath );
@@ -115,7 +115,7 @@ void Diag::Cleanup ( void )
115115
{
116116
// clean up after ourselves
117117
// start at 1 since 0 is the generated log's path; we still need that
118-
for (int i = 1; i < ( signed ) files.size(); i++)
118+
for (int i = 1; i < ( signed ) files.size() - 1; i++)
119119
remove ( files[i].c_str() );
120120
}
121121

@@ -138,12 +138,9 @@ void Diag::GeneratePaths ( void )
138138

139139
files.push_back ( tempDir + "\\" + logFileName + ".txt" ); // files [0] ...
140140
files.push_back ( tempDir + "\\tempoutput.txt" );
141-
files.push_back ( tempDir + "\\WMIC.txt" );
142-
files.push_back ( tempDir + "\\directory.txt" );
143-
files.push_back ( tempDir + "\\regexport.txt" );
144-
files.push_back ( systemRoot + "\\system32\\D3DX9_43.dll" );
145141
files.push_back ( tempDir + "\\MTANightly.exe" );
146142
files.push_back ( tempDir + "\\WMICUni.txt" );
143+
files.push_back ( systemRoot + "\\system32\\D3DX9_43.dll" );
147144

148145
#ifdef DEBUGOUTPUT
149146
for ( int i = 0; i < ( signed ) files.size(); i++ )
@@ -306,14 +303,14 @@ void Diag::UpdateMTA ( void )
306303
}
307304

308305
#ifndef SKIPUPDATE
309-
if ( Curl::DownloadFile (url, files[6].c_str() ) )
306+
if ( Curl::DownloadFile (url, files[2].c_str() ) )
310307
{
311-
std::ifstream ifile ( files[6].c_str() );
308+
std::ifstream ifile ( files[2].c_str() );
312309
if ( ifile )
313310
{
314311
std::cout << std::endl << "Launching the installer..." << std::endl;
315312
std::cout << "Run MTA once the installer has finished to see if it works now." << std::endl;
316-
system ( files[6].c_str() );
313+
system ( files[2].c_str() );
317314
}
318315
}
319316
else
@@ -341,9 +338,7 @@ void Diag::UpdateMTA ( void )
341338

342339
void Diag::UpdateDirectX ( void )
343340
{
344-
std::string DXWebSetupPath = tempDir;
345-
346-
DXWebSetupPath.append ( "\\dxwebsetup.exe" );
341+
std::string DXWebSetupPath = ( tempDir + "\\dxwebsetup.exe" );
347342

348343
std::string DXWebSetupURL = "http://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe";
349344

@@ -379,7 +374,7 @@ void Diag::QueryWMIC ( std::string arg1, std::string arg2, std::string arg3, std
379374
std::string WMIC;
380375
std::stringstream ss; // create a stringstream
381376

382-
ss << "wmic " << arg1 << " " << arg2 << " " << arg3 << " " << arg4 << " >" << files[7].c_str();
377+
ss << "wmic " << arg1 << " " << arg2 << " " << arg3 << " " << arg4 << " >" << files[3].c_str();
383378
WMIC = ss.str ();
384379

385380
// clear the stringstream
@@ -388,19 +383,19 @@ void Diag::QueryWMIC ( std::string arg1, std::string arg2, std::string arg3, std
388383

389384
system ( WMIC.c_str() );
390385

391-
ConvertUnicodeToASCII ( files[7], files[2] );
386+
ConvertUnicodeToASCII ( files[3], files[1] );
392387

393-
remove ( files[7].c_str() );
388+
remove ( files[3].c_str() );
394389

395-
Log::WriteFileToLog ( files[2], ( "WMIC " + arg1 + " " + arg2 + " " + arg3 + " " + arg4 ) );
390+
Log::WriteFileToLog ( files[1], ( "WMIC " + arg1 + " " + arg2 + " " + arg3 + " " + arg4 ) );
396391
}
397392

398393
void Diag::GetDir ( std::string directory )
399394
{
400395
std::string dirPath;
401396
std::stringstream ss; // create a stringstream
402397

403-
ss << "dir \"" << directory << "\" >\"" << files[3].c_str() << "\"";
398+
ss << "dir \"" << directory << "\" >\"" << files[1].c_str() << "\"";
404399
dirPath = ss.str();
405400

406401
// clear the stringstream
@@ -409,15 +404,15 @@ void Diag::GetDir ( std::string directory )
409404

410405
system ( dirPath.c_str() );
411406

412-
Log::WriteFileToLog ( files[3].c_str(), ( directory + " directory listing" ) );
407+
Log::WriteFileToLog ( files[1].c_str(), ( directory + " directory listing" ) );
413408
}
414409

415-
void Diag::ExportRegKeyToFile ( std::string subkey, std::string filePath )
410+
void Diag::ExportRegKeyToFile ( std::string subkey )
416411
{
417412
std::string ExportReg;
418413
std::stringstream ss; // create a stringstream
419414

420-
ss << "regedit /e /a " << filePath << " \"" << subkey << "\"";
415+
ss << "regedit /e /a " << files[1] << " \"" << subkey << "\"";
421416
ExportReg = ss.str();
422417

423418
// clear the stringstream

MTADiag/Diag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace Diag {
6767

6868
void DoSystemCommandWithOutput ( std::string command );
6969
void GetDir ( std::string directory );
70-
void ExportRegKeyToFile ( std::string subkey, std::string filePath );
70+
void ExportRegKeyToFile ( std::string subkey );
7171
void TrimCompatabilityExport ( std::string filePath );
7272
void QueryWMIC ( std::string, std::string = "", std::string = "", std::string = "" );
7373

0 commit comments

Comments
 (0)