diff --git a/BigBaseV2/src/hooking.cpp b/BigBaseV2/src/hooking.cpp index 982c27d9..26ab6172 100644 --- a/BigBaseV2/src/hooking.cpp +++ b/BigBaseV2/src/hooking.cpp @@ -118,12 +118,13 @@ namespace big bool hooks::run_script_threads(std::uint32_t ops_to_execute) { - TRY_CLAUSE + g_native_invoker.cache_handlers(); + + if (g_running) { - if (g_running) - g_script_mgr.tick(); - return g_hooking->m_run_script_threads_hook.get_original()(ops_to_execute); - } EXCEPT_CLAUSE - return false; + g_script_mgr.tick(); + } + + return g_hooking->m_run_script_threads_hook.get_original()(ops_to_execute); } } diff --git a/BigBaseV2/src/invoker.cpp b/BigBaseV2/src/invoker.cpp index 5f47b177..53159a9e 100644 --- a/BigBaseV2/src/invoker.cpp +++ b/BigBaseV2/src/invoker.cpp @@ -16,13 +16,17 @@ namespace big void native_invoker::cache_handlers() { + if (m_handlers_cached) + return; + for (const rage::scrNativeMapping& mapping : g_crossmap) { rage::scrNativeHandler handler = g_pointers->m_get_native_handler( g_pointers->m_native_registration_table, mapping.second); - m_handler_cache.emplace(mapping.first, handler); } + + m_handlers_cached = true; } void native_invoker::begin_call() diff --git a/BigBaseV2/src/invoker.hpp b/BigBaseV2/src/invoker.hpp index 2a43576e..ca9e3d97 100644 --- a/BigBaseV2/src/invoker.hpp +++ b/BigBaseV2/src/invoker.hpp @@ -38,6 +38,7 @@ namespace big private: native_call_context m_call_context; std::unordered_map m_handler_cache; + bool m_handlers_cached = false; }; inline native_invoker g_native_invoker; diff --git a/BigBaseV2/src/main.cpp b/BigBaseV2/src/main.cpp index 0349b35d..d691986a 100644 --- a/BigBaseV2/src/main.cpp +++ b/BigBaseV2/src/main.cpp @@ -87,7 +87,7 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) LOG(INFO) << "Registered service instances..."; g_script_mgr.add_script(std::make_unique