diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 7f6556d1c5..b0a94ada06 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -39,7 +39,7 @@ bool enableAll = false; static std::vector cheatList; extern void DrawBackground(float alpha); static CWCheatEngine *cheatEngine2; -static bool enableCheat [64]; +static bool enableCheat [128]; std::vector CwCheatScreen::CreateCodeList() { cheatEngine2 = new CWCheatEngine(); @@ -110,23 +110,23 @@ UI::EventReturn CwCheatScreen::OnEnableAll(UI::EventParams ¶ms) std::vector temp = cheatList; enableAll = !enableAll; os.open(activeCheatFile.c_str()); - for (int j = 0; j < temp.size(); j++) { - if (enableAll == 1 && temp[j].substr(0, 3) == "_C0"){ - temp[j].replace(0,3,"_C1"); + for (int j = 0; j < cheatList.size(); j++) { + if (enableAll == 1 && cheatList[j].substr(0, 3) == "_C0"){ + cheatList[j].replace(0, 3, "_C1"); } - else if (enableAll == 0 && temp[j].substr(0, 3) == "_C1") { - temp[j].replace(0, 3, "_C0"); + else if (enableAll == 0 && cheatList[j].substr(0, 3) == "_C1") { + cheatList[j].replace(0, 3, "_C0"); } } - for (int y = 0; y < 64; y++) { + for (int y = 0; y < 128; y++) { enableCheat[y] = enableAll; } - for (int i = 0; i < temp.size(); i++) { - os << temp[i]; - if (i < temp.size() - 1) { + for (int i = 0; i < cheatList.size(); i++) { + os << cheatList[i]; + if (i < cheatList.size() - 1) { os << "\n"; } } @@ -143,29 +143,31 @@ UI::EventReturn CwCheatScreen::OnAddCheat(UI::EventParams ¶ms) UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) { std::string line; + std::vector title; bool finished = false, skip = false; std::vector newList; #ifdef ANDROID - is.open (g_Config.memCardDirectory + "PSP/Cheats/cheat.db"; + is.open(g_Config.memCardDirectory + "PSP/Cheats/cheat.db"; #else is.open("cheats/cheat.db"); #endif - os.open(activeCheatFile.c_str(),std::ios::app); while (is.good()) { getline(is, line); // get line from file if (line == "_S " + gameTitle.substr(0, 4) + "-" + gameTitle.substr(4)) { + title.push_back(line); getline(is, line); + title.push_back(line); getline(is, line); - - - + + + do { if (finished == false){ getline(is, line); } - if (line.substr(0, 3) == "_C0") + if (line.substr(0, 3) == "_C0" || line.substr(0, 3) == "_C1") { //Test if cheat already exists in cheatList for (int j = 0; j < formattedList.size(); j++) { @@ -174,7 +176,7 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) goto loop; } } - + newList.push_back(line); getline(is, line); do { @@ -187,10 +189,19 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) loop:; } while (line.substr(0, 2) != "_S"); finished = true; - } + } if (finished == true) break; - } + } + is.close(); + std::string title2; + is.open(activeCheatFile.c_str()); + getline(is, title2); + is.close(); + os.open(activeCheatFile.c_str(), std::ios::app); + if (title2.substr(0, 2) != "_S") { + os << title[0] << "\n" << title[1]; + } if (newList.size() != 0) { os << "\n"; @@ -202,7 +213,6 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) } } os.close(); - is.close(); g_Config.bReloadCheats = true; //Need a better way to refresh the screen, rather than exiting and having to re-enter. screenManager()->finishDialog(this, DR_OK); diff --git a/UI/CwCheatScreen.h b/UI/CwCheatScreen.h index 120271b7a7..4ad4764a94 100644 --- a/UI/CwCheatScreen.h +++ b/UI/CwCheatScreen.h @@ -46,7 +46,6 @@ protected: private: UI::EventReturn OnCheckBox(UI::EventParams ¶ms); - bool enableCheat [128]; std::vector formattedList; std::vector locations;