diff --git a/src/client/component/dedicated.cpp b/src/client/component/dedicated.cpp index 2031788a..a199913b 100644 --- a/src/client/component/dedicated.cpp +++ b/src/client/component/dedicated.cpp @@ -8,6 +8,7 @@ #include "game/dvars.hpp" #include "dvars.hpp" #include "console.hpp" +#include "gsc.hpp" #include #include @@ -80,12 +81,11 @@ namespace dedicated return console_command_queue; } - void execute_console_command(const int client, const char* command) + void execute_console_command([[maybe_unused]] const int local_client_num, const char* command) { if (game::Live_SyncOnlineDataFlags(0) == 0) { - game::Cbuf_AddText(client, 0, command); - game::Cbuf_AddText(client, 0, "\n"); + command::execute(command); } else { @@ -100,8 +100,7 @@ namespace dedicated for (const auto& command : queue) { - game::Cbuf_AddText(0, 0, command.data()); - game::Cbuf_AddText(0, 0, "\n"); + command::execute(command); } } @@ -110,21 +109,6 @@ namespace dedicated std::this_thread::sleep_for(1ms); } - game::dvar_t* gscr_set_dynamic_dvar() - { - /* - auto s = game::Scr_GetString(0); - auto* dvar = game::Dvar_FindVar(s); - - if (dvar && !strncmp("scr_", dvar->name, 4)) - { - return dvar; - } - */ - - return gscr_set_dynamic_dvar_hook.invoke(); - } - void kill_server() { const auto* svs_clients = *game::mp::svs_clients; @@ -237,15 +221,18 @@ namespace dedicated a.popad64(); a.jmp(0x157DDF_b); - }), true);// + }), true); + + // return 0 so the game doesn't override the cfg + gsc::function::add("isusingmatchrulesdata", []() + { + game::Scr_AddInt(0); + }); // delay console commands until the initialization is done // COULDN'T FOUND // utils::hook::call(0x1400D808C, execute_console_command); // utils::hook::nop(0x1400D80A4, 5); - // patch GScr_SetDynamicDvar to behave better - gscr_set_dynamic_dvar_hook.create(0x43CF60_b, &gscr_set_dynamic_dvar); - utils::hook::nop(0x189514_b, 248); // don't load config file utils::hook::nop(0x156C46_b, 5); // ^ utils::hook::set(0x17F470_b, 0xC3); // don't save config file diff --git a/src/client/component/gsc.cpp b/src/client/component/gsc.cpp index 274f0810..68985991 100644 --- a/src/client/component/gsc.cpp +++ b/src/client/component/gsc.cpp @@ -588,7 +588,7 @@ namespace gsc namespace method { - void add(const std::string& name, builtin_method method) + void add(const std::string& name, scripting::script_function method) { if (xsk::gsc::h1::resolver::find_method(name)) { @@ -668,7 +668,7 @@ namespace gsc utils::hook::nop(SELECT_VALUE(0x3CB723_b, 0x512783_b), 8); utils::hook::call(SELECT_VALUE(0x3CB723_b, 0x512783_b), vm_call_builtin_function_stub); - gsc::function::add("print", []() + function::add("print", []() { const auto num = game::Scr_GetNumParam(); std::string buffer{}; @@ -683,7 +683,7 @@ namespace gsc console::info("%s\n", buffer.data()); }); - gsc::function::add("assert", []() + function::add("assert", []() { const auto expr = get_argument(0).as(); if (!expr) @@ -692,7 +692,7 @@ namespace gsc } }); - gsc::function::add("assertex", []() + function::add("assertex", []() { const auto expr = get_argument(0).as(); if (!expr) @@ -702,7 +702,7 @@ namespace gsc } }); - gsc::function::add("replacefunc", []() + function::add("replacefunc", []() { const auto what = get_argument(0).get_raw(); const auto with = get_argument(1).get_raw(); diff --git a/src/client/component/slowmotion.cpp b/src/client/component/slowmotion.cpp index f7ed223a..1ae9cb98 100644 --- a/src/client/component/slowmotion.cpp +++ b/src/client/component/slowmotion.cpp @@ -22,12 +22,12 @@ namespace slowmotion if (game::Scr_GetNumParam() >= 2) { - end = game::Scr_GetFloat(1u); + end = game::Scr_GetFloat(1); } if (game::Scr_GetNumParam() >= 3) { - duration = static_cast(game::Scr_GetFloat(2u) * 1000.0f); + duration = static_cast(game::Scr_GetFloat(2) * 1000.0f); } game::SV_SetConfigstring(10, utils::string::va("%i %i %g %g", *game::mp::gameTime, duration, start, end)); diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index c4a40c37..e9a593d7 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -158,9 +158,9 @@ namespace game WEAK symbol Scr_NotifyId{0x3C92E0, 0x510340}; WEAK symbol Scr_AllocVector{0x3C42D0, 0x50B330}; - WEAK symbol Scr_GetFloat{0x3C87D0, 0x50F870}; - WEAK symbol Scr_GetString{0x3C8CC0, 0x50FCB0}; - WEAK symbol Scr_GetNumParam{0x3C89E0, 0x50F9D0}; + WEAK symbol Scr_GetFloat{0x3C87D0, 0x50F870}; + WEAK symbol Scr_GetString{0x3C8CC0, 0x50FCB0}; + WEAK symbol Scr_GetNumParam{0x3C89E0, 0x50F9D0}; WEAK symbol Scr_ClearOutParams{0x3C7EF0, 0x50F070}; WEAK symbol Scr_GetEntityIdRef{0x3C6760, 0x50D8E0}; WEAK symbol Scr_GetEntityId{0x3C66B0, 0x50D830};