A ts.obj reference directly stores a SimObject * pointer. This means extremely fast property access and method calls, but also means that it could suddenly be pointing at the void if the object is deleted. There is currently no way to detect this, which makes it even more of a problem; it'll likely just crash the game if you try to use it.
Some possible solutions:
Make every ts.obj store the object ID it refers to in addition to the pointer. Provide a obj.exists field which uses Sim::findObject with the ID to make sure it still exists. This would still let you crash the game by using an invalid object but at least would let you see if it is invalid first.
Store object IDs instead of SimObject * pointers and look them up with Sim::findObject every time they're used. This would be too slow.
A
ts.obj
reference directly stores aSimObject *
pointer. This means extremely fast property access and method calls, but also means that it could suddenly be pointing at the void if the object is deleted. There is currently no way to detect this, which makes it even more of a problem; it'll likely just crash the game if you try to use it.Some possible solutions:
ts.obj
store the object ID it refers to in addition to the pointer. Provide aobj.exists
field which usesSim::findObject
with the ID to make sure it still exists. This would still let you crash the game by using an invalid object but at least would let you see if it is invalid first.SimObject *
pointers and look them up withSim::findObject
every time they're used. This would be too slow.