Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
NWScript object management #341
This PR makes NWScript variables store object ids, not object pointers. It introduces two new classes: ObjectReference, which holds the object id, and ObjectManager, which acts as the global registry for objects. This PR also implements destroyObject function in KotOR.
There's still use-after-free crashes here: https://gist.github.com/DrMcCoy/0fd8777a1a179bd921de3192895f24d0
The reason seems to be that the _owner and _triggerer member variables in NCSFile are still plain pointers. When assigning those to stack variables, the ObjectReference tries to get their ID, crashing.
Sorry, got another use-after-free here: https://gist.github.com/DrMcCoy/549d6f2ed5ea7532539ee148a02f75a7
The issue here is that Module::_delayedActions contains raw Object pointers (ActionQueue, which is a std::multiset, struct Action members owner and triggerer)