tastudio: fix yet another branch crash.
This commit is contained in:
parent
bafe41fa54
commit
b5582722c8
|
@ -378,6 +378,9 @@ 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)
|
||||||
|
BranchStates.Remove(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasDuplicate)
|
if (!hasDuplicate)
|
||||||
|
@ -650,30 +653,34 @@ namespace BizHawk.Client.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the state at frame in the given branch (-1 for current) has any duplicates.
|
/// Checks if the state at frame in the given branch (-1 for current) has any duplicates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns the ID of the branch (-1 for current) of the first match. If no match, returns -2.</returns>
|
/// <returns>Index of the branch (-1 for current) of the first match. If no match, returns -2.</returns>
|
||||||
private int stateHasDuplicate(int frame, int branch)
|
private int stateHasDuplicate(int frame, int branchHash)
|
||||||
{
|
{
|
||||||
StateManagerState stateToMatch;
|
StateManagerState stateToMatch;
|
||||||
if (branch == -1)
|
|
||||||
|
// figure out what state we're checking
|
||||||
|
if (branchHash == -1)
|
||||||
stateToMatch = States[frame];
|
stateToMatch = States[frame];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!BranchStates[frame].ContainsKey(branch))
|
if (!BranchStates[frame].ContainsKey(branchHash))
|
||||||
return -2;
|
return -2;
|
||||||
stateToMatch = BranchStates[frame][branch];
|
stateToMatch = BranchStates[frame][branchHash];
|
||||||
if (States.ContainsKey(frame) && States[frame] == stateToMatch)
|
if (States.ContainsKey(frame) && States[frame] == stateToMatch)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// there's no state for that frame at all
|
||||||
if (!BranchStates.ContainsKey(frame))
|
if (!BranchStates.ContainsKey(frame))
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
|
// find the branches whose state for that frame is the same
|
||||||
|
SortedList<int, StateManagerState> stateList = BranchStates[frame];
|
||||||
for (int i = 0; i < _movie.BranchCount; i++)
|
for (int i = 0; i < _movie.BranchCount; i++)
|
||||||
{
|
{
|
||||||
if (i == branch)
|
if (i == _movie.BranchIndexByHash(branchHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SortedList<int, StateManagerState> stateList = BranchStates[frame];
|
|
||||||
if (stateList != null && stateList.ContainsKey(i) && stateList[i] == stateToMatch)
|
if (stateList != null && stateList.ContainsKey(i) && stateList[i] == stateToMatch)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue