mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-07 17:46:41 +00:00
Merge pull request #4023 from makotech222/cwcheat
CWCheat: Fix for crashing when exceeding cheat list size.
This commit is contained in:
commit
4e4b49ce70
@ -40,21 +40,19 @@ static bool enableAll = false;
|
||||
static std::vector<std::string> cheatList;
|
||||
extern void DrawBackground(float alpha);
|
||||
static CWCheatEngine *cheatEngine2;
|
||||
static bool enableCheat [128];
|
||||
|
||||
static std::deque<bool> bEnableCheat;
|
||||
std::vector<std::string> CwCheatScreen::CreateCodeList() {
|
||||
cheatEngine2 = new CWCheatEngine();
|
||||
cheatList = cheatEngine2->GetCodesList();
|
||||
int j = 0;
|
||||
bEnableCheat.clear();
|
||||
for (size_t i = 0; i < cheatList.size(); i++) {
|
||||
if (cheatList[i].substr(0, 3) == "_C1") {
|
||||
formattedList.push_back(cheatList[i].substr(4));
|
||||
enableCheat[j++] = true;
|
||||
locations.push_back((int)i);
|
||||
bEnableCheat.push_back(true);
|
||||
}
|
||||
if (cheatList[i].substr(0, 3) == "_C0") {
|
||||
formattedList.push_back(cheatList[i].substr(4));
|
||||
enableCheat[j++] = false;
|
||||
bEnableCheat.push_back(false);
|
||||
}
|
||||
}
|
||||
delete cheatEngine2;
|
||||
@ -90,7 +88,7 @@ void CwCheatScreen::CreateViews() {
|
||||
rightColumn->Add(new ItemHeader(k->T("Cheats")));
|
||||
for (size_t i = 0; i < formattedList.size(); i++) {
|
||||
name = formattedList[i].c_str();
|
||||
rightColumn->Add(new CheatCheckBox(&enableCheat[i], k->T(name), "" ))->OnClick.Handle(this, &CwCheatScreen::OnCheckBox);
|
||||
rightColumn->Add(new CheatCheckBox(&bEnableCheat[i], k->T(name), ""))->OnClick.Handle(this, &CwCheatScreen::OnCheckBox);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,8 +126,8 @@ UI::EventReturn CwCheatScreen::OnEnableAll(UI::EventParams ¶ms)
|
||||
cheatList[j].replace(0, 3, "_C0");
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < 128; y++) {
|
||||
enableCheat[y] = enableAll;
|
||||
for (int y = 0; y < bEnableCheat.size(); y++) {
|
||||
bEnableCheat[y] = enableAll;
|
||||
}
|
||||
for (int i = 0; i < (int)cheatList.size(); i++) {
|
||||
os << cheatList[i];
|
||||
|
@ -48,7 +48,6 @@ private:
|
||||
UI::EventReturn OnCheckBox(UI::EventParams ¶ms);
|
||||
|
||||
std::vector<std::string> formattedList;
|
||||
std::vector<int> locations;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user