Today we pass naked CSpaceObject pointers around in TLisp. This has various downsides, including vulnerability to crashes. A better solution is to create a new class that wraps the CSpaceObject pointer and use that inside TLisp.

giantcabbage 12 Aug 2025:

I made an attempt at this last year (unfortunately lost the work after a git stash mistake)... but I did try including both the pointer and ObjID in the wrapper meaning the TLisp object remained valid across system transitions.

  • We mark all the pointers as invalid on changing system
  • On next access we can attempt an obj ID lookup with appropriate result while out of system.

I didn’t get around to save/restoring, as we keep the ObjID in the wrapper we should be able to store the wrapper object in the save file. Then we should be able to simplify all the ObjID / GetObjByID / ObjRef stuff.

We can also create a generic pointer wrapper for gPlayer gScreen etc.

  • Could add subclasses for player / screen, or just record a data type to allow basic type checking (and prevent someone passing gPlayer to a screen function etc)
wolfy 12 Aug 2025:

We also did something like this, but with less protections as that wasnt the priority at the time, in the original 64bit port.
One thing we will want to keep in mind is that pointer/reference type should be easily updated to size_t instead of int, so switching to the 64bit version wont cause things to explode.