From d79a00f035bf5a62cd807229505a8b8932e75ac5 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 15 Jun 2019 16:17:49 -0500 Subject: [PATCH] remove IStateManager.IsMarkerState --- .../movie/tasproj/IStateManager.cs | 6 ++++-- .../movie/tasproj/StateManagerDecay.cs | 13 +++++++----- .../movie/tasproj/TasStateManager.cs | 20 +++++++++---------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/BizHawk.Client.Common/movie/tasproj/IStateManager.cs b/BizHawk.Client.Common/movie/tasproj/IStateManager.cs index 265c15e342..c1d430e5bd 100644 --- a/BizHawk.Client.Common/movie/tasproj/IStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/IStateManager.cs @@ -46,8 +46,6 @@ namespace BizHawk.Client.Common int Last { get; } - bool IsMarkerState(int frame); - void UpdateStateFrequency(); /// @@ -60,6 +58,10 @@ namespace BizHawk.Client.Common /// int GetStateFrameByIndex(int index); + /// + /// Directly remove a state from the given frame, if it exists + /// Should only be called by pruning operations + /// bool Remove(int frame); } } diff --git a/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs b/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs index 88a47ff934..fb4f28e861 100644 --- a/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs +++ b/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs @@ -79,15 +79,17 @@ namespace BizHawk.Client.Common { int currentFrame = _tsm.GetStateFrameByIndex(currentStateIndex); - if (_tsm.IsMarkerState(currentFrame)) + if (_movie.Markers.IsMarker(currentFrame + 1)) { continue; } - else if (currentFrame + 1 == _movie.LastEditedFrame) + + if (currentFrame + 1 == _movie.LastEditedFrame) { continue; } - else if (currentFrame % _step > 0) + + if (currentFrame % _step > 0) { // ignore the pattern if the state doesn't belong already, drop it blindly and skip everything if (_tsm.Remove(currentFrame)) @@ -124,11 +126,12 @@ namespace BizHawk.Client.Common { int currentFrame = _tsm.GetStateFrameByIndex(currentStateIndex); - if (_tsm.IsMarkerState(currentFrame)) + if (_movie.Markers.IsMarker(currentFrame + 1)) { continue; } - else if ((currentFrame % _step > 0) && (currentFrame + 1 != _movie.LastEditedFrame)) + + if ((currentFrame % _step > 0) && (currentFrame + 1 != _movie.LastEditedFrame)) { // ignore the pattern if the state doesn't belong already, drop it blindly and skip everything if (_tsm.Remove(currentFrame)) diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs index cbd3cdb54a..8568b20d8c 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs @@ -198,16 +198,6 @@ namespace BizHawk.Client.Common return anyInvalidated; } - public bool IsMarkerState(int frame) - { - if (frame == -1) - { - return false; - } - - return _movie.Markers.IsMarker(frame + 1); - } - public bool Remove(int frame) { int index = _states.IndexOfKey(frame); @@ -291,6 +281,16 @@ namespace BizHawk.Client.Common return _states.Keys[index]; } + private bool IsMarkerState(int frame) + { + if (frame == -1) + { + return false; + } + + return _movie.Markers.IsMarker(frame + 1); + } + private void SetState(int frame, byte[] state, bool skipRemoval = true) { if (!skipRemoval) // skipRemoval: false only when capturing new states