Skip to content

Commit ea654d1

Browse files
committed
Upgrade to VS2012; changed to MTASA Pastebin; clarified wording; 1.3.3 nightly support; fixed file checker misleading output
1 parent 79e887d commit ea654d1

File tree

9 files changed

+117
-35
lines changed

9 files changed

+117
-35
lines changed

MTADiag.sln

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
Microsoft Visual Studio Solution File, Format Version 10.00
3-
# Visual Studio 2008
4-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MTADiag", "MTADiag\MTADiag.vcproj", "{C55F3E8F-3FC0-45F5-B595-48D3F1207E6C}"
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MTADiag", "MTADiag\MTADiag.vcxproj", "{C55F3E8F-3FC0-45F5-B595-48D3F1207E6C}"
55
EndProject
66
Global
77
GlobalSection(SolutionConfigurationPlatforms) = preSolution

MTADiag/Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
#include <shlobj.h>
2424
#include "Log.h"
2525

26-
#define VERSION "2.7.4"
26+
#define VERSION "2.7.9"

MTADiag/Curl.cpp

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,79 @@ bool Curl::DownloadFile ( std::string fileURL, std::string filePath )
3939
fclose ( fp ); // close the file
4040

4141
if ( !res ) // if we were successful
42-
return true;
42+
return true;
4343
else // failure
44-
return false;
44+
return false;
4545
}
4646
else // failure to initialize CURL
4747
return false;
4848
}
4949

