TF2-DMB / CBaseNPC

Provides a friendly interface for plugins to use in order to create custom NPCs on the game Team Fortress 2
37 stars 6 forks source link

Change custom entity datamap cleanup to entity destructor #3

Closed KitRifty closed 3 years ago

KitRifty commented 3 years ago

Currently, attempting to access a user-defined property in a custom entity in OnEntityDestroyed() or a NextBotAction's OnEnd() callback during destruction will result in an error due to the GetDataDescMap hook removed prior to those calls. This fix delays the cleanup to a post-hook, allowing plugins to access the datamap during destruction.

KitRifty commented 3 years ago

Currently moving the fix instead to the entity's destructor. However, would still like to have CBaseNPCIntention's behavior destroyed in UpdateOnRemove() since it's still safe to access the entity and call virtual functions, needed for good cleanup code.

KitRifty commented 3 years ago

Additionally this also fixes cases where trying to access Handles during OnEnd or OnRemove would result in an invalid handle error, especially during a map change, plugin reload, or server shutdown.