Skip to content

Commit

Permalink
Patcher: fix: broken go to labels in script engine
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Oct 22, 2024
1 parent 1e5da54 commit 132e21e
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions Patcher/AutoPatcher/ScriptEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1487,13 +1487,16 @@ private static void IfFoundGo(string Label)

if (FindSuccess)
{
FunctionDescriptor FoundLabel = Labels.Find(l => string.Equals(l.Name, Label, StringComparison.CurrentCultureIgnoreCase));
if (FoundLabel == null)
throw new ScriptExecutionException("Label not found: " + Label);

WriteLog("Condition was found, jumping to label: " + Label);
WriteLog("New virtual address: 0x" + FoundLabel.VirtualAddress.ToString("X8"));
CurrentVirtualAddressTarget = FoundLabel.VirtualAddress;
CodeLine NewLine = ScriptCode.Find(l => string.Equals(l.Label, Label, StringComparison.CurrentCultureIgnoreCase));
if (NewLine == null)
{
throw new ScriptExecutionException("Label " + Label + " not found");
}
else
{
Pointer = ScriptCode.IndexOf(NewLine);
WriteLog("Go to label: " + Label);
}
}
}

Expand All @@ -1504,13 +1507,16 @@ private static void IfNotFoundGo(string Label)

if (!FindSuccess)
{
FunctionDescriptor FoundLabel = Labels.Find(l => string.Equals(l.Name, Label, StringComparison.CurrentCultureIgnoreCase));
if (FoundLabel == null)
throw new ScriptExecutionException("Label not found: " + Label);

WriteLog("Condition was not found, jumping to label: " + Label);
WriteLog("New virtual address: 0x" + FoundLabel.VirtualAddress.ToString("X8"));
CurrentVirtualAddressTarget = FoundLabel.VirtualAddress;
CodeLine NewLine = ScriptCode.Find(l => string.Equals(l.Label, Label, StringComparison.CurrentCultureIgnoreCase));
if (NewLine == null)
{
throw new ScriptExecutionException("Label " + Label + " not found");
}
else
{
Pointer = ScriptCode.IndexOf(NewLine);
WriteLog("Go to label: " + Label);
}
}
}

Expand Down

0 comments on commit 132e21e

Please sign in to comment.