50+
std::string Curl::CreateMTAPasteBin ( std::string filePath, std::string pasteName )
51+
{
52+
CURL *curl; // initialize curl
53+
curl = curl_easy_init(); // initialize curl_easy
54+
55+
std::string logText; // stores entire log file
56+
std::string post; // stores POST string
57+
std::stringstream ss; // create a stringstream
58+
std::ifstream file;
59+
60+
// read entire MTADiag log into string
61+
file.open ( filePath.c_str(), std::ios::in );
62+
if ( file )
63+
{
64+
ss << file.rdbuf();
65+
logText = ss.str();
66+
}
67+
file.close();
68+
69+
// clear the stringstream
70+
ss.str ("");
71+
ss.clear();
72+
73+
ss << "code2="
74+
<< curl_easy_escape ( curl, logText.c_str(), logText.length() ) // urlencode log file contents
75+
<< "&"
76+
<< "format=text&"
77+
<< "postkey=&"
78+
<< "paste=Submit&"
79+
<< "expiry=m&"
80+
<< "give_pid=yes&"
81+
<< "poster="
82+
<< curl_easy_escape ( curl, pasteName.c_str(), pasteName.length() ) // urlencode MTADiag log filename
83+
<< "&";
84+
post = ss.str();
85+
86+
// clear the stringstream
87+
ss.str ("");
88+
ss.clear();
89+
90+
if ( curl ) // if curl was initialized
91+
{
92+
curl_easy_setopt ( curl, CURLOPT_URL, "http://pastebin.mtasa.com/index.php" ); // set the URL
93+
curl_easy_setopt ( curl, CURLOPT_POSTFIELDS, post.c_str() ); // set our log file as the POST field
94+
curl_easy_setopt ( curl, CURLOPT_NOPROGRESS, FALSE ); // we want progress
95+
curl_easy_setopt ( curl, CURLOPT_PROGRESSFUNCTION, progress_callback ); // set the progress callback function
96+
curl_easy_setopt ( curl, CURLOPT_WRITEFUNCTION, write_data ); // set the write function
97+
CURLcode res = curl_easy_perform ( curl ); // perform; store result into res
98+
curl_easy_cleanup ( curl ); // clean up
99+
100+
if ( !res ) // if we were successful
101+
{
102+
return response;
103+
}
104+
else // failure
105+
{
106+
return "Failed to upload to Pastebin.";
107+
}
108+
}
109+
else
110+
{
111+
return "Failed to initialize CURL.";
112+
}
113+
}
114+
50115
std::string Curl::CreatePasteBin ( std::string filePath, std::string pasteName )
51116
{
52117
CURL *curl; // initialize curl
@@ -77,7 +142,7 @@ std::string Curl::CreatePasteBin ( std::string filePath, std::string pasteName )
77142
<< curl_easy_escape ( curl, pasteName.c_str(), pasteName.length() ) // urlencode MTADiag log filename
78143
<< "&"
79144
<< "api_paste_expire_date=1M&" // paste will expire in one month
80-
<< "api_dev_key=provide_your_own&" // Pastebin API dev key
145+
<< "api_dev_key=&" // Pastebin API dev key
81146
<< "api_paste_code="
82147
<< curl_easy_escape ( curl, logText.c_str(), logText.length() ); // urlencode log file contents
83148
post = ss.str();
@@ -98,7 +163,6 @@ std::string Curl::CreatePasteBin ( std::string filePath, std::string pasteName )
98163

99164
if ( !res ) // if we were successful
100165
{
101-
102166
return response;
103167
}
104168
else // failure

MTADiag/Curl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace Curl {
2020

2121
bool DownloadFile ( std::string fileURL, std::string filePath );
22+
std::string CreateMTAPasteBin ( std::string filePath, std::string pasteName );
2223
std::string CreatePasteBin ( std::string filePath, std::string pasteName );
23-
2424
static std::string response; // HTTP POST response
2525
}

MTADiag/Diag.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
//#define SKIPUPDATE
2020
//#define SKIPDXDIAG
21+
//#define SKIPFILECHECK
2122
//#define DEBUGOUTPUT // output contents of files vector
2223

2324
std::vector<std::string> Diag::files;
@@ -53,7 +54,7 @@ void Diag::Begin ( void )
5354
// only check 32-bit OSes due to compatibility mode settings *NOT* being written to Wow6432Node on 64-bit OSes
5455
// and I can't seem to query non-Wow6432Node keys - maybe I'm doing something wrong?
5556
if ( !bIsWOW64 ) { CompatRemoved2 = DeleteCompatibilityEntries ( CompatModeRegKey, HKEY_LOCAL_MACHINE ); }
56-
57+
#ifndef SKIPFILECHECK
5758
// check for any missing GTA files
5859
std::cout << "Checking for missing GTA files, please wait..." << std::endl;
5960

@@ -66,8 +67,7 @@ void Diag::Begin ( void )
6667
std::cout << "Missing GTA file: " << fileList[i].szFilename << std::endl; // output any messed up file
6768
bQuit = true; // we need to quit since the user's GTA install is probably screwed up
6869
}
69-
printf ( "Checking %i out of %i...\r", i, ( sizeof ( fileList ) / sizeof ( fileList[0] ) ) );
70-
fflush ( stdout );
70+
std::cout << "\rChecking " << ( i + 1 ) << " out of " << ( sizeof ( fileList ) / sizeof ( fileList[0] ) ) << "...";
7171
}
7272
std::cout << std::endl;
7373
if ( bQuit )
@@ -77,7 +77,7 @@ void Diag::Begin ( void )
7777
system ( "pause" );
7878
exit ( EXIT_FAILURE ); // exit
7979
};
80-
80+
#endif
8181
// check if MTA version matches the latest auto-update nightly
8282
if ( Curl::DownloadFile ( MTAVerURL, files[1].c_str() ) ) // download the version appropriation HTML
8383
{
@@ -122,7 +122,7 @@ void Diag::Begin ( void )
122122
if ( CompatRemoved1 == true || CompatRemoved2 == true )
123123
Log::WriteStringToLog ( "Compat. mode deleted: Yes");
124124
Log::WriteStringToLog ( "" );
125-
125+
#ifndef SKIPFILECHECK
126126
// check for any modified or nonstandard GTA files
127127
std::cout << "Checking for modified or nonstandard GTA files, please wait..." << std::endl;
128128

@@ -140,10 +140,10 @@ void Diag::Begin ( void )
140140
Log::WriteStringToLog ( "Value should be: ", szMd5 );
141141
Log::WriteStringToLog ( "" );
142142
}
143-
printf ( "Checking %i out of %i...\r", i, ( sizeof ( fileList ) / sizeof ( fileList[0] ) ) );
144-
fflush ( stdout );
143+
std::cout << "\rChecking " << ( i + 1 ) << " out of " << ( sizeof ( fileList ) / sizeof ( fileList[0] ) ) << "...";
145144
}
146-
145+
std::cout << std::endl;
146+
#endif
147147
// collect more information and output to log file
148148
std::cout << "Gathering information. Please wait..." << std::endl;
149149
ProgressBar ( 0 );
@@ -199,11 +199,12 @@ void Diag::Begin ( void )
199199
// upload to PasteBin
200200
std::cout << "Log file generated. Uploading to Pastebin..." << std::endl;
201201

202-
PasteBinResult = Curl::CreatePasteBin ( files[0], logFileName ); // store the HTTP POST result into PasteBinResult
202+
PasteBinResult = Curl::CreateMTAPasteBin ( files[0], logFileName ); // store the HTTP POST result into PasteBinResult
203203

204204
// upload successful; copy URL to clipboard
205-
if ( strstr ( PasteBinResult.c_str(), "http://pastebin.com/" ) )
205+
if ( HasDigits ( PasteBinResult ) && !( strstr ( PasteBinResult.c_str(), "DOCTYPE" ) ) )
206206
{
207+
PasteBinResult.insert ( 0, "http://pastebin.mtasa.com/" );
207208
if ( CopyToClipboard ( PasteBinResult ) ) // was copying to clipboard successful?
208209
{
209210
std::cout << "Pastebin link (" << PasteBinResult << ") copied to your clipboard." << std::endl << "Please include the Pastebin link in your forum post." << std::endl;
@@ -216,10 +217,10 @@ void Diag::Begin ( void )
216217
}
217218
else // upload failure, open the log in WordPad so the user can copy & paste it themselves
218219
{
219-
std::cout << std::endl << std::endl << "Failed to upload log file to Pastebin." << std::endl;
220+
std::cout << std::endl << std::endl << "Failed to upload log file to MTA Pastebin." << std::endl;
220221
std::cout << "Error code: \"" << PasteBinResult << "\"" << std::endl;
221-
std::cout << "Please paste the contents of the opened Wordpad window at www.pastebin.com." << std::endl;
222-
std::cout << "Include the Pastebin link in your forum post." << std::endl << std::endl;
222+
std::cout << "Please paste the contents of the opened Wordpad window at www.pastebin.mtasa.com." << std::endl;
223+
std::cout << "Include the MTA Pastebin link in your forum post." << std::endl << std::endl;
223224
ShellExecute ( NULL, "open", "wordpad.exe", files[0].c_str(), NULL, SW_SHOW );
224225
}
225226
}
@@ -317,7 +318,7 @@ bool Diag::PollMTAVersions ( void )
317318

318319
void Diag::UserPickVersion ( void )
319320
{
320-
std::cout << "You have multiple versions of MTA installed." << std::endl << "Please pick which version to diagnose:" << std::endl;
321+
std::cout << "You have multiple versions of MTA installed." << std::endl << "Please pick which version to diagnose by entering the number within the brackets:" << std::endl;
321322

322323
// iterate through currently installed MTA versions and output them
323324
for (int i = 1; i < CUR_MTA_VERSIONS; i++)

MTADiag/Diag.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
// Nightly download URLs
4242
#define MTA11NightlyURL "https://nightly.mtasa.com/?mtasa-1.1.1-rc-latest"
4343
#define MTA12NightlyURL "https://nightly.mtasa.com/?mtasa-1.2-rc-latest"
44-
#define MTA13NightlyURL "https://nightly.mtasa.com/?mtasa-1.3.1-rc-latest"
44+
#define MTA13NightlyURL "https://nightly.mtasa.com/?mtasa-1.3.3-rc-latest"
4545
#define MTA14NightlyURL "https://nightly.mtasa.com/?mtasa-1.4-unstable-latest"
4646
#define MTA15NightlyURL "https://nightly.mtasa.com/?mtasa-1.5-unstable-latest"
4747

@@ -234,11 +234,11 @@ namespace Diag {
234234
{"da741c471b42859c99b3468bde1dc621", "\\data\\Decision\\chris\\ryder3.ped"},
235235
{"36e16f72d8be78bb8628478d5642860d", "\\data\\Decision\\david\\dam_sec.ped"},
236236
{"bf932fd285c05f708171b2e7cf0abe35", "\\data\\Decision\\david\\hei2_sc.ped"},
237-
{"4d5f2754d6236d7e8c765def78b0fd68", "\\data\\Icons\\app.ico"},
238-
{"ca533637e0a1aac05c9b14a98069c224", "\\data\\Icons\\bin.ico"},
239-
{"ffcc3a0d32517475bc83f08331169ada", "\\data\\Icons\\saicon.ICN"},
240-
{"ffcc3a0d32517475bc83f08331169ada", "\\data\\Icons\\saicon2.ICN"},
241-
{"ffcc3a0d32517475bc83f08331169ada", "\\data\\Icons\\saicon3.ICN"},
237+
//{"4d5f2754d6236d7e8c765def78b0fd68", "\\data\\Icons\\app.ico"},
238+
//{"ca533637e0a1aac05c9b14a98069c224", "\\data\\Icons\\bin.ico"},
239+
//{"ffcc3a0d32517475bc83f08331169ada", "\\data\\Icons\\saicon.ICN"},
240+
//{"ffcc3a0d32517475bc83f08331169ada", "\\data\\Icons\\saicon2.ICN"},
241+
//{"ffcc3a0d32517475bc83f08331169ada", "\\data\\Icons\\saicon3.ICN"},
242242
{"b65284518b3bab328530eb0f2b969d86", "\\data\\Paths\\NODES0.DAT"},
243243
{"167712a4ec91fd811670b120ba13ec33", "\\data\\Paths\\NODES1.DAT"},
244244
{"da13b3a0422f2866cb3cab02a93296fe", "\\data\\Paths\\NODES10.DAT"},
@@ -511,9 +511,9 @@ namespace Diag {
511511
//{"497d6d1447c62e57c55db49444876fac", "\\movies\\GTAtitles.mpg"},
512512
//{"fe0ddfa024d1296597890f27d24ae335", "\\movies\\Logo.mpg"},
513513
{"6791e6e0ffa6317af8a0dff648c9633d", "\\text\\american.gxt"},
514-
{"3d069d3322809ccae92f315f53b5ad52", "\\text\\french.gxt"},
515-
{"7801fc85df72041ba497bade4b258da5", "\\text\\german.gxt"},
516-
{"fe4b7386f7149826ec682c5816f91ae4", "\\text\\italian.gxt"},
517-
{"71e0281b4ff0ec6f192a2bda4d00effd", "\\text\\spanish.gxt"},
514+
//{"3d069d3322809ccae92f315f53b5ad52", "\\text\\french.gxt"},
515+
//{"7801fc85df72041ba497bade4b258da5", "\\text\\german.gxt"},
516+
//{"fe4b7386f7149826ec682c5816f91ae4", "\\text\\italian.gxt"},
517+
//{"71e0281b4ff0ec6f192a2bda4d00effd", "\\text\\spanish.gxt"},
518518
};
519519
}

MTADiag/MTADiag.vcproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
RuntimeLibrary="2"
120120
EnableFunctionLevelLinking="true"
121121
UsePrecompiledHeader="0"
122-
WarningLevel="3"
122+
WarningLevel="4"
123123
DebugInformationFormat="3"
124124
/>
125125
<Tool
@@ -135,7 +135,7 @@
135135
Name="VCLinkerTool"
136136
AdditionalDependencies="libcurl.lib"
137137
LinkIncremental="1"
138-
UACExecutionLevel="2"
138+
UACExecutionLevel="0"
139139
GenerateDebugInformation="true"
140140
SubSystem="1"
141141
OptimizeReferences="2"
@@ -189,6 +189,10 @@
189189
RelativePath=".\main.cpp"
190190
>
191191
</File>
192+
<File
193+
RelativePath=".\md5.cpp"
194+
>
195+
</File>
192196
<File
193197
RelativePath=".\util.cpp"
194198
>
@@ -215,6 +219,10 @@
215219
RelativePath=".\Log.h"
216220
>
217221
</File>
222+
<File
223+
RelativePath=".\md5.h"
224+
>
225+
</File>
218226
<File
219227
RelativePath=".\util.h"
220228
>

MTADiag/util.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ bool FindInFile ( std::string filename, std::string value )
305305
return false; // we didn't find it, return false
306306
}
307307

308+
bool HasDigits ( std::string s )
309+
{
310+
if ( std::string::npos != s.find_first_of ( "0123456789" ) )
311+
return true;
312+
else
313+
return false;
314+
}
315+
308316
void ProgressBar ( int percent )
309317
{
310318
std::string bar;

MTADiag/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ bool IsWin8OrNewer ( void );
3030
std::string GetFileMD5 ( std::string filename );
3131
bool CompareFileMD5 ( std::string MD5sum, std::string filename );
3232
bool FindInFile ( std::string filename, std::string value );
33+
bool HasDigits ( std::string s );
3334
void ProgressBar ( int percent );
3435
std::string GetEnv ( std::string variable );

0 commit comments

Comments
 (0)