CheatList - has memory domains passed in to the Load() method

This commit is contained in:
adelikat 2020-05-25 17:50:42 -05:00
parent 8798d0c03e
commit 7a374f0013
4 changed files with 9 additions and 9 deletions

View File

@ -72,10 +72,10 @@ namespace BizHawk.Client.Common
/// <summary>
/// Looks for a .cht file that matches the ROM loaded based on the default filename for a given ROM
/// </summary>
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];

View File

@ -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<Cheats>();
}

View File

@ -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");
}

View File

@ -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);