Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core hooks #241

Merged
merged 8 commits into from Mar 8, 2018
Merged

Core hooks #241

merged 8 commits into from Mar 8, 2018

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.

@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.

None yet

2 participants