From cacfb615c44200e67d6635bb86480f188f6b8aee Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 16 Feb 2016 20:02:57 -0500 Subject: [PATCH] simplify Cheat.cs somewhat --- BizHawk.Client.Common/tools/Cheat.cs | 31 +++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs index e98a77fa02..2beb9c1cea 100644 --- a/BizHawk.Client.Common/tools/Cheat.cs +++ b/BizHawk.Client.Common/tools/Cheat.cs @@ -1,6 +1,4 @@ -using System.Linq; - -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { @@ -50,10 +48,10 @@ namespace BizHawk.Client.Common cheat.Domain, cheat.Address ?? 0, cheat.Size, - cheat.Type, + cheat.Type, cheat.BigEndian ?? false, cheat.Name - ); + ); _compare = cheat.Compare; _val = cheat.Value ?? 0; @@ -238,46 +236,45 @@ namespace BizHawk.Client.Common { switch (_comparisonType) { - case Cheat.COMPARISONTYPE.NONE: // This should never happen, but it's here just in case + default: + case COMPARISONTYPE.NONE: // This should never happen, but it's here just in case break; - case Cheat.COMPARISONTYPE.EQUAL: + case COMPARISONTYPE.EQUAL: if (_compare.Value == _watch.ValueNoFreeze) { _watch.Poke(GetStringForPulse(_val)); } break; - case Cheat.COMPARISONTYPE.GREATER_THAN: + case COMPARISONTYPE.GREATER_THAN: if (_compare.Value > _watch.ValueNoFreeze) { _watch.Poke(GetStringForPulse(_val)); } break; - case Cheat.COMPARISONTYPE.GREATER_THAN_OR_EQUAL: + case COMPARISONTYPE.GREATER_THAN_OR_EQUAL: if (_compare.Value >= _watch.ValueNoFreeze) { _watch.Poke(GetStringForPulse(_val)); } break; - case Cheat.COMPARISONTYPE.LESS_THAN: + case COMPARISONTYPE.LESS_THAN: if (_compare.Value < _watch.ValueNoFreeze) { _watch.Poke(GetStringForPulse(_val)); } break; - case Cheat.COMPARISONTYPE.LESS_THAN_OR_EQUAL: + case COMPARISONTYPE.LESS_THAN_OR_EQUAL: if (_compare.Value <= _watch.ValueNoFreeze) { _watch.Poke(GetStringForPulse(_val)); } break; - case Cheat.COMPARISONTYPE.NOT_EQUAL: + case COMPARISONTYPE.NOT_EQUAL: if (_compare.Value != _watch.ValueNoFreeze) { _watch.Poke(GetStringForPulse(_val)); } break; - default : - break; } } else @@ -413,13 +410,13 @@ namespace BizHawk.Client.Common if (obj is Watch) { var watch = obj as Watch; - return this.Domain == watch.Domain && this.Address == watch.Address; + return Domain == watch.Domain && Address == watch.Address; } if (obj is Cheat) { var cheat = obj as Cheat; - return this.Domain == cheat.Domain && this.Address == cheat.Address; + return Domain == cheat.Domain && Address == cheat.Address; } return base.Equals(obj); @@ -427,7 +424,7 @@ namespace BizHawk.Client.Common public override int GetHashCode() { - return this.Domain.GetHashCode() + (int)(this.Address ?? 0); + return Domain.GetHashCode() + (int)(Address ?? 0); } public static bool operator ==(Cheat a, Cheat b)