From 7a374f001377fb511415f07f7567fc9b0be24686 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 25 May 2020 17:50:42 -0500 Subject: [PATCH] CheatList - has memory domains passed in to the Load() method --- src/BizHawk.Client.Common/tools/CheatList.cs | 8 ++++---- src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs | 2 +- src/BizHawk.Client.EmuHawk/MainForm.cs | 4 ++-- src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/BizHawk.Client.Common/tools/CheatList.cs b/src/BizHawk.Client.Common/tools/CheatList.cs index 468a229c9a..d7d8913ae7 100644 --- a/src/BizHawk.Client.Common/tools/CheatList.cs +++ b/src/BizHawk.Client.Common/tools/CheatList.cs @@ -72,10 +72,10 @@ namespace BizHawk.Client.Common /// /// Looks for a .cht file that matches the ROM loaded based on the default filename for a given ROM /// - public bool AttemptToLoadCheatFile() + public bool AttemptToLoadCheatFile(IMemoryDomains domains) { var file = new FileInfo(_defaultFileName); - return file.Exists && Load(file.FullName, false); + return file.Exists && Load(domains, file.FullName, false); } public void NewList(string defaultFileName, bool autosave = false) @@ -321,7 +321,7 @@ namespace BizHawk.Client.Common } } - public bool Load(string path, bool append) + public bool Load(IMemoryDomains domains, string path, bool append) { var file = new FileInfo(path); if (file.Exists == false) @@ -376,7 +376,7 @@ namespace BizHawk.Client.Common compare = int.Parse(vals[2], NumberStyles.HexNumber); } - var domain = Global.Emulator.AsMemoryDomains()[vals[3]]; + var domain = domains[vals[3]]; var enabled = vals[4] == "1"; var name = vals[5]; diff --git a/src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs b/src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs index 1facad1aee..0cd6c43f3f 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs @@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk private void LoadCheats(string filename, string archive = null) { - CheatList.Load(filename, false); + CheatList.Load(Emulator.AsMemoryDomains(), filename, false); Tools.Load(); } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 36049601df..4aa3af9b2c 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3748,10 +3748,10 @@ namespace BizHawk.Client.EmuHawk Tools.Restart(Emulator); - if (Config.LoadCheatFileByGame) + if (Config.LoadCheatFileByGame && Emulator.HasMemoryDomains()) { CheatList.SetDefaultFileName(Tools.GenerateDefaultCheatFilename()); - if (CheatList.AttemptToLoadCheatFile()) + if (CheatList.AttemptToLoadCheatFile(Emulator.AsMemoryDomains())) { AddOnScreenMessage("Cheats file loaded"); } diff --git a/src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index 1492ad2a5a..43c686e5c4 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -73,7 +73,7 @@ namespace BizHawk.Client.EmuHawk var askResult = !Global.CheatList.Changes || AskSaveChanges(); if (askResult) { - var loadResult = Global.CheatList.Load(path, append: false); + var loadResult = Global.CheatList.Load(Core, path, append: false); if (!loadResult) { Config.RecentCheats.HandleLoadError(path); @@ -108,7 +108,7 @@ namespace BizHawk.Client.EmuHawk if (result) { - Global.CheatList.Load(file.FullName, append); + Global.CheatList.Load(Core, file.FullName, append); GeneralUpdate(); UpdateMessageLabel(); Config.RecentCheats.Add(Global.CheatList.CurrentFileName);