Skip to content

Commit

Permalink
Fix a few more breakpoint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Mar 1, 2024
1 parent 8356575 commit bd9c69f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
12 changes: 7 additions & 5 deletions Source/TAS/Input/InputController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class InputController
public FastForward? CurrentFastForward => FastForwards.FirstOrDefault(pair => pair.Key > CurrentFrameInTas).Value ??
FastForwards.LastOrDefault().Value;

public bool Break => CurrentFastForward?.Frame == CurrentFrameInTas;

public bool ShouldFastForward => CurrentFastForward is { } forward && forward.Frame > CurrentFrameInTas;

public bool CanPlayback => CurrentFrameInTas < Inputs.Count;
Expand Down Expand Up @@ -180,10 +182,6 @@ public void ReadLines(IEnumerable<string> lines, string filePath, int startLine,
// TODO: Is the goto here required?
string lineText = readLine.Trim();

// Empty / Comment
if (lineText.IsNullOrWhiteSpace() || lineText.StartsWith('#') || blockCommentMode)
goto NextLine;

// Block comments
if (lineText.StartsWith("/*"))
{
Expand All @@ -196,6 +194,10 @@ public void ReadLines(IEnumerable<string> lines, string filePath, int startLine,
goto NextLine;
}

// Empty / Comment
if (lineText.IsNullOrWhiteSpace() || lineText.StartsWith('#') || blockCommentMode)
goto NextLine;

if (Command.TryParse(this, filePath, subLine, lineText, initializationFrameCount, studioLine, out var _))
{
goto NextLine;
Expand Down Expand Up @@ -266,7 +268,7 @@ public void Clear() {
// savestateChecksum = string.Empty;
Inputs.Clear();
Commands.Clear();
// FastForwards.Clear();
FastForwards.Clear();
// FastForwardComments.Clear();
// Comments.Clear();
usedFiles.Clear();
Expand Down
11 changes: 9 additions & 2 deletions Source/TAS/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public static void EnableRun()
{
Log.Info($"Starting TAS: {InputController.TasFilePath}");

CurrState = State.Running;
NextState = State.Running;
CurrState = NextState = State.Running;
AttributeUtils.Invoke<EnableRunAttribute>();
Controller.Stop();
Controller.Clear();
Expand Down Expand Up @@ -79,6 +78,13 @@ public static void Update()
{
Controller.AdvanceFrame(out bool canPlayback);

// Stop TAS if breakpoint is not placed at the end
if (Controller.Break && Controller.CanPlayback) {
// Controller.NextCommentFastForward = null;
NextState = State.Paused;
return;
}

if (!canPlayback)
{
DisableRun();
Expand Down Expand Up @@ -121,6 +127,7 @@ public static void AbortTas(string message)
public static bool IsLoading()
{
return !(Game.Instance.transitionStep == Game.TransitionStep.FadeIn ||
Game.Instance.transitionStep == Game.TransitionStep.Perform ||
Game.Instance.transitionStep == Game.TransitionStep.None);
}

Expand Down
15 changes: 5 additions & 10 deletions Source/TAS/TASMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ private static void On_App_Tick_Update(orig_App_Tick_Update orig, TimeSpan delta
// Don't do anything if TAS isn't running
if (!Manager.Running)
{
TASMod.Update();
orig(delta);
Update();
return;
}

Expand Down Expand Up @@ -155,16 +155,11 @@ private static void On_App_Tick_Update(orig_App_Tick_Update orig, TimeSpan delta
orig(delta);
}

if (Manager.Running && Manager.Controller.ShouldFastForward)
// Fast forward to breakpoint
while (Manager.Running && Manager.Controller.ShouldFastForward)
{
// Fast forward to breakpoint
while (Manager.Running && Manager.Controller.ShouldFastForward)
{
TASMod.Update();
orig(delta);
}
// And pause after that
Manager.NextState = Manager.State.Paused;
TASMod.Update();
orig(delta);
}
}

Expand Down

0 comments on commit bd9c69f

Please sign in to comment.