adv3Lite library check for precondit hitting nil obj ref

There is a treadmill in the debriefing room. Player character is on the treadmill. Game player then examines a couple of things and then issues the command “Get on it”. Parser does its thing checking for validity, and…boom. Nil object reference…

The debugger pointer is aimed at line 810—step = step.stagingLocation;—in precondit.t.

            local step = stagingLoc;
            
            while(step != loc)
            {
                path = [step] + path;
                step = step.stagingLocation;
            }

I set a breakpoint just before the while loop and stepped through it, to see it correctly evaluating step, until step.stagingLocation finally returns nil, and then the code continues through the while loop one more time, thereby breaking when it tries once again to match step, by now nil, to a value…

Shouldn’t the while loop be defined like this…

while (step != nil && step != loc)

… to avoid the nil obj ref?

Jerry

Yes, that’s probably right. I’ll make the change in the library at any rate, since it’s obviously good to avoid nil-object-reference run-time errors. Thanks for pointing it out.