Spellcaster Studios

Make it happen…

The endless reference bug…

Today I worked a bit more on the last area of the game…

screen231

Deliberately blurry so I don’t spoil anything…

Anyway, because of the transition and the fight going on in the previous area, I found a silly bug, which is quite recurrent in all systems I built: references.

Basically, the Lua threads that are running to animate stuff aren’t bound to the area, which means that if we transition an area and the thread deletes an object (for example), it will delete either an un-existent object (not that serious, but sloppy), or an object in the new scene with the same name (which is a no-no).

So, I had to code in a “bind to area” feature for cutscenes, etc, which means the threads will stop running if the are they’re bound to is destroyed. It’s implemented a bit sloppily, but it should be enough for this game, which has quite simple dependencies.

This is something I run quite often… Languages like Java sidestep this issue by keeping reference counting and garbage collection, but that’s inefficient and you’re really just shifting the object management to an entity that knows nothing about the way you actually want to manage the entities…

Spellbook (my main engine) uses a combination of reference counting and explicit deletes, but the reference counting is more used for debugging purposes than anything else: basically, if you try to delete something that’s still in use in some other part of the system, you’ll get notified. If you exit the application (or if you call explicit calls to check it), and there’s still caught references, the system will warn you as well… These two small debug hooks are mostly enough to keep the system well behaved, and if they’re not enough, I can always finish a tool I was building some time ago that will dump to a socket when an object was created/deleted/referenced, etc, so I can put that into a tool that will show me the info and enable me to keep track of the entities…

Now listening to “Kiske-Sommerville” by “Michael Kiske & Amanda Sommerville”

Comment