tastudio: use DivergentPoint() as a backup in case branches lose their states.

This commit is contained in:
feos 2015-09-23 19:42:41 +03:00
parent a31492a57f
commit 1175a86123
2 changed files with 10 additions and 3 deletions

View File

@ -480,12 +480,19 @@ namespace BizHawk.Client.Common
public void LoadBranch(TasBranch branch)
{
int? divergentPoint = DivergantPoint(_log, branch.InputLog);
int? divergentPoint = DivergentPoint(_log, branch.InputLog);
_log = branch.InputLog.ToList();
//_changes = true;
LagLog.FromLagLog(branch.LagLog);
// if there are branch states, they will be loaded anyway
// but if there's none, or only *after* divergent point, don't invalidate the entire movie anymore
if (divergentPoint.HasValue)
StateManager.Invalidate(divergentPoint.Value);
else
StateManager.Invalidate(branch.InputLog.Count);
StateManager.LoadBranch(Branches.IndexOf(branch));
StateManager.SetState(branch.Frame, branch.CoreData);
@ -496,7 +503,7 @@ namespace BizHawk.Client.Common
}
// TODO: use LogGenerators rather than string comparisons
private int? DivergantPoint(List<string> currentLog, List<string> newLog)
private int? DivergentPoint(List<string> currentLog, List<string> newLog)
{
int max = newLog.Count;
if (currentLog.Count < newLog.Count)

View File

@ -806,7 +806,7 @@ namespace BizHawk.Client.Common
{
int branchHash = _movie.BranchHashByIndex(index);
Invalidate(0); // Not a good way of doing it?
//Invalidate(0); // Not a good way of doing it?
foreach (KeyValuePair<int, SortedList<int, StateManagerState>> kvp in BranchStates)
{