Is your feature request related to a problem? Please describe.
Currently UObjectGlobals::RegisterHook only supports installing both pre and post callbacks simultaneously.
For callbacks installed through Function->RegisterPreHook / Function->RegisterPostHook this can be worked around by directly calling those functions. But for other type of callbacks (ProcessLocalScriptFunctionInternal related) there is no simple alternative for UObjectGlobals::RegisterHook other than practically full reimplementation of it.
For functions called very often installing both pre/post callbacks at the same time (when actually only one callback is required) is bad performance wise.
Describe the solution you'd like
Let UObjectGlobals::RegisterHook treat nullptr passed as PreCallback or PostCallback properly - i.e. do not try to register nullptr callbacks (which will result with an error at runtime logged in console when calling callbacks) at all.
Additional context
I must note that UE4SS users already expect UObjectGlobals::RegisterHook to treat nullptr that way and call it with nullptr arguments all the time.
Also, even LUA can install a single callback in its RegisterHook equivalent but C++ cannot - that's just shameful.
Is your feature request related to a problem? Please describe.
Currently
UObjectGlobals::RegisterHookonly supports installing both pre and post callbacks simultaneously.For callbacks installed through
Function->RegisterPreHook/Function->RegisterPostHookthis can be worked around by directly calling those functions. But for other type of callbacks (ProcessLocalScriptFunctionInternal related) there is no simple alternative forUObjectGlobals::RegisterHookother than practically full reimplementation of it.For functions called very often installing both pre/post callbacks at the same time (when actually only one callback is required) is bad performance wise.
Describe the solution you'd like
Let
UObjectGlobals::RegisterHooktreat nullptr passed asPreCallbackorPostCallbackproperly - i.e. do not try to register nullptr callbacks (which will result with an error at runtime logged in console when calling callbacks) at all.Additional context
I must note that UE4SS users already expect
UObjectGlobals::RegisterHookto treat nullptr that way and call it with nullptr arguments all the time.Also, even LUA can install a single callback in its
RegisterHookequivalent but C++ cannot - that's just shameful.