fixes to cheat system

This commit is contained in:
zeromus 2010-07-18 06:32:15 +00:00
parent 5e8fa718c6
commit 9c750642c8
2 changed files with 5 additions and 40 deletions

View File

@ -39,9 +39,6 @@ void CHEATS::init(char *path)
clear(); clear();
strcpy((char *)filename, path); strcpy((char *)filename, path);
if (stack) delete [] stack;
stack = NULL;
load(); load();
} }
@ -505,7 +502,7 @@ BOOL CHEATS::getList(CHEATS_LIST *cheat)
} }
//memcpy(cheat, &list[currentGet++], sizeof(CHEATS_LIST)); //memcpy(cheat, &list[currentGet++], sizeof(CHEATS_LIST));
*cheat = list[currentGet++]; *cheat = list[currentGet++];
if (currentGet >= list.size()) if (currentGet > list.size())
{ {
currentGet = 0; currentGet = 0;
return FALSE; return FALSE;
@ -621,6 +618,8 @@ BOOL CHEATS::load()
} }
trim(buf); trim(buf);
if ((strlen(buf) == 0) || (buf[0] == ';')) continue; if ((strlen(buf) == 0) || (buf[0] == ';')) continue;
if(!strnicmp(buf,"name=",5)) continue;
if(!strnicmp(buf,"serial=",7)) continue;
memset(&tmp_cht, 0, sizeof(tmp_cht)); memset(&tmp_cht, 0, sizeof(tmp_cht));
if ((buf[0] == 'D') && (buf[1] == 'S')) // internal if ((buf[0] == 'D') && (buf[1] == 'S')) // internal
@ -649,7 +648,7 @@ BOOL CHEATS::load()
continue; continue;
} }
tmp_cht.enabled = (buf[3] == '0')?false:true; tmp_cht.enabled = (buf[3] == '0')?FALSE:TRUE;
u32 descr_pos = (u32)(std::max<s32>(strchr((char*)buf, ';') - buf, 0)); u32 descr_pos = (u32)(std::max<s32>(strchr((char*)buf, ';') - buf, 0));
if (descr_pos != 0) if (descr_pos != 0)
strcpy(tmp_cht.description, (buf + descr_pos + 1)); strcpy(tmp_cht.description, (buf + descr_pos + 1));
@ -688,36 +687,10 @@ BOOL CHEATS::load()
return FALSE; return FALSE;
} }
//BOOL CHEATS::push()
//{
// if (stack) return FALSE;
// stack = new u8 [sizeof(list)];
// memcpy(stack, list, sizeof(list));
// numStack = num;
// return TRUE;
//}
//
//BOOL CHEATS::pop()
//{
// if (!stack) return FALSE;
// memcpy(list, stack, sizeof(list));
// num = numStack;
// delete [] stack;
// stack = NULL;
// return TRUE;
//}
//
//void CHEATS::stackClear()
//{
// if (!stack) return;
// delete [] stack;
// stack = NULL;
//}
void CHEATS::process() void CHEATS::process()
{ {
if (CommonSettings.cheatsDisable) return; if (CommonSettings.cheatsDisable) return;
if (!list.size() == 0) return; if (list.size() == 0) return;
size_t num = list.size(); size_t num = list.size();
for (size_t i = 0; i < num; i++) for (size_t i = 0; i < num; i++)
{ {

View File

@ -50,9 +50,6 @@ private:
u8 filename[MAX_PATH]; u8 filename[MAX_PATH];
u32 currentGet; u32 currentGet;
u8 *stack;
u16 numStack;
void clear(); void clear();
void ARparser(CHEATS_LIST& cheat); void ARparser(CHEATS_LIST& cheat);
BOOL XXcodePreParser(CHEATS_LIST *cheat, char *code); BOOL XXcodePreParser(CHEATS_LIST *cheat, char *code);
@ -61,8 +58,6 @@ private:
public: public:
CHEATS() CHEATS()
: currentGet(0) : currentGet(0)
, stack(0)
, numStack(0)
{ {
memset(filename, 0, sizeof(filename)); memset(filename, 0, sizeof(filename));
} }
@ -82,9 +77,6 @@ public:
u32 getSize(); u32 getSize();
BOOL save(); BOOL save();
BOOL load(); BOOL load();
//BOOL push();
//BOOL pop();
//void stackClear();
void process(); void process();
void getXXcodeString(CHEATS_LIST cheat, char *res_buf); void getXXcodeString(CHEATS_LIST cheat, char *res_buf);
}; };