refactor cheatlist and watchlist to use MemoryDomain name indexing

This commit is contained in:
adelikat 2013-11-06 02:25:27 +00:00
parent 1061add64f
commit 6f1090c87f
2 changed files with 3 additions and 29 deletions

View File

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

View File

@ -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
}
}