Added luiReload command

This commit is contained in:
Jari van der Kaap 2023-02-12 19:32:33 +01:00
parent a045200523
commit da43fb33ee
2 changed files with 38 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#include "game/ui_scripting/execution.hpp" #include "game/ui_scripting/execution.hpp"
#include "command.hpp"
#include "ui_scripting.hpp" #include "ui_scripting.hpp"
#include "scheduler.hpp" #include "scheduler.hpp"
@ -393,12 +394,36 @@ namespace ui_scripting
game::Dvar_SetFromStringByName("ui_error_report_delay", "0", true); game::Dvar_SetFromStringByName("ui_error_report_delay", "0", true);
}, scheduler::pipeline::renderer); }, scheduler::pipeline::renderer);
command::add("luiReload", [](auto& params)
{
auto frontend = game::Com_IsRunningUILevel();
if (frontend)
{
converted_functions.clear();
globals.loaded_scripts.clear();
globals.local_scripts.clear();
game::UI_CoD_Shutdown();
game::UI_CoD_Init(true);
// Com_LoadFrontEnd stripped
game::Lua_CoD_LoadLuaFile(*game::hks::lua_state, "ui_mp.T6.main");
game::UI_AddMenu(game::UI_CoD_GetRootNameForController(0), "main", -1, *game::hks::lua_state);
game::UI_CoD_LobbyUI_Init();
}
else
{
// TODO: Find a way to do a full shutdown & restart like in frontend, that opens up the loading screen that can't be easily closed
game::CG_LUIHUDRestart(0);
}
});
scheduler::once([]() { scheduler::once([]() {
printf("dvar_cg_enable_unsafe_lua_functions scheduler %s", game::Dvar_DisplayableValue(dvar_cg_enable_unsafe_lua_functions));
if (!dvar_cg_enable_unsafe_lua_functions->current.enabled) if (!dvar_cg_enable_unsafe_lua_functions->current.enabled)
{ {
printf("dvar_cg_enable_unsafe_lua_functions add jumps");
// Do not allow the HKS vm to open LUA's libraries // Do not allow the HKS vm to open LUA's libraries
// Disable unsafe functions // Disable unsafe functions
utils::hook::jump(0x141D34190_g, luaopen_stub); // debug utils::hook::jump(0x141D34190_g, luaopen_stub); // debug

View File

@ -92,6 +92,16 @@ namespace game
WEAK symbol<char> s_dvarPool{ 0x157AC8220 }; WEAK symbol<char> s_dvarPool{ 0x157AC8220 };
WEAK symbol<int> g_dvarCount{ 0x157AC81CC }; WEAK symbol<int> g_dvarCount{ 0x157AC81CC };
// UI
WEAK symbol<void(bool frontend)> UI_CoD_Init{ 0x141F298B0, 0x0 };
WEAK symbol<void()> UI_CoD_LobbyUI_Init{ 0x141F2C620, 0x0 };
WEAK symbol<void()> UI_CoD_Shutdown{ 0x141F336B0, 0x0 };
WEAK symbol<void(const char*, const char*, int, game::hks::lua_State*)> UI_AddMenu{ 0x1427024B0, 0x0 };
WEAK symbol<const char* (int)> UI_CoD_GetRootNameForController{ 0x141F291E0, 0x0 };
WEAK symbol<void(game::hks::lua_State*, const char*)> Lua_CoD_LoadLuaFile{ 0x141F122C0, 0x0 };
WEAK symbol<void(int localClientNum)> CG_LUIHUDRestart{ 0x140F7E970 };
WEAK symbol<void(int localClientNum)> CL_CheckKeepDrawingConnectScreen{ 0x1413CCAE0 };
// Scr // Scr
WEAK symbol<void(scriptInstance_t inst, int value)> Scr_AddInt{0x0, 0x14016F160}; WEAK symbol<void(scriptInstance_t inst, int value)> Scr_AddInt{0x0, 0x14016F160};
WEAK symbol<void(scriptInstance_t inst, const char* value)> Scr_AddString{0x0, 0x14016F320}; WEAK symbol<void(scriptInstance_t inst, const char* value)> Scr_AddString{0x0, 0x14016F320};