From fc1a8fc1f3f6cf8d629fd5dfadf5fe75ac334dee Mon Sep 17 00:00:00 2001 From: Steven Cherry Date: Mon, 17 Jun 2013 17:44:41 -0500 Subject: [PATCH 1/2] Fix bug with titles containing "/" Also, add comments to help those reading the code. --- Core/CwCheat.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 554985c6c7..9d2bf42861 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -23,6 +23,9 @@ void __CheatInit() { if (gameTitle.find("™")!= std::string::npos) { gameTitle.erase (gameTitle.find("™"), std::string::npos); } + while (gameTitle.find("/")!= std::string::npos) { + gameTitle.replace (gameTitle.find("/"),1," "); + } activeCheatFile = CHEATS_DIR + "/" + gameTitle +".ini"; File::CreateFullPath(CHEATS_DIR); @@ -51,7 +54,7 @@ void __CheatShutdown() { void hleCheat(u64 userdata, int cyclesLate) { CoreTiming::ScheduleEvent(msToCycles(77), CheatEvent, 0); - if (g_Config.bReloadCheats == true) { + if (g_Config.bReloadCheats == true) { //Checks if the "reload cheats" button has been pressed. cheatEngine->CreateCodeList(); g_Config.bReloadCheats = false; } @@ -67,7 +70,7 @@ CWCheatEngine::CWCheatEngine() { void CWCheatEngine::Exit() { exit2 = true; } -void CWCheatEngine::CreateCodeList() { +void CWCheatEngine::CreateCodeList() { //Creates code list to be used in function GetNextCode initialCodesList = GetCodesList(); std::string currentcode, codename; std::vector codelist; @@ -99,7 +102,7 @@ void CWCheatEngine::CreateCodeList() { } parts = makeCodeParts(codelist); } -inline std::vector makeCodeParts(std::vector CodesList) { +inline std::vector makeCodeParts(std::vector CodesList) { //Takes a single code line and creates a two-part vector for all codes. Feeds to CreateCodeList std::string currentcode; std::vector finalList; char split_char = '\n'; @@ -120,7 +123,7 @@ inline std::vector makeCodeParts(std::vector CodesList } return finalList; } -std::vector CWCheatEngine::GetNextCode() { +std::vector CWCheatEngine::GetNextCode() { // Feeds a size-2 vector of ints to Run() which contains the address and value of one cheat. std::string code1; std::string code2; std::vector splitCode; @@ -162,8 +165,7 @@ void CWCheatEngine::SkipAllCodes() { currentCode = codes.size(); } -int CWCheatEngine::GetAddress(int value) { - // The User space base address has to be added to given value +int CWCheatEngine::GetAddress(int value) { //Returns static address used by ppsspp. Some games may not like this, and causes cheats to not work without offset return (value + 0x08800000) & 0x3FFFFFFF; } @@ -178,7 +180,7 @@ inline void trim2(std::string& str) { else str.erase(str.begin(), str.end()); } -std::vector CWCheatEngine::GetCodesList() { +std::vector CWCheatEngine::GetCodesList() { //Reads the entire cheat list from the appropriate .ini. std::string line; std::vector codesList; // Read from INI here std::ifstream list(activeCheatFile.c_str()); From 83549aa43eab7619b263041a7ddc09129453a605 Mon Sep 17 00:00:00 2001 From: Steven Cherry Date: Mon, 17 Jun 2013 17:58:29 -0500 Subject: [PATCH 2/2] Another small fix for ":" character --- Core/CwCheat.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 9d2bf42861..2c0d93934f 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -20,12 +20,16 @@ void trim2(std::string& str); void __CheatInit() { //Moved createFullPath to CheatInit from the constructor because it spams the log and constantly checks if exists. In here, only checks once. std::string gameTitle = g_paramSFO.GetValueString("DISC_ID") + " - " + g_paramSFO.GetValueString("TITLE"); + //These 3 statements clean up the title, which sometimes contain characters that will cause problems when creating the .ini if (gameTitle.find("™")!= std::string::npos) { gameTitle.erase (gameTitle.find("™"), std::string::npos); } while (gameTitle.find("/")!= std::string::npos) { gameTitle.replace (gameTitle.find("/"),1," "); } + if (gameTitle.find(":")!= std::string::npos) { + gameTitle.replace (gameTitle.find(":"),1," "); + } activeCheatFile = CHEATS_DIR + "/" + gameTitle +".ini"; File::CreateFullPath(CHEATS_DIR);