TasStateManager.cs -> fixed stateHasDuplicate
This commit is contained in:
parent
8b5440d963
commit
a751412c1f
|
@ -138,7 +138,8 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (frame == 0) {
|
if (frame == 0)
|
||||||
|
{
|
||||||
return new KeyValuePair<int, byte[]>(0, InitialState);
|
return new KeyValuePair<int, byte[]>(0, InitialState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +392,7 @@ namespace BizHawk.Client.Common
|
||||||
else
|
else
|
||||||
Used -= (ulong)BranchStates[frame][branch].Length;
|
Used -= (ulong)BranchStates[frame][branch].Length;
|
||||||
BranchStates[frame].RemoveAt(BranchStates[frame].IndexOfKey(branch));
|
BranchStates[frame].RemoveAt(BranchStates[frame].IndexOfKey(branch));
|
||||||
|
|
||||||
if (BranchStates[frame].Count == 0)
|
if (BranchStates[frame].Count == 0)
|
||||||
BranchStates.Remove(frame);
|
BranchStates.Remove(frame);
|
||||||
}
|
}
|
||||||
|
@ -716,7 +717,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
StateManagerState stateToMatch;
|
StateManagerState stateToMatch;
|
||||||
|
|
||||||
// figure out what state we're checking
|
// Get the state instance
|
||||||
if (branchHash == -1)
|
if (branchHash == -1)
|
||||||
stateToMatch = States[frame];
|
stateToMatch = States[frame];
|
||||||
else
|
else
|
||||||
|
@ -724,26 +725,28 @@ namespace BizHawk.Client.Common
|
||||||
if (!BranchStates[frame].ContainsKey(branchHash))
|
if (!BranchStates[frame].ContainsKey(branchHash))
|
||||||
return -2;
|
return -2;
|
||||||
stateToMatch = BranchStates[frame][branchHash];
|
stateToMatch = BranchStates[frame][branchHash];
|
||||||
//if (States.ContainsKey(frame) && States[frame] == stateToMatch)
|
// Check the current branch for duplicate.
|
||||||
// return -1;
|
if (States.ContainsKey(frame) && States[frame] == stateToMatch)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there's no state for that frame at all
|
// Check if there are any branch states for the given frame.
|
||||||
if (!BranchStates.ContainsKey(frame))
|
if (!BranchStates.ContainsKey(frame) || BranchStates[frame] == null)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
// find the branches whose state for that frame is the same
|
// Loop through branch states for the given frame.
|
||||||
SortedList<int, StateManagerState> stateList = BranchStates[frame];
|
SortedList<int, StateManagerState> stateList = BranchStates[frame];
|
||||||
for (int i = 0; i < _movie.BranchCount; i++)
|
for (int i = 0; i < _movie.BranchCount; i++)
|
||||||
{
|
{
|
||||||
|
// Don't check the branch containing the state to match.
|
||||||
if (i == _movie.BranchIndexByHash(branchHash))
|
if (i == _movie.BranchIndexByHash(branchHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (stateList != null && stateList.ContainsKey(i) && stateList[i] == stateToMatch)
|
if (stateList.Values[i] == stateToMatch)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -2;
|
return -2; // No match.
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point findState(StateManagerState s)
|
private Point findState(StateManagerState s)
|
||||||
|
@ -795,13 +798,11 @@ namespace BizHawk.Client.Common
|
||||||
if (stateList == null)
|
if (stateList == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (stateHasDuplicate(kvp.Key, branchHash) == -2)
|
if (stateList.ContainsKey(branchHash))
|
||||||
{
|
{
|
||||||
if (stateList.ContainsKey(branchHash))
|
if (stateHasDuplicate(kvp.Key, branchHash) == -2)
|
||||||
{
|
{
|
||||||
if (stateList[branchHash].IsOnDisk)
|
if (!stateList[branchHash].IsOnDisk)
|
||||||
{ }
|
|
||||||
else
|
|
||||||
Used -= (ulong)stateList[branchHash].Length;
|
Used -= (ulong)stateList[branchHash].Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -823,13 +824,11 @@ namespace BizHawk.Client.Common
|
||||||
if (stateList == null)
|
if (stateList == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (stateHasDuplicate(kvp.Key, branchHash) == -2)
|
if (stateList.ContainsKey(branchHash))
|
||||||
{
|
{
|
||||||
if (stateList.ContainsKey(branchHash))
|
if (stateHasDuplicate(kvp.Key, branchHash) == -2)
|
||||||
{
|
{
|
||||||
if (stateList[branchHash].IsOnDisk)
|
if (!stateList[branchHash].IsOnDisk)
|
||||||
{ }
|
|
||||||
else
|
|
||||||
Used -= (ulong)stateList[branchHash].Length;
|
Used -= (ulong)stateList[branchHash].Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue