allow scripts to see scripts before they start

This commit is contained in:
haven1433 2023-10-01 12:50:07 -05:00
parent c12d15bb04
commit 53b4ed35e0
2 changed files with 11 additions and 1 deletions

View File

@ -879,7 +879,7 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
// (1) the run has no name
// (2) the run has only one source (the script)
if (run is NoInfoRun || run.PointerSources == null) return -1;
if (run is IScriptStartRun) return -1; // this script has a length, but don't track it (prevent recursion loop)
if (run is IScriptStartRun) return 1; // this script has a length, but don't calculate it (prevent recursion loop)
if (run.PointerSources.Count == 1 && string.IsNullOrEmpty(model.GetAnchorFromAddress(-1, destination))) {
return run.Length;
}

View File

@ -873,5 +873,15 @@ label2:;goto <000050>;end";
Assert.Equal(8, run.Start);
Assert.IsType<PointerRun>(run);
}
[Fact]
public void ScriptGotoBeforeScriptStarts_Reload_IncludesSubScript() {
EventScript = "end";
ViewPort.Goto.Execute(0x10);
EventScript = "if.yes.goto <section1>;end;section1:;if.yes.goto <000000>;end";
Assert.Equal(2, Tool.Contents.Count);
}
}
}