inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
4.14k stars 492 forks source link

nullref after reload -> save on "previousContentObject" #901

Open Alex-Sand-0 opened 6 months ago

Alex-Sand-0 commented 6 months ago

Hi, I encountered a nullref in ink on this line: (ink 1.1.1) https://github.com/inkle/ink/blob/master/ink-engine-runtime/CallStack.cs#L145

I was reloading a state after changing the ink scripts, and the previous "previousContentObject" was pointing to a stitch I had renamed. The weird thing is that I had no problems loading this state, but I got a crash when trying to save again, immediately after loading. (I do that as a kind of "automatic testing" of my game serialization). It looks like can avoid the crash just with adding a null check, like in the snippet below , my question is: how is this "previousContentObject" used ? Which problems should I expect from just ignoring this error?

                if (!previousPointer.isNull)
                {
                    var path = previousPointer.Resolve()?.path?.ToString();
                    if (path != null)
                    {
                        writer.WriteProperty("previousContentObject", path);
                    }
                    else
                    {
                        // Question:  should we expect further problems  ??
                    }
                }

Thanks for your help, and thanks for this great lib!!