Changed UI Scripting init on frontend to different hook when everything is initialized

This commit is contained in:
Jari van der Kaap 2023-01-03 00:27:40 +01:00
parent 6ac79fa98b
commit 43364491ab
2 changed files with 15 additions and 3 deletions

View File

@ -18,6 +18,7 @@ namespace ui_scripting
std::unordered_map<game::hks::cclosure*, std::function<arguments(const function_arguments& args)>> converted_functions; std::unordered_map<game::hks::cclosure*, std::function<arguments(const function_arguments& args)>> converted_functions;
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_shutdown_hook; utils::hook::detour ui_shutdown_hook;
utils::hook::detour hks_package_require_hook; utils::hook::detour hks_package_require_hook;
utils::hook::detour lua_cod_getrawfile_hook; utils::hook::detour lua_cod_getrawfile_hook;
@ -216,9 +217,18 @@ namespace ui_scripting
} }
} }
void ui_cod_init_stub(void* a1, void* a2) void ui_cod_init_stub(bool frontend)
{ {
ui_cod_init_hook.invoke(a1, a2); ui_cod_init_hook.invoke(frontend);
if (game::Com_IsRunningUILevel())
return;
const auto _0 = utils::finally(&try_start);
}
void ui_cod_lobbyui_init_stub()
{
ui_cod_lobbyui_init_hook.invoke();
const auto _0 = utils::finally(&try_start); const auto _0 = utils::finally(&try_start);
} }
@ -361,6 +371,7 @@ namespace ui_scripting
hks_package_require_hook.create(0x141D28EF0_g, hks_package_require_stub); hks_package_require_hook.create(0x141D28EF0_g, hks_package_require_stub);
ui_cod_init_hook.create(0x141F298B0_g, ui_cod_init_stub); ui_cod_init_hook.create(0x141F298B0_g, ui_cod_init_stub);
ui_cod_lobbyui_init_hook.create(0x141F2C620_g, ui_cod_lobbyui_init_stub);
ui_shutdown_hook.create(0x14270E9C0_g, ui_shutdown_stub); ui_shutdown_hook.create(0x14270E9C0_g, ui_shutdown_stub);
lua_cod_getrawfile_hook.create(0x141F0F880_g, lua_cod_getrawfile_stub); lua_cod_getrawfile_hook.create(0x141F0F880_g, lua_cod_getrawfile_stub);

View File

@ -21,6 +21,7 @@ namespace game
WEAK symbol<void(int channel, unsigned int label, const char* fmt, ...)> Com_Printf{0x1421499C0, 0x140505630}; WEAK symbol<void(int channel, unsigned int label, const char* fmt, ...)> Com_Printf{0x1421499C0, 0x140505630};
WEAK symbol<void(const char* file, int line, int code, const char* fmt, ...)> Com_Error_{0x1420F8BD0}; WEAK symbol<void(const char* file, int line, int code, const char* fmt, ...)> Com_Error_{0x1420F8BD0};
WEAK symbol<bool(eModes mode)> Com_SessionMode_IsMode{0x1420F7DD0}; WEAK symbol<bool(eModes mode)> Com_SessionMode_IsMode{0x1420F7DD0};
WEAK symbol<bool()> Com_IsRunningUILevel{0x142148DB0};
WEAK symbol<void(uint32_t localClientNum, eModes fromMode, eModes toMode, uint32_t flags)> Com_SwitchMode{ WEAK symbol<void(uint32_t localClientNum, eModes fromMode, eModes toMode, uint32_t flags)> Com_SwitchMode{
0x14214AF30 0x14214AF30
}; };