Skip to content

Commit a7a76c9

Browse files
committed
fix state manager Unreserve logic to always reject Unreserve(0)
by simply flipping these two ifs. It was not expected for a state manager to have only one state, which was the only scenario in which this would throw.
1 parent feb6b87 commit a7a76c9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/BizHawk.Client.Common/movie/tasproj/ZwinderStateManager.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,19 @@ private bool ShouldKeepForAncient(int frame)
340340
int index = StateCache.BinarySearch(frame + 1);
341341
if (index < 0)
342342
index = ~index;
343+
if (index <= 1)
344+
{
345+
// index == 0 should not be possible. (It's the index of the state after the given frame.)
346+
// index == 1 would mean we are considering removing the state on frame 0.
347+
// We must always have a state on frame 0.
348+
return true;
349+
}
343350
if (index == StateCache.Count)
344351
{
345352
// There is no future state, so there is no gap between states for us to measure.
346353
// We're probably unreserving for a marker removal. Allow it to be removed, so we don't pollute _reserved.
347354
return false;
348355
}
349-
if (index <= 1)
350-
// index == 0 should not be possible. (It's the index of the state after the given frame.)
351-
// index == 1 would mean we are considering removing the state on frame 0.
352-
// We must always have a state on frame 0.
353-
return true;
354356

355357
int nextState = StateCache[index];
356358
int previousState = StateCache[index - 2]; // assume StateCache[index - 1] == frame

0 commit comments

Comments
 (0)