refactor cheatlist and watchlist to use MemoryDomain name indexing
This commit is contained in:
parent
1061add64f
commit
6f1090c87f
|
@ -333,7 +333,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
compare = Int32.Parse(vals[2], NumberStyles.HexNumber);
|
||||
}
|
||||
MemoryDomain domain = DomainByName(vals[3]);
|
||||
MemoryDomain domain = Global.Emulator.MemoryDomains[vals[3]];
|
||||
bool ENABLED = vals[4] == "1";
|
||||
string name = vals[5];
|
||||
|
||||
|
@ -554,21 +554,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
#region Privates
|
||||
|
||||
//TODO: remove this and make MemoryDomains in IEmulator support this
|
||||
private static MemoryDomain DomainByName(string name)
|
||||
{
|
||||
//Attempts to find the memory domain by name, if it fails, it defaults to index 0
|
||||
foreach (MemoryDomain domain in Global.Emulator.MemoryDomains)
|
||||
{
|
||||
if (domain.Name == name)
|
||||
{
|
||||
return domain;
|
||||
}
|
||||
}
|
||||
|
||||
return Global.Emulator.MemoryDomains.MainMemory;
|
||||
}
|
||||
|
||||
private void CheatChanged(object sender)
|
||||
{
|
||||
if (Changed != null)
|
||||
|
|
|
@ -481,7 +481,7 @@ namespace BizHawk.Client.Common
|
|||
startIndex = line.IndexOf('\t') + 1;
|
||||
line = line.Substring(startIndex, line.Length - startIndex); //Domain
|
||||
temp = line.Substring(0, line.IndexOf('\t'));
|
||||
memDomain = Global.Emulator.MemoryDomains[GetDomainPos(temp)];
|
||||
memDomain = Global.Emulator.MemoryDomains[temp];
|
||||
}
|
||||
|
||||
startIndex = line.IndexOf('\t') + 1;
|
||||
|
@ -495,7 +495,7 @@ namespace BizHawk.Client.Common
|
|||
type,
|
||||
notes,
|
||||
bigEndian));
|
||||
_domain = Global.Emulator.MemoryDomains[GetDomainPos(domain)];
|
||||
_domain = Global.Emulator.MemoryDomains[domain];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,17 +511,6 @@ namespace BizHawk.Client.Common
|
|||
return true;
|
||||
}
|
||||
|
||||
private static int GetDomainPos(string name)
|
||||
{
|
||||
//Attempts to find the memory domain by name, if it fails, it defaults to index 0
|
||||
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
|
||||
{
|
||||
if (Global.Emulator.MemoryDomains[x].Name == name)
|
||||
return x;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue