mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 03:09:15 +01:00
*fixed problem with loading wrong cheats instead of the selected
*fixed possible problem in activating cheats for certain languages
This commit is contained in:
parent
378463e838
commit
11feda685b
@ -2,8 +2,8 @@
|
|||||||
<app version="1">
|
<app version="1">
|
||||||
<name> USB Loader GX</name>
|
<name> USB Loader GX</name>
|
||||||
<coder>USB Loader GX Team</coder>
|
<coder>USB Loader GX Team</coder>
|
||||||
<version>2.3 r1174</version>
|
<version>2.3 r1177</version>
|
||||||
<release_date>201205091915</release_date>
|
<release_date>201205101853</release_date>
|
||||||
<!-- // remove this line to enable arguments
|
<!-- // remove this line to enable arguments
|
||||||
<arguments>
|
<arguments>
|
||||||
<arg>--ios=250</arg>
|
<arg>--ios=250</arg>
|
||||||
|
@ -120,11 +120,11 @@ int CheatMenu(const char * gameID)
|
|||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
const char *strCheck = cheatslst.GetName(ret);
|
const char *strCheck = cheatslst.GetName(ret);
|
||||||
if (strCheck && strncmp(strCheck, tr("ON"), 2) == 0)
|
if (strCheck && strcmp(strCheck, tr("ON")) == 0)
|
||||||
{
|
{
|
||||||
cheatslst.SetName(ret, "%s", tr("OFF"));
|
cheatslst.SetName(ret, "%s", tr("OFF"));
|
||||||
}
|
}
|
||||||
else if (strCheck && strncmp(strCheck, tr("OFF"), 3) == 0)
|
else if (strCheck && strcmp(strCheck, tr("OFF")) == 0)
|
||||||
{
|
{
|
||||||
cheatslst.SetName(ret, "%s", tr("ON"));
|
cheatslst.SetName(ret, "%s", tr("ON"));
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ int CheatMenu(const char * gameID)
|
|||||||
for (int i = 0; i < cntcheats; i++)
|
for (int i = 0; i < cntcheats; i++)
|
||||||
{
|
{
|
||||||
const char *strCheck = cheatslst.GetName(i);
|
const char *strCheck = cheatslst.GetName(i);
|
||||||
if (strCheck && strncmp(strCheck, tr("ON"), 2) == 0)
|
if (strCheck && strcmp(strCheck, tr("ON")) == 0)
|
||||||
vActiveCheats.push_back(i);
|
vActiveCheats.push_back(i);
|
||||||
}
|
}
|
||||||
if (vActiveCheats.size() == 0)
|
if (vActiveCheats.size() == 0)
|
||||||
|
@ -36,11 +36,9 @@ GCTCheats::~GCTCheats(void)
|
|||||||
|
|
||||||
void GCTCheats::Clear(void)
|
void GCTCheats::Clear(void)
|
||||||
{
|
{
|
||||||
sGameID.clear();
|
cheatList.clear();
|
||||||
sCheatName.clear();
|
sGameID.clear();
|
||||||
sGameTitle.clear();
|
sGameTitle.clear();
|
||||||
sCheatComment.clear();
|
|
||||||
sCheats.clear();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,26 +54,26 @@ string GCTCheats::getGameID(void)
|
|||||||
|
|
||||||
vector<unsigned int> GCTCheats::getCheat(int nr)
|
vector<unsigned int> GCTCheats::getCheat(int nr)
|
||||||
{
|
{
|
||||||
if((unsigned int)nr >= sCheats.size())
|
if((unsigned int)nr >= cheatList.size())
|
||||||
return vector<unsigned int>();
|
return vector<unsigned int>();
|
||||||
|
|
||||||
return sCheats[nr];
|
return cheatList[nr].sCheats;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GCTCheats::getCheatName(int nr)
|
string GCTCheats::getCheatName(int nr)
|
||||||
{
|
{
|
||||||
if((unsigned int)nr >= sCheatName.size())
|
if((unsigned int)nr >= cheatList.size())
|
||||||
return ERRORRANGE;
|
return ERRORRANGE;
|
||||||
|
|
||||||
return sCheatName[nr];
|
return cheatList[nr].sCheatName;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GCTCheats::getCheatComment(int nr)
|
string GCTCheats::getCheatComment(int nr)
|
||||||
{
|
{
|
||||||
if((unsigned int)nr >= sCheatComment.size())
|
if((unsigned int)nr >= cheatList.size())
|
||||||
return ERRORRANGE;
|
return ERRORRANGE;
|
||||||
|
|
||||||
return sCheatComment[nr];
|
return cheatList[nr].sCheatComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GCTCheats::createGCT(const vector<int> &vCheats, const char * filename)
|
int GCTCheats::createGCT(const vector<int> &vCheats, const char * filename)
|
||||||
@ -90,21 +88,17 @@ int GCTCheats::createGCT(const vector<int> &vCheats, const char * filename)
|
|||||||
|
|
||||||
fwrite(GCT_Header, sizeof(GCT_Header), 1, pFile);
|
fwrite(GCT_Header, sizeof(GCT_Header), 1, pFile);
|
||||||
|
|
||||||
int cnt = vCheats.size();
|
int cnt = vCheats.size();
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while (c < cnt)
|
while (c < cnt)
|
||||||
{
|
{
|
||||||
if((unsigned int)vCheats[c] > sCheats.size())
|
if((unsigned int)vCheats[c] >= cheatList.size())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vector<unsigned int> &cheatBuf = sCheats[vCheats[c]];
|
vector<unsigned int> &cheatBuf = cheatList[vCheats[c]].sCheats;
|
||||||
unsigned int x = 0;
|
if(cheatBuf.size() > 0)
|
||||||
|
fwrite((char*)&cheatBuf[0], cheatBuf.size() * sizeof(unsigned int), 1, pFile);
|
||||||
|
|
||||||
while (x < cheatBuf.size())
|
|
||||||
{
|
|
||||||
fwrite((char*)&cheatBuf[x], 4, 1, pFile);
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,9 +160,9 @@ int GCTCheats::openTxtfile(const char * filename)
|
|||||||
if(*line == 0)
|
if(*line == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sCheatName.push_back(line);
|
// first line is the cheat name
|
||||||
|
CheatEntry cheatEntry;
|
||||||
vector<unsigned int> cheatdata;
|
cheatEntry.sCheatName = line;
|
||||||
|
|
||||||
while (fgets(line, max_line_size, pFile))
|
while (fgets(line, max_line_size, pFile))
|
||||||
{
|
{
|
||||||
@ -183,19 +177,17 @@ int GCTCheats::openTxtfile(const char * filename)
|
|||||||
line[8] = 0;
|
line[8] = 0;
|
||||||
line[17] = 0;
|
line[17] = 0;
|
||||||
|
|
||||||
cheatdata.push_back(strtoul(&line[0], 0, 16));
|
cheatEntry.sCheats.push_back(strtoul(&line[0], 0, 16));
|
||||||
cheatdata.push_back(strtoul(&line[9], 0, 16));
|
cheatEntry.sCheats.push_back(strtoul(&line[9], 0, 16));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sCheatComment.push_back(line);
|
cheatEntry.sCheatComment = line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cheatdata.empty())
|
if(!cheatEntry.sCheats.empty())
|
||||||
continue;
|
cheatList.push_back(cheatEntry);
|
||||||
|
|
||||||
sCheats.push_back(cheatdata);
|
|
||||||
}
|
}
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
delete [] line;
|
delete [] line;
|
||||||
@ -223,10 +215,10 @@ bool GCTCheats::IsCode(const char *str)
|
|||||||
|
|
||||||
bool GCTCheats::IsCheatIncluded(int iCheat, const unsigned char *gctBuf, unsigned int gctSize)
|
bool GCTCheats::IsCheatIncluded(int iCheat, const unsigned char *gctBuf, unsigned int gctSize)
|
||||||
{
|
{
|
||||||
if(!gctBuf || (unsigned int)iCheat >= sCheats.size())
|
if(!gctBuf || (unsigned int)iCheat >= cheatList.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
vector<unsigned int> &Cheat = sCheats[iCheat];
|
vector<unsigned int> &Cheat = cheatList[iCheat].sCheats;
|
||||||
int len = Cheat.size() * sizeof(unsigned int);
|
int len = Cheat.size() * sizeof(unsigned int);
|
||||||
|
|
||||||
for(unsigned int i = sizeof(GCT_Header); i + len <= gctSize - sizeof(GCT_Footer); i += 4)
|
for(unsigned int i = sizeof(GCT_Header); i + len <= gctSize - sizeof(GCT_Footer); i += 4)
|
||||||
|
@ -29,9 +29,13 @@ class GCTCheats
|
|||||||
private:
|
private:
|
||||||
string sGameID;
|
string sGameID;
|
||||||
string sGameTitle;
|
string sGameTitle;
|
||||||
vector< string > sCheatName;
|
struct CheatEntry
|
||||||
vector< string > sCheatComment;
|
{
|
||||||
vector< vector<unsigned int> > sCheats;
|
string sCheatName;
|
||||||
|
string sCheatComment;
|
||||||
|
vector<unsigned int> sCheats;
|
||||||
|
};
|
||||||
|
vector<CheatEntry> cheatList;
|
||||||
public:
|
public:
|
||||||
//!Constructor
|
//!Constructor
|
||||||
GCTCheats(void);
|
GCTCheats(void);
|
||||||
@ -49,7 +53,7 @@ class GCTCheats
|
|||||||
int createGCT(const vector<int> &vCheats, const char * filename);
|
int createGCT(const vector<int> &vCheats, const char * filename);
|
||||||
//!Gets Count cheats
|
//!Gets Count cheats
|
||||||
//!\return Count cheats
|
//!\return Count cheats
|
||||||
int getCnt() const { return sCheats.size(); }
|
int getCnt() const { return cheatList.size(); }
|
||||||
//!Gets Game Name
|
//!Gets Game Name
|
||||||
//!\return Game Name
|
//!\return Game Name
|
||||||
string getGameName(void);
|
string getGameName(void);
|
||||||
@ -64,7 +68,7 @@ class GCTCheats
|
|||||||
string getCheatName(int nr);
|
string getCheatName(int nr);
|
||||||
//!Gets Cheat Comment
|
//!Gets Cheat Comment
|
||||||
//!\return Cheat Comment
|
//!\return Cheat Comment
|
||||||
string getCheatComment(int nr);
|
string getCheatComment(int nr);
|
||||||
//!Clear all loaded cheats
|
//!Clear all loaded cheats
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
//!Check if string is a code
|
//!Check if string is a code
|
||||||
|
Loading…
Reference in New Issue
Block a user