Skip to content

Add ability to install single (pre or post) callback using UObjectGlobals::RegisterHook (C++) #1310

Description

@PowerGamer1

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions