Merge pull request #459 from JariKCoding/main

feat #367: added Engine.IsBoiii to lua state
This commit is contained in:
Maurice Heumann 2023-04-07 21:24:02 +02:00 committed by GitHub
commit c5da3c1587

View File

@ -20,6 +20,7 @@ namespace ui_scripting
std::unordered_map<game::hks::cclosure*, std::function<arguments(const function_arguments& args)>> std::unordered_map<game::hks::cclosure*, std::function<arguments(const function_arguments& args)>>
converted_functions; converted_functions;
utils::hook::detour ui_init_hook;
utils::hook::detour ui_cod_init_hook; utils::hook::detour ui_cod_init_hook;
utils::hook::detour ui_cod_lobbyui_init_hook; utils::hook::detour ui_cod_lobbyui_init_hook;
utils::hook::detour cl_first_snapshot_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; state->m_global->m_bytecodeSharingMode = game::hks::HKS_BYTECODE_SHARING_SECURE;
} }
void start() void setup_lua_globals()
{ {
globals = {}; globals = {};
@ -204,6 +205,12 @@ namespace ui_scripting
lua["print"] = function(reinterpret_cast<game::hks::lua_function>(0x141D30290_g)); // hks::base_print lua["print"] = function(reinterpret_cast<game::hks::lua_function>(0x141D30290_g)); // hks::base_print
lua["table"]["unpack"] = lua["unpack"]; lua["table"]["unpack"] = lua["unpack"];
lua["luiglobals"] = lua; lua["luiglobals"] = lua;
lua["Engine"]["IsBOIII"] = true;
}
void start()
{
setup_lua_globals();
const utils::nt::library host{}; const utils::nt::library host{};
const auto folder = game::is_server() ? "lobby_scripts/" : "ui_scripts/"; 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; bool doneFirstSnapshot = false;
void ui_cod_init_stub(const bool frontend) void ui_cod_init_stub(const bool frontend)
@ -467,6 +481,7 @@ namespace ui_scripting
return; return;
} }
ui_init_hook.create(0x142704FF0_g, ui_init_stub);
cl_first_snapshot_hook.create(0x141320E60_g, cl_first_snapshot_stub); cl_first_snapshot_hook.create(0x141320E60_g, cl_first_snapshot_stub);
scheduler::once([]() scheduler::once([]()