Skip to content

Commit

Permalink
SDK/Plugins: Add UObject::call_function
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Dec 24, 2023
1 parent 956fb49 commit 02bea8b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/uevr/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ typedef struct {
bool (*is_a)(UEVR_UObjectHandle object, UEVR_UClassHandle other);

void (*process_event)(UEVR_UObjectHandle object, UEVR_UFunctionHandle function, void* params);
void (*call_function)(UEVR_UObjectHandle object, const wchar_t* name, void* params);
} UEVR_UObjectFunctions;

typedef struct {
Expand Down
16 changes: 16 additions & 0 deletions shared/sdk/UObjectBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,20 @@ void UObjectBase::process_event(sdk::UFunction* func, void* params) {

vfunc(this, func, params);
}

void UObjectBase::call_function(const wchar_t* name, void* params) {
const auto klass = get_class();

if (klass == nullptr) {
return;
}

const auto func = klass->find_function(name);

if (func == nullptr) {
return;
}

process_event(func, params);
}
}
1 change: 1 addition & 0 deletions shared/sdk/UObjectBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class UObjectBase {
void update_offsets();
std::wstring get_full_name() const;
void process_event(UFunction* function, void* params);
void call_function(const wchar_t* name, void* params);

UClass* get_class() const {
return *(UClass**)((uintptr_t)this + s_class_private_offset);
Expand Down
4 changes: 4 additions & 0 deletions src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ UEVR_UObjectFunctions g_uobject_functions {
[](UEVR_UObjectHandle obj, UEVR_UFunctionHandle func, void* params) {
UOBJECT(obj)->process_event((sdk::UFunction*)func, params);
},
// call_function
[](UEVR_UObjectHandle obj, const wchar_t* name, void* params) {
UOBJECT(obj)->call_function(name, params);
},
};

UEVR_UObjectArrayFunctions g_uobject_array_functions {
Expand Down

0 comments on commit 02bea8b

Please sign in to comment.