diff --git a/gui.pnproj b/gui.pnproj
index 9c8c1fea..d2cb4a7f 100644
--- a/gui.pnproj
+++ b/gui.pnproj
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/source/cheats/gct.cpp b/source/cheats/gct.cpp
index 56dd210b..21286d03 100644
--- a/source/cheats/gct.cpp
+++ b/source/cheats/gct.cpp
@@ -182,20 +182,17 @@ int GCTCheats::openTxtfile(const char * filename) {
if (sGameTitle[sGameTitle.length() - 1] == '\r')
sGameTitle.erase(sGameTitle.length() - 1);
- //filestr.ignore();
getline(filestr,sCheatName[i]); // skip first line if file uses CRLF
if (!sGameTitle[sGameTitle.length() - 1] == '\r')
filestr.seekg(0,ios_base::beg);
while (!filestr.eof()) {
-
getline(filestr,sCheatName[i]); // '\n' delimiter by default
if (sCheatName[i][sCheatName[i].length() - 1] == '\r')
sCheatName[i].erase(sCheatName[i].length() - 1);
string cheatdata;
bool emptyline = false;
- bool isComment = false;
do {
getline(filestr,str);
@@ -207,26 +204,41 @@ int GCTCheats::openTxtfile(const char * filename) {
break;
}
- if (str.size() <= 16 || str.size() > 17 ) {
- isComment = true;
- printf ("%i",str.size());
- }
-
- if (!isComment) {
- cheatdata.append(str);
+ if (IsCode(str)) {
+ // remove any garbage (comment) after code
+ while (str.size() > 17) {
+ str.erase(str.length() - 1);
+ }
+ cheatdata.append(str);
size_t found=cheatdata.find(' ');
cheatdata.replace(found,1,"");
- } else {
+ } else {
+ //printf("%i",str.size());
sCheatComment[i] = str;
}
-
- if (filestr.eof()) break;
+ if (filestr.eof()) break;
+
} while (!emptyline);
sCheats[i] = cheatdata;
- i++;
+ i++;
+ if (i == MAXCHEATS) break;
}
iCntCheats = i;
filestr.close();
return 1;
}
+
+bool GCTCheats::IsCode(const std::string& str) {
+ if (str[8] == ' ' && str.size() >= 17) {
+ // accept strings longer than 17 in case there is a comment on the same line as the code
+ char part1[9];
+ char part2[9];
+ snprintf(part1,sizeof(part1),"%c%c%c%c%c%c%c%c",str[0],str[1],str[2],str[3],str[4],str[5],str[6],str[7]);
+ snprintf(part1,sizeof(part2),"%c%c%c%c%c%c%c%c",str[9],str[10],str[11],str[12],str[13],str[14],str[15],str[16]);
+ if ((strtok(part1,"0123456789ABCDEFabcdef") == NULL) && (strtok(part2,"0123456789ABCDEFabcdef") == NULL)) {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/source/cheats/gct.h b/source/cheats/gct.h
index 1e1055f1..3dca78ae 100644
--- a/source/cheats/gct.h
+++ b/source/cheats/gct.h
@@ -9,7 +9,7 @@
#include
-#define MAXCHEATS 40
+#define MAXCHEATS 300
using namespace std;
@@ -66,6 +66,9 @@ public:
//!Gets Cheat Comment
//!\return Cheat Comment
string getCheatComment(int nr);
+ //!Check if string is a code
+ //!\return true/false
+ bool IsCode(const std::string& s);
};
#endif /* _GCT_H */
diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp
index 1a189163..67fdec38 100644
--- a/source/prompts/DiscBrowser.cpp
+++ b/source/prompts/DiscBrowser.cpp
@@ -302,8 +302,6 @@ int autoSelectDol(const char *id) {
}
return choice;
}
- //if (strcmp(id,"R3ME01 ") == 0) return 780; mp1: 780, mp2: 781, mp3: 782
- //if (strcmp(id,"R3MP01 ") == 0) return;
//Mortal Kombat
if (strcmp(id,"RKMP5D") == 0) return 290;//from isostar