Simplify Cheat Pulse() logic wihen it comes to comparison type, and also fix comparison type logic that wasn't accounting for all the display types
This commit is contained in:
parent
b1c294c236
commit
bf544e02fa
|
@ -166,57 +166,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (!IsSeparator && _enabled)
|
||||
{
|
||||
if (_compare.HasValue)
|
||||
{
|
||||
switch (ComparisonType)
|
||||
{
|
||||
default:
|
||||
case CompareType.None: // This should never happen, but it's here just in case. adelikat: And yet it does! Cheat Code converter doesn't do this. Changing this to default to equal since 99.9999% of all cheats are going to be equals
|
||||
case CompareType.Equal:
|
||||
if (_compare.Value == _watch.Value)
|
||||
{
|
||||
PokeByte();
|
||||
}
|
||||
|
||||
break;
|
||||
case CompareType.GreaterThan:
|
||||
if (_compare.Value > _watch.Value)
|
||||
{
|
||||
PokeByte();
|
||||
}
|
||||
|
||||
break;
|
||||
case CompareType.GreaterThanOrEqual:
|
||||
if (_compare.Value >= _watch.Value)
|
||||
{
|
||||
PokeByte();
|
||||
}
|
||||
|
||||
break;
|
||||
case CompareType.LessThan:
|
||||
if (_compare.Value < _watch.Value)
|
||||
{
|
||||
PokeByte();
|
||||
}
|
||||
|
||||
break;
|
||||
case CompareType.LessThanOrEqual:
|
||||
if (_compare.Value <= _watch.Value)
|
||||
{
|
||||
PokeByte();
|
||||
}
|
||||
|
||||
break;
|
||||
case CompareType.NotEqual:
|
||||
if (_compare.Value != _watch.Value)
|
||||
{
|
||||
PokeByte();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (ShouldPoke())
|
||||
{
|
||||
switch (_watch.Size)
|
||||
{
|
||||
|
@ -234,6 +184,25 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
// Returns true if compare value exists, and the comparison type criteria matches
|
||||
private bool ShouldPoke()
|
||||
{
|
||||
if (_compare.HasValue)
|
||||
{
|
||||
return ComparisonType switch
|
||||
{
|
||||
CompareType.GreaterThan => _compare.Value > _watch.Value,
|
||||
CompareType.GreaterThanOrEqual => _compare.Value >= _watch.Value,
|
||||
CompareType.LessThan => _compare.Value < _watch.Value,
|
||||
CompareType.LessThanOrEqual => _compare.Value <= _watch.Value,
|
||||
CompareType.NotEqual => _compare.Value != _watch.Value,
|
||||
_ => _compare.Value == _watch.Value,
|
||||
};
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void PokeByte()
|
||||
{
|
||||
_watch.Poke(GetStringForPulse(_val));
|
||||
|
|
Loading…
Reference in New Issue