H-uru / Plasma

Cyan Worlds's Plasma game engine
http://h-uru.github.io/Plasma/
GNU General Public License v3.0
202 stars 80 forks source link

Restore vftable of `hsRefCount`. #1559

Closed Hoikas closed 5 months ago

Hoikas commented 5 months ago

This restores the vftable of hsRefCount to match its layout in TPotS and the original MOUL. Having these methods be virtual is extremely helpful in the case of ModDLLs that define external creatables. If you're making an external creatable, it's important that those creatables are allocated and deallocated by the ModDLL itself. If UnRef() is not virtual, then your external creatable may be deleted by the engine, which may not be built against the same C++ runtime library as the engine. If the two C++ runtime libraries are not ABI compatible, this can result in sinister crashes. This is most relevant for very, very old builds of the engine, such as TPotS (Visual C++ 6) where it would be nice to build a ModDLL with a newer compiler.

(Yes, this does mean that I have made a ModDLL with an external creatable. The pure virtual function call was very surprising.)