Cheats - address issue 148, instead of throwing an exception when attempting to add an out of range address, present an error message. One odd side effect is that it will add a separator instead, but I think that's acceptable for now.

This commit is contained in:
adelikat 2014-03-23 15:58:44 +00:00
parent 1e9374e4e4
commit b378cd13e4
1 changed files with 22 additions and 12 deletions

View File

@ -271,19 +271,29 @@ namespace BizHawk.Client.EmuHawk
{ {
get get
{ {
var watch = Watch.GenerateWatch( var domain = Global.Emulator.MemoryDomains[DomainDropDown.SelectedItem.ToString()];
Global.Emulator.MemoryDomains[DomainDropDown.SelectedItem.ToString()], var address = AddressBox.ToRawInt().Value;
AddressBox.ToRawInt().Value, if (address < domain.Size)
GetCurrentSize(), {
Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()), var watch = Watch.GenerateWatch(
NameBox.Text, Global.Emulator.MemoryDomains[DomainDropDown.SelectedItem.ToString()],
BigEndianCheckBox.Checked); AddressBox.ToRawInt().Value,
GetCurrentSize(),
Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()),
NameBox.Text,
BigEndianCheckBox.Checked);
return new Cheat( return new Cheat(
watch, watch,
ValueBox.ToRawInt().Value, ValueBox.ToRawInt().Value,
CompareBox.ToRawInt() CompareBox.ToRawInt()
); );
}
else
{
MessageBox.Show(address.ToString() + " is not a valid address for the domain " + domain.Name, "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return Cheat.Separator;
}
} }
} }