From b2214c40e2ee15bb87f5b6d19489d67c926c59e0 Mon Sep 17 00:00:00 2001 From: Jari van der Kaap Date: Fri, 7 Apr 2023 18:30:04 +0200 Subject: [PATCH] feat #367: added Engine.IsBoiii to lua state --- src/client/component/ui_scripting.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index a414c427..51dc4eaa 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -20,6 +20,7 @@ namespace ui_scripting std::unordered_map> converted_functions; + utils::hook::detour ui_init_hook; utils::hook::detour ui_cod_init_hook; utils::hook::detour ui_cod_lobbyui_init_hook; utils::hook::detour cl_first_snapshot_hook; @@ -192,7 +193,7 @@ namespace ui_scripting state->m_global->m_bytecodeSharingMode = game::hks::HKS_BYTECODE_SHARING_SECURE; } - void start() + void setup_lua_globals() { globals = {}; @@ -204,6 +205,12 @@ namespace ui_scripting lua["print"] = function(reinterpret_cast(0x141D30290_g)); // hks::base_print lua["table"]["unpack"] = lua["unpack"]; lua["luiglobals"] = lua; + lua["Engine"]["IsBOIII"] = true; + } + + void start() + { + setup_lua_globals(); const utils::nt::library host{}; const auto folder = game::is_server() ? "lobby_scripts/" : "ui_scripts/"; @@ -223,6 +230,13 @@ namespace ui_scripting } } + void ui_init_stub(void* allocFunction, void* outOfMemoryFunction) + { + ui_init_hook.invoke(allocFunction, outOfMemoryFunction); + + setup_lua_globals(); + } + bool doneFirstSnapshot = false; void ui_cod_init_stub(const bool frontend) @@ -467,6 +481,7 @@ namespace ui_scripting return; } + ui_init_hook.create(0x142704FF0_g, ui_init_stub); cl_first_snapshot_hook.create(0x141320E60_g, cl_first_snapshot_stub); scheduler::once([]()