Skip to content

Commit 716c1e4

Browse files
committed
fix(Lua): native UFunction lua hook ID mapping
1 parent 6e478cf commit 716c1e4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

UE4SS/src/Mod/LuaMod.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,13 +1789,17 @@ No overload found for function 'UnregisterHook'.
17891789
}
17901790

17911791
// Hooks on native UFunctions will have both of these IDs.
1792+
// pre_id and post_id are generic IDs returned to Lua, we need to map them to native IDs
17921793
auto native_hook_pre_id_it = LuaMod::m_generic_hook_id_to_native_hook_id.find(static_cast<int32_t>(pre_id));
17931794
auto native_hook_post_id_it = LuaMod::m_generic_hook_id_to_native_hook_id.find(static_cast<int32_t>(post_id));
17941795
if (native_hook_pre_id_it != LuaMod::m_generic_hook_id_to_native_hook_id.end() &&
17951796
native_hook_post_id_it != LuaMod::m_generic_hook_id_to_native_hook_id.end())
17961797
{
1798+
// Use the native IDs for comparison, not the generic IDs
1799+
auto native_pre_id = native_hook_pre_id_it->second;
1800+
auto native_post_id = native_hook_post_id_it->second;
17971801
const auto hook_data = std::ranges::find_if(g_hooked_script_function_data, [&](const std::unique_ptr<LuaUnrealScriptFunctionData>& elem) {
1798-
return elem->post_callback_id == post_id && elem->pre_callback_id == pre_id;
1802+
return elem->post_callback_id == native_post_id && elem->pre_callback_id == native_pre_id;
17991803
});
18001804
if (hook_data != g_hooked_script_function_data.end())
18011805
{

0 commit comments

Comments
 (0)