diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index 0bd0cfe1..c7ee155f 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -208,8 +208,11 @@ namespace ui_scripting lua["luiglobals"] = lua; utils::nt::library host{}; - load_scripts((game::get_appdata_path() / "data/ui_scripts/").string()); - load_scripts((host.get_folder() / "boiii/ui_scripts/").string()); + std::string folder = "ui_scripts/"; + if (game::is_server()) + folder = "lobby_scripts/"; + load_scripts((game::get_appdata_path() / "data" / folder).string()); + load_scripts((host.get_folder() / "boiii" / folder).string()); } void try_start() @@ -228,7 +231,7 @@ namespace ui_scripting { ui_cod_init_hook.invoke(frontend); - if (game::Com_IsRunningUILevel()) + if (!game::is_server() && game::Com_IsRunningUILevel()) { // Fetch the names of the local files so file overrides are already handled globals = {}; @@ -271,7 +274,7 @@ namespace ui_scripting return load_buffer(globals.raw_script_name, utils::io::read_file(globals.raw_script_name)); } - return utils::hook::invoke(0x141D3AFB0_g, state, compiler_options, reader, reader_data, debug_reader, + return utils::hook::invoke(game::select(0x141D3AFB0, 0x1403E4090), state, compiler_options, reader, reader_data, debug_reader, debug_reader_data, chunk_name); } @@ -375,18 +378,21 @@ namespace ui_scripting return closure; } - class component final : public client_component + class component final : public generic_component { public: void post_unpack() override { - utils::hook::call(0x141D4979A_g, hks_load_stub); + utils::hook::call(game::select(0x141D4979A, 0x1403F233A), hks_load_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_lobbyui_init_hook.create(0x141F2C620_g, ui_cod_lobbyui_init_stub); - ui_shutdown_hook.create(0x14270E9C0_g, ui_shutdown_stub); - lua_cod_getrawfile_hook.create(0x141F0F880_g, lua_cod_getrawfile_stub); + hks_package_require_hook.create(game::select(0x141D28EF0, 0x1403D7FC0), hks_package_require_stub); + ui_cod_init_hook.create(game::select(0x141F298B0, 0x1404A0A50), ui_cod_init_stub); + ui_cod_lobbyui_init_hook.create(game::select(0x141F2C620, 0x1404A1F50), ui_cod_lobbyui_init_stub); + ui_shutdown_hook.create(game::select(0x14270E9C0, 0x1404A1280), ui_shutdown_stub); + lua_cod_getrawfile_hook.create(game::select(0x141F0F880, 0x1404BCB70), lua_cod_getrawfile_stub); + + if (game::is_server()) + return; dvar_cg_enable_unsafe_lua_functions = game::Dvar_RegisterBool( game::Dvar_GenerateHash("cg_enable_unsafe_lua_functions"), "cg_enable_unsafe_lua_functions", false, diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index f491261a..34ad4b7e 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -165,21 +165,21 @@ namespace game namespace hks { - WEAK symbol lua_state {0x159C78D88}; - WEAK symbol hksi_lua_pushlstring{0x140A18430}; + WEAK symbol lua_state {0x159C78D88, 0x14858C408}; + WEAK symbol hksi_lua_pushlstring{0x140A18430, 0x1401DE6F0}; - WEAK symbol hks_obj_settable{0x141D4B660}; - WEAK symbol hks_obj_gettable{0x141D4ABF0}; - WEAK symbol vm_call_internal{0x141D71070}; - WEAK symbol Hashtable_Create{0x141D3B5F0}; - WEAK symbol cclosure_Create{0x141D3B7E0}; - WEAK symbol hksi_luaL_ref{0x141D4D1A0}; - WEAK symbol hksi_luaL_unref{0x141D4D320}; + WEAK symbol hks_obj_settable{0x141D4B660, 0x1403F41B0}; + WEAK symbol hks_obj_gettable{0x141D4ABF0, 0x1403F3750}; + WEAK symbol vm_call_internal{0x141D71070, 0x140418E40}; + WEAK symbol Hashtable_Create{0x141D3B5F0, 0x1403E46D0}; + WEAK symbol cclosure_Create{0x141D3B7E0, 0x1403E48C0}; + WEAK symbol hksi_luaL_ref{0x141D4D1A0, 0x1403F5CF0}; + WEAK symbol hksi_luaL_unref{0x141D4D320, 0x1403F5E70}; - WEAK symbol hksi_hksL_loadbuffer{0x141D4BD80}; - WEAK symbol hksi_lua_getinfo{0x141D4D960}; - WEAK symbol hksi_lua_getstack{0x141D4DC20}; - WEAK symbol hksi_luaL_error{0x141D4D050}; + WEAK symbol hksi_hksL_loadbuffer{0x141D4BD80, 0x1403F48D0}; + WEAK symbol hksi_lua_getinfo{0x141D4D960, 0x1403F64B0}; + WEAK symbol hksi_lua_getstack{0x141D4DC20, 0x1403F6770}; + WEAK symbol hksi_luaL_error{0x141D4D050, 0x1403F5BA0}; WEAK symbol s_compilerTypeName{0x140A18430}; } }