TF2-DMB / CBaseNPC

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

Fix crash with IsHindrance + CallBaseFunction, reformat includes #36

Closed KitRifty closed 1 year ago

KitRifty commented 1 year ago

Changes:

This special value is passed by PathFollower to quickly determine if it should do additional yet more expensive checks for any entities that may impede path progress. If this special value is passed in, the query callback assumed it was a valid pointer and tries to convert it via EntityToBCompatRef, resulting in a crash. Now if this special value is passed in, an entity index of -1 is instead directly passed into the callback instead.

The CallBaseFunction method was failing to take into account that when variable arguments are used, any cell parameter within the varargs are passed by-ref, not by value. The native now correctly resolves these references. To guard against further crashes and potentially other undefined behavior, errors will now be thrown if incorrect number of parameters are passed in. Checks for invalid entity index/references were added for IsEntityTraversable and ShouldCollideWith since valid entities are required for those functions.

This was mostly done to fix the VSCode SourcePawn extension not parsing over the include files. Auto-completion + snippets now work correctly. Also, formatting them this way brings them closer to how SM formats their include files.