From 34bd80e30be1cf74703f7b0dcd81b8fb56206b8f Mon Sep 17 00:00:00 2001 From: maybegreat48 Date: Fri, 4 Oct 2024 19:46:09 -0400 Subject: [PATCH] support debug scripts --- GTA V Script Decompiler/Function.cs | 2 +- GTA V Script Decompiler/ScriptFile.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/GTA V Script Decompiler/Function.cs b/GTA V Script Decompiler/Function.cs index 660a17f..748ec55 100644 --- a/GTA V Script Decompiler/Function.cs +++ b/GTA V Script Decompiler/Function.cs @@ -522,7 +522,7 @@ private void HandleSwitch(Ast.StatementTree.Tree tree) /// public void BuildInstructions() { - Offset = CodeBlock[4]; + Offset = 0; Instructions = new List(); InstructionMap = new Dictionary(); int curoff; diff --git a/GTA V Script Decompiler/ScriptFile.cs b/GTA V Script Decompiler/ScriptFile.cs index 749dd6c..e0c78d5 100644 --- a/GTA V Script Decompiler/ScriptFile.cs +++ b/GTA V Script Decompiler/ScriptFile.cs @@ -169,9 +169,14 @@ private void AddFunction(int start1, int start2) { for (var i = 0; i < namelen; i++) { - name += (char)CodeTable[start1 + 5 + i]; + var chr = (char)CodeTable[start1 + 5 + i]; + if (chr != '\0') + name += chr; } + if (name.StartsWith("__", StringComparison.Ordinal)) + name = name.TrimStart('_'); + foreach (var fun in Functions) if (fun.Name == name) name += "_0";