Tastudio - branches - invalidate on branch load at the point the branch diverges from the current greenzone, not at frame 0

This commit is contained in:
adelikat 2015-07-25 16:24:38 -04:00
parent bac2ba42a6
commit df41eeffc3
1 changed files with 32 additions and 1 deletions

View File

@ -457,13 +457,44 @@ namespace BizHawk.Client.Common
public void LoadBranch(TasBranch branch)
{
int? divergentPoint = DivergantPoint(_log, branch.InputLog);
_log = branch.InputLog;
_changes = true;
StateManager.ClearStateHistory();
if (divergentPoint.HasValue)
{
StateManager.Invalidate(divergentPoint.Value);
}
else
{
StateManager.Invalidate(branch.InputLog.Count);
}
StateManager.SetState(branch.Frame, branch.CoreData);
//LagLog.Clear(); LagLog and InputLog is the same reference as what's in the branch!
LagLog.FromLagLog(branch.LagLog);
ChangeLog = branch.ChangeLog;
}
// TODO: use LogGenerators rather than string comparisons
private int? DivergantPoint(List<string> currentLog, List<string> newLog)
{
int max = newLog.Count;
if (currentLog.Count > newLog.Count)
{
max = currentLog.Count;
}
for (int i = 0; i < max; i++)
{
if (newLog[i] != currentLog[i])
{
return i;
}
}
return null;
}
}
}