Skip to content

Conversation

@Ayuto
Copy link
Member

@Ayuto Ayuto commented Mar 6, 2018

This PR allows us to easily create entity hooks in C++. This can be done to speed up certain hooks.

Right now, only the PlayerRunCommand hook has been ported.

@Ayuto Ayuto requested review from jordanbriere and satoon101 March 6, 2018 19:41
@jordanbriere
Copy link
Contributor

Nice! Optimizations are always welcome. After hovering the changes, I got few points:

  • Any reason why ISimpleEntityHook accepts a pre and a post parameters over a single one accepting a HookType_t? Unless I missed something obvious, I don't think registering both for the same listener will ever be needed.

  • Since the goal of your implementation is to optimize, this could directly read m_nButtons instead of Player.buttons (which would save quite a bit of looping behind the scene).

  • Forgot a not into sp_hooks.cpp line 105.

  • Into ISimpleEntityHook::Initialize, true is returned instead of false into the catch block line 93.

- Improved retrieval of m_nButtons.
- Updated log messages.
- Return "true" if hooking the function failed.
@Ayuto
Copy link
Member Author

Ayuto commented Mar 7, 2018

Thanks for the feedback!

I don't think registering both for the same listener will ever be needed.

That was exactly the reason why I added this. But you are right: HookType_t makes more sense.

Into ISimpleEntityHook::Initialize, true is returned instead of false into the catch block line 93

This wasn't done by mistaken. If that part failed, it will probably also fail for all future entities as well. And we don't want it to fail over and over again.

@Ayuto Ayuto merged commit 05aa830 into master Mar 8, 2018
@Ayuto Ayuto deleted the core_hooks branch March 8, 2018 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants