Open Archie-osu opened 3 years ago
Can you provide a stack trace? I believe this is intended behavior as there’s no real way to write a null object.
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=UndertaleModLib
StackTrace:
at UndertaleModLib.UndertaleWriter.WriteUndertaleObject[T](T obj) in C:\Users\Archie\Documents\GitHub\UndertaleModTool\UndertaleModLib\UndertaleIO.cs:line 491
UndertaleModLib.dll!UndertaleModLib.UndertaleWriter.WriteUndertaleObject<UndertaleModLib.Models.UndertaleInstruction.Reference<UndertaleModLib.Models.UndertaleFunction>>(UndertaleModLib.Models.UndertaleInstruction.Reference<UndertaleModLib.Models.UndertaleFunction> obj = null) | UndertaleIO.cs Line 491
UndertaleModLib.dll!UndertaleModLib.Models.UndertaleInstruction.Serialize(UndertaleModLib.UndertaleWriter writer = {UndertaleModLib.UndertaleWriter}) | UndertaleCode.cs Line 498
UndertaleModTool.dll!UndertaleModTool.MainWindow.CreateGMLBytecode(string sCode = "room_goto(20)", bool UseAUMI = true) | ScriptingFunctions.cs Line 78
UndertaleModTool.dll!UndertaleModTool.MainWindow.RunScriptNow(string path = "C:\\Users\\Archie\\Desktop\\gmlexec.csx") | MainWindow.xaml.cs Line 1074
Are there line numbers?
Updated with line numbers.
Looking at the relevant code, it seems that Function
is null. Did you forget to set it perhaps?
https://github.com/krzys-h/UndertaleModTool/blob/master/UndertaleModLib/Models/UndertaleCode.cs#L498
I am looping over CompileContext.ResultAssembly after compiling GML. For each entry in that list, I call entry.Serialize - the same instructions and code are valid in non-YYC environments.
Crashes on the newest build of the "master" branch. The game is empty, made with GMS 2.3 + YYC.
The actual exception occurs in WriteUndertaleObject, where the code checks for the type, not expecting that obj might be null.
Screenshot: https://imgur.com/a/rfYD1l9