diff --git a/src/client/component/discord.cpp b/src/client/component/discord.cpp index 97c3a027..a567fa92 100644 --- a/src/client/component/discord.cpp +++ b/src/client/component/discord.cpp @@ -10,7 +10,6 @@ #include "materials.hpp" #include "discord.hpp" -#include "ui_scripting.hpp" #include "game/ui_scripting/execution.hpp" #include @@ -187,13 +186,13 @@ namespace discord handlers.ready = ready; handlers.errored = errored; handlers.disconnected = errored; - handlers.joinGame = nullptr; //join_game + handlers.joinGame = nullptr; handlers.spectateGame = nullptr; - handlers.joinRequest = nullptr; //join_request + handlers.joinRequest = nullptr; Discord_Initialize("947125042930667530", &handlers, 1, nullptr); - //scheduler::once(download_default_avatar, scheduler::pipeline::async); + scheduler::once(download_default_avatar, scheduler::pipeline::async); scheduler::once([]() { diff --git a/src/client/component/input.cpp b/src/client/component/input.cpp index 45f55e08..d31dc888 100644 --- a/src/client/component/input.cpp +++ b/src/client/component/input.cpp @@ -4,7 +4,6 @@ #include "game/game.hpp" #include "game_console.hpp" -#include "ui_scripting.hpp" #include "game/ui_scripting/execution.hpp" #include @@ -18,7 +17,6 @@ namespace input void cl_char_event_stub(const int local_client_num, const int key) { - /* if (ui_scripting::lui_running()) { ui_scripting::notify("keypress", @@ -27,7 +25,6 @@ namespace input {"key", game::Key_KeynumToString(key, 0, 1)}, }); } - */ if (!game_console::console_char_event(local_client_num, key)) { @@ -39,7 +36,6 @@ namespace input void cl_key_event_stub(const int local_client_num, const int key, const int down) { - /* if (ui_scripting::lui_running()) { ui_scripting::notify(down ? "keydown" : "keyup", @@ -48,7 +44,6 @@ namespace input {"key", game::Key_KeynumToString(key, 0, 1)}, }); } - */ if (!game_console::console_key_event(local_client_num, key, down)) { diff --git a/src/client/component/lui.cpp b/src/client/component/lui.cpp index d8736114..53f652b4 100644 --- a/src/client/component/lui.cpp +++ b/src/client/component/lui.cpp @@ -15,14 +15,6 @@ namespace lui public: void post_unpack() override { - // Don't show create cod account popup - //utils::hook::set(0x14017C957, 0); - -//#ifdef _DEBUG - // Enable development menus (causes issues in sp) - //utils::hook::set(SELECT_VALUE(0x1400B4ABC, 0x1401AB779), 1); -//#endif - command::add("lui_open", [](const command::params& params) { if (params.size() <= 1) @@ -55,4 +47,4 @@ namespace lui }; } -//REGISTER_COMPONENT(lui::component) +REGISTER_COMPONENT(lui::component) diff --git a/src/client/component/scheduler.cpp b/src/client/component/scheduler.cpp index abe01fff..a5ef6f97 100644 --- a/src/client/component/scheduler.cpp +++ b/src/client/component/scheduler.cpp @@ -89,7 +89,7 @@ namespace scheduler utils::hook::detour r_end_frame_hook; utils::hook::detour g_run_frame_hook; utils::hook::detour main_frame_hook; - //utils::hook::detour hks_frame_hook; //no scripting for now + utils::hook::detour hks_frame_hook; void execute(const pipeline type) { @@ -209,7 +209,7 @@ namespace scheduler g_run_frame_hook.create(SELECT_VALUE(0x0, 0x417940_b), scheduler::server_frame_stub); main_frame_hook.create(SELECT_VALUE(0x0, 0x3438B0_b), scheduler::main_frame_stub); - //hks_frame_hook.create(SELECT_VALUE(0x0, 0x0), scheduler::hks_frame_stub); // no scripting for now + hks_frame_hook.create(SELECT_VALUE(0x0, 0x2792E0_b), scheduler::hks_frame_stub); } void pre_destroy() override diff --git a/src/client/component/stats.cpp b/src/client/component/stats.cpp index 8da3fa78..2684feb1 100644 --- a/src/client/component/stats.cpp +++ b/src/client/component/stats.cpp @@ -88,4 +88,4 @@ namespace stats }; } -// REGISTER_COMPONENT(stats::component) +REGISTER_COMPONENT(stats::component) diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index 46bf5332..75b89a0b 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -7,164 +7,339 @@ #include "scheduler.hpp" #include "command.hpp" -#include "ui_scripting.hpp" +#include "localized_strings.hpp" +#include "console.hpp" +#include "game_module.hpp" +#include "fps.hpp" +#include "server_list.hpp" -#include "game/ui_scripting/lua/engine.hpp" #include "game/ui_scripting/execution.hpp" -#include "game/ui_scripting/lua/error.hpp" +#include "game/scripting/execution.hpp" + +#include "ui_scripting.hpp" #include #include +#include namespace ui_scripting { namespace { - std::unordered_map converted_functions; + std::unordered_map> converted_functions; - utils::hook::detour hksi_lual_error_hook; - utils::hook::detour hksi_lual_error_hook2; utils::hook::detour hks_start_hook; utils::hook::detour hks_shutdown_hook; - utils::hook::detour hks_allocator_hook; - utils::hook::detour hks_frame_hook; - utils::hook::detour lui_error_hook; - utils::hook::detour hksi_hks_error_hook; + utils::hook::detour hks_package_require_hook; - bool error_hook_enabled = false; + utils::hook::detour hks_load_hook; + utils::hook::detour db_find_xasset_header_hook; - void hksi_lual_error_stub(game::hks::lua_State* s, const char* fmt, ...) + struct script { - char va_buffer[2048] = {0}; + std::string name; + std::string root; + }; - va_list ap; - va_start(ap, fmt); - vsprintf_s(va_buffer, fmt, ap); - va_end(ap); + struct globals_t + { + std::string in_require_script; + std::vector