Fix comments after code lines and avoid UI crash from empty comments

This commit is contained in:
LunaMoo 2016-10-24 04:37:49 +02:00
parent 4a977d87dd
commit 5765655214
2 changed files with 13 additions and 4 deletions

View file

@ -183,6 +183,11 @@ void CWCheatEngine::CreateCodeList() { //Creates code list to be used in functio
if (initialCodesList[i].substr(0,2) == "_L") {
if (cheatEnabled == true) {
currentcode = initialCodesList[i];
std::size_t comment = currentcode.find("//");
if (comment != std::string::npos) {
currentcode.erase(currentcode.begin() + comment, currentcode.end());
//Purge comments after code lines before adding them to codelist
}
currentcode.erase(currentcode.begin(), currentcode.begin() + 3);
codelist.push_back(currentcode);
}

View file

@ -274,8 +274,10 @@ UI::EventReturn CwCheatScreen::OnCheckBox(UI::EventParams &params) {
void CwCheatScreen::processFileOn(std::string activatedCheat) {
std::fstream fs;
for (size_t i = 0; i < cheatList.size(); i++) {
if (cheatList[i].substr(4) == activatedCheat) {
cheatList[i] = "_C1 " + activatedCheat;
if (cheatList[i].length() >= 4) {
if (cheatList[i].substr(4) == activatedCheat) {
cheatList[i] = "_C1 " + activatedCheat;
}
}
}
@ -293,8 +295,10 @@ void CwCheatScreen::processFileOn(std::string activatedCheat) {
void CwCheatScreen::processFileOff(std::string deactivatedCheat) {
std::fstream fs;
for (size_t i = 0; i < cheatList.size(); i++) {
if (cheatList[i].substr(4) == deactivatedCheat) {
cheatList[i] = "_C0 " + deactivatedCheat;
if (cheatList[i].length() >= 4) {
if (cheatList[i].substr(4) == deactivatedCheat) {
cheatList[i] = "_C0 " + deactivatedCheat;
}
}
}