01-26-2015, 03:22 AM
Hello, welcome to the forum.
(I have moved your thread to the Lua discussion subforum, I think this is a better place for it.)
This does make sense for player-based and entity-based hooks, true. It doesn't make much sense for the other hooks.
A slight problem with your approach would be threading - if you removed a hook but it was already trying to execute in a different server thread, the removal code would need to take this into account.
It hasn't been implemented mostly because no-one requested it yet and we have other things to do, usually more important than improving existing API.
I personally think that the performance impact of this hooks being global is negligible, the C++-to-Lua transition is quite fast, so calling it even a few hundred times for a large server shouldn't be that much of a problem. We've had some tests done where the C++ code would call into Lua several hundred thousand times per second and yet it wasn't using the full CPU.
(I have moved your thread to the Lua discussion subforum, I think this is a better place for it.)
This does make sense for player-based and entity-based hooks, true. It doesn't make much sense for the other hooks.
A slight problem with your approach would be threading - if you removed a hook but it was already trying to execute in a different server thread, the removal code would need to take this into account.
It hasn't been implemented mostly because no-one requested it yet and we have other things to do, usually more important than improving existing API.
I personally think that the performance impact of this hooks being global is negligible, the C++-to-Lua transition is quite fast, so calling it even a few hundred times for a large server shouldn't be that much of a problem. We've had some tests done where the C++ code would call into Lua several hundred thousand times per second and yet it wasn't using the full CPU.