diff --git a/Cores/DeltaCore b/Cores/DeltaCore index a20b36f..d8532bd 160000 --- a/Cores/DeltaCore +++ b/Cores/DeltaCore @@ -1 +1 @@ -Subproject commit a20b36f96e52bc236d243cd8b1b55fc5e1bbf76c +Subproject commit d8532bd184a9a1e87b48ad5ad9f4a6d24d81783f diff --git a/Cores/SNESDeltaCore b/Cores/SNESDeltaCore index cac97f6..58dce56 160000 --- a/Cores/SNESDeltaCore +++ b/Cores/SNESDeltaCore @@ -1 +1 @@ -Subproject commit cac97f68eea3eb85471a16b468ae8da6fa1038e6 +Subproject commit 58dce561dd80baf954f487fc8fa15aae998559a6 diff --git a/Delta/Emulation/EmulationViewController.swift b/Delta/Emulation/EmulationViewController.swift index b724e80..4cdd49e 100644 --- a/Delta/Emulation/EmulationViewController.swift +++ b/Delta/Emulation/EmulationViewController.swift @@ -347,9 +347,9 @@ extension EmulationViewController: CheatsViewControllerDelegate try self.emulatorCore.activateCheat(cheat) } - func cheatsViewController(cheatsViewController: CheatsViewController, didDeactivateCheat cheat: Cheat) throws + func cheatsViewController(cheatsViewController: CheatsViewController, didDeactivateCheat cheat: Cheat) { - try self.emulatorCore.deactivateCheat(cheat) + self.emulatorCore.deactivateCheat(cheat) } private func updateCheats() @@ -370,31 +370,26 @@ extension EmulationViewController: CheatsViewControllerDelegate let cheats = Cheat.instancesWithPredicate(predicate, inManagedObjectContext: backgroundContext, type: Cheat.self) for cheat in cheats { - do + if cheat.enabled { - if cheat.enabled + do { try self.emulatorCore.activateCheat(cheat) } - else + catch EmulatorCore.CheatError.invalid { - try self.emulatorCore.deactivateCheat(cheat) + print("Invalid cheat:", cheat.name, cheat.code) } + catch let error as NSError + { + print("Unknown Cheat Error:", error, cheat.name, cheat.code) + } + } - catch EmulatorCore.CheatError.invalid + else { - print("Invalid cheat:", cheat.name, cheat.code) + self.emulatorCore.deactivateCheat(cheat) } - catch EmulatorCore.CheatError.doesNotExist - { - // Ignore this error, because we could be deactivating a cheat that hasn't yet been activated - print("Cheat does not exist:", cheat.name, cheat.code) - } - catch let error as NSError - { - print("Unknown Cheat Error:", error, cheat.name, cheat.code) - } - } if running diff --git a/Delta/Pause Menu/Cheats/CheatsViewController.swift b/Delta/Pause Menu/Cheats/CheatsViewController.swift index 87dcac6..754239e 100644 --- a/Delta/Pause Menu/Cheats/CheatsViewController.swift +++ b/Delta/Pause Menu/Cheats/CheatsViewController.swift @@ -17,7 +17,7 @@ protocol CheatsViewControllerDelegate: class { func cheatsViewControllerActiveEmulatorCore(saveStatesViewController: CheatsViewController) -> EmulatorCore func cheatsViewController(cheatsViewController: CheatsViewController, didActivateCheat cheat: Cheat) throws - func cheatsViewController(cheatsViewController: CheatsViewController, didDeactivateCheat cheat: Cheat) throws + func cheatsViewController(cheatsViewController: CheatsViewController, didDeactivateCheat cheat: Cheat) } class CheatsViewController: UITableViewController @@ -121,7 +121,7 @@ private extension CheatsViewController func deleteCheat(cheat: Cheat) { - let _ = try? self.delegate.cheatsViewController(self, didDeactivateCheat: cheat) + self.delegate.cheatsViewController(self, didDeactivateCheat: cheat) let backgroundContext = DatabaseManager.sharedManager.backgroundManagedObjectContext() backgroundContext.performBlock { @@ -191,30 +191,27 @@ extension CheatsViewController let temporaryCheat = backgroundContext.objectWithID(cheat.objectID) as! Cheat temporaryCheat.enabled = !temporaryCheat.enabled - do + if temporaryCheat.enabled { - if temporaryCheat.enabled + do { try self.delegate.cheatsViewController(self, didActivateCheat: temporaryCheat) } - else + catch EmulatorCore.CheatError.invalid { - try self.delegate.cheatsViewController(self, didDeactivateCheat: temporaryCheat) + print("Invalid cheat:", cheat.name, cheat.code) + } + catch let error as NSError + { + print("Unknown Cheat Error:", error, cheat.name, cheat.code) } } - catch EmulatorCore.CheatError.invalid + else { - print("Invalid cheat:", cheat.name, cheat.code) - } - catch EmulatorCore.CheatError.doesNotExist - { - print("Cheat does not exist:", cheat.name, cheat.code) - } - catch let error as NSError - { - print("Unknown Cheat Error:", error, cheat.name, cheat.code) + self.delegate.cheatsViewController(self, didDeactivateCheat: temporaryCheat) } + backgroundContext.saveWithErrorLogging() } @@ -281,22 +278,14 @@ extension CheatsViewController: EditCheatViewControllerDelegate guard previousCheat.code != code else { return } - do - { - try self.delegate.cheatsViewController(self, didDeactivateCheat: previousCheat) - } - catch let error as NSError - { - print(error) - } - + self.delegate.cheatsViewController(self, didDeactivateCheat: previousCheat) }) } } func editCheatViewController(editCheatViewController: EditCheatViewController, deactivateCheat cheat: Cheat) { - let _ = try? self.delegate.cheatsViewController(self, didDeactivateCheat: cheat) + self.delegate.cheatsViewController(self, didDeactivateCheat: cheat) } }