From 738e53989e29c912eba3be4656df18cecc76e69b Mon Sep 17 00:00:00 2001 From: BearOso Date: Sat, 18 May 2024 19:25:33 -0500 Subject: [PATCH] Cheats: Retain enabled state when updating existing cheat. Fix inverted logic in Qt cheat window. --- cheats2.cpp | 4 ++++ qt/src/CheatsDialog.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cheats2.cpp b/cheats2.cpp index 8f8ac473..7d2080a9 100644 --- a/cheats2.cpp +++ b/cheats2.cpp @@ -518,10 +518,14 @@ int S9xModifyCheatGroup(uint32 num, const std::string &name, const std::string & if (num >= Cheat.group.size()) return -1; + bool enabled = Cheat.group[num].enabled; S9xDisableCheatGroup(num); Cheat.group[num] = S9xCreateCheatGroup(name, cheat); + if (enabled) + S9xEnableCheatGroup(num); + return num; } diff --git a/qt/src/CheatsDialog.cpp b/qt/src/CheatsDialog.cpp index d260b1d5..7073d33d 100644 --- a/qt/src/CheatsDialog.cpp +++ b/qt/src/CheatsDialog.cpp @@ -63,7 +63,7 @@ void CheatsDialog::addCode() if (description.empty()) description = tr("No description").toStdString(); - if (app->addCheat(description, code)) + if (!app->addCheat(description, code)) { QMessageBox::information(this, tr("Invalid Cheat"), tr("The cheat you entered was not valid.")); return;