Skip to content

Commit

Permalink
Lua/Plugins: Add get/set_function_flags
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 10, 2024
1 parent 8ba59a0 commit 59e4738
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/uevr/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SOFTWARE.
#define UEVR_OUT

#define UEVR_PLUGIN_VERSION_MAJOR 2
#define UEVR_PLUGIN_VERSION_MINOR 31
#define UEVR_PLUGIN_VERSION_MINOR 32
#define UEVR_PLUGIN_VERSION_PATCH 0

#define UEVR_RENDERER_D3D11 0
Expand Down Expand Up @@ -325,6 +325,8 @@ typedef struct {
typedef struct {
void* (*get_native_function)(UEVR_UFunctionHandle function);
bool (*hook_ptr)(UEVR_UFunctionHandle function, UEVR_UFunction_NativePreFn pre_hook, UEVR_UFunction_NativePostFn post_hook);
unsigned int (*get_function_flags)(UEVR_UFunctionHandle function);
void (*set_function_flags)(UEVR_UFunctionHandle function, unsigned int flags);
} UEVR_UFunctionFunctions;

typedef struct {
Expand Down
10 changes: 10 additions & 0 deletions include/uevr/API.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,16 @@ class API {
return fn(to_handle());
}

uint32_t get_function_flags() const {
static const auto fn = initialize()->get_function_flags;
return fn(to_handle());
}

void set_function_flags(uint32_t flags) {
static const auto fn = initialize()->set_function_flags;
fn(to_handle(), flags);
}

using UEVR_UFunction_CPPPreNative = bool(*)(API::UFunction*, API::UObject*, void*, void*);
using UEVR_UFunction_CPPPostNative = void(*)(API::UFunction*, API::UObject*, void*, void*);

Expand Down
4 changes: 3 additions & 1 deletion lua-api/lib/src/ScriptContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,9 @@ int ScriptContext::setup_bindings() {
if (post != sol::nil) {
hook->post_hooks.push_back(post);
}
}
},
"get_function_flags", &uevr::API::UFunction::get_function_flags,
"set_function_flags", &uevr::API::UFunction::set_function_flags
);

m_lua.new_usertype<uevr::API::FField>("UEVR_FField",
Expand Down
8 changes: 7 additions & 1 deletion src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,13 @@ UEVR_UFunctionFunctions g_ufunction_functions {
},
.hook_ptr = [](UEVR_UFunctionHandle func, UEVR_UFunction_NativePreFn pre, UEVR_UFunction_NativePostFn post) -> bool {
return PluginLoader::get()->hook_ufunction_ptr(func, pre, post);
}
},
.get_function_flags = [](UEVR_UFunctionHandle func) -> uint32_t {
return UFUNCTION(func)->get_function_flags();
},
.set_function_flags = [](UEVR_UFunctionHandle func, uint32_t flags) {
UFUNCTION(func)->get_function_flags() = flags;
},
};

namespace uevr {
Expand Down

0 comments on commit 59e4738

Please sign in to comment.