From 7915ec8bc10989c61b469909ecaf6a988793cf8b Mon Sep 17 00:00:00 2001 From: vadosnaprimer Date: Thu, 18 Apr 2019 19:11:27 +0300 Subject: [PATCH] tsm decay: try to work around some more removal bugs --- BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs b/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs index 4d551f86e6..f7b3130881 100644 --- a/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs +++ b/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs @@ -156,6 +156,8 @@ namespace BizHawk.Client.Common backwardFrame = currentFrame; } } + + int decayStatesLast = decayStates; if (forwardFrame > -1 && backwardFrame > -1) { @@ -192,10 +194,11 @@ namespace BizHawk.Client.Common decayStates--; } } - else - { + // we're very sorry about failing to find states to remove, but we can't go beyond capacity, so remove at least something // this shouldn't happen, but if we don't do it here, nothing good will happen either + if (decayStatesLast == decayStates) + { if (_tsm.RemoveState(_tsm.GetStateFrameByIndex(1))) { // decrementing this if no state was removed is BAD