OpenTrespasser / JurassicParkTrespasser

A git-based fork of the Jurassic Park: Trespasser source code.
98 stars 24 forks source link

CRefObj: reenable delete operator #50

Closed meekee7 closed 4 years ago

meekee7 commented 4 years ago

Trespasser has the smart pointer rptr which does reference counting and deletes the object if no references are left. The idea is comparable to std::shared_ptr from C++11. Objects for rptr need to be instances of the CRefObj interface, which stores the reference count. The delete operator for CRefObj has protected visibility so that they are only deleted when the reference count reaches zero.

Unfortunately we are drowning in compiler errors because of this. Sometimes CRefObj objects are used and deleted outside of an rptr. But most errors come from places where rptr objects are created from the rptr_new and rptr_cast macros.

Besides from a complete overhaul of the rptr mechanism, I can offer no better workaround than reenabling the delete operator for the public.