From 887d1652b559ff952e8b5ad7fc291dcb85685c9c Mon Sep 17 00:00:00 2001 From: Steven Cherry Date: Sat, 31 Aug 2013 21:15:50 -0500 Subject: [PATCH 1/3] Fix Reading from cheat.db and enable/disable all --- UI/CwCheatScreen.cpp | 50 ++++++++++++++++++++++++++------------------ UI/CwCheatScreen.h | 1 - 2 files changed, 30 insertions(+), 21 deletions(-) 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; From fc7003d2377069641ec27416847025745fa8b747 Mon Sep 17 00:00:00 2001 From: Steven Cherry Date: Sun, 1 Sep 2013 13:58:05 -0500 Subject: [PATCH 2/3] Fix parentheses --- UI/CwCheatScreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index b0a94ada06..71cdf38baf 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -147,7 +147,7 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) 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 From 3d468e37ad9a9b5ccafacdc5cf3b9c3a2db9b069 Mon Sep 17 00:00:00 2001 From: Steven Cherry Date: Sun, 1 Sep 2013 18:11:41 -0500 Subject: [PATCH 3/3] Fix --- UI/CwCheatScreen.cpp | 22 ---------------------- ffmpeg | 2 +- lang | 2 +- native | 2 +- pspautotests | 2 +- 5 files changed, 4 insertions(+), 26 deletions(-) diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 67e7a5cf4c..239688d653 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -111,15 +111,9 @@ UI::EventReturn CwCheatScreen::OnEnableAll(UI::EventParams ¶ms) std::vector temp = cheatList; enableAll = !enableAll; os.open(activeCheatFile.c_str()); -<<<<<<< HEAD for (int j = 0; j < cheatList.size(); j++) { if (enableAll == 1 && cheatList[j].substr(0, 3) == "_C0"){ cheatList[j].replace(0, 3, "_C1"); -======= - for (size_t j = 0; j < temp.size(); j++) { - if (enableAll == 1 && temp[j].substr(0, 3) == "_C0"){ - temp[j].replace(0,3,"_C1"); ->>>>>>> upstream2/master } else if (enableAll == 0 && cheatList[j].substr(0, 3) == "_C1") { @@ -131,15 +125,9 @@ UI::EventReturn CwCheatScreen::OnEnableAll(UI::EventParams ¶ms) for (int y = 0; y < 128; y++) { enableCheat[y] = enableAll; } -<<<<<<< HEAD for (int i = 0; i < cheatList.size(); i++) { os << cheatList[i]; if (i < cheatList.size() - 1) { -======= - for (int i = 0; i < (int)temp.size(); i++) { - os << temp[i]; - if (i < temp.size() - 1) { ->>>>>>> upstream2/master os << "\n"; } } @@ -173,13 +161,6 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) getline(is, line); title.push_back(line); getline(is, line); -<<<<<<< HEAD - - - -======= - ->>>>>>> upstream2/master do { if (finished == false){ getline(is, line); @@ -210,7 +191,6 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) if (finished == true) break; } -<<<<<<< HEAD is.close(); std::string title2; is.open(activeCheatFile.c_str()); @@ -220,8 +200,6 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) if (title2.substr(0, 2) != "_S") { os << title[0] << "\n" << title[1]; } -======= ->>>>>>> upstream2/master if (newList.size() != 0) { os << "\n"; diff --git a/ffmpeg b/ffmpeg index 2a1acf8603..c2b6c476b5 160000 --- a/ffmpeg +++ b/ffmpeg @@ -1 +1 @@ -Subproject commit 2a1acf86036e3ff159eca161b87c99a7048f6f95 +Subproject commit c2b6c476b5feafb610f4db2c3918ab8f619f7d07 diff --git a/lang b/lang index 1997dbc1ec..8651a82d8f 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 1997dbc1ec67420e75f5f1d0dd4019a48007096f +Subproject commit 8651a82d8f85f261762c9961f96b525210844523 diff --git a/native b/native index 0da853e54c..faf9714b56 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 0da853e54c6e1cce9b438f8db4454322c4c930fe +Subproject commit faf9714b563fb6343fe6d17305330bc715d8e532 diff --git a/pspautotests b/pspautotests index f5fa205057..30e70f0630 160000 --- a/pspautotests +++ b/pspautotests @@ -1 +1 @@ -Subproject commit f5fa205057dbbf80ec1e302c21d22c9ddd0ea03a +Subproject commit 30e70f0630542155cbc8ccf3508929be9a1d98d4