diff --git a/src/client/component/bots.cpp b/src/client/component/bots.cpp index bbc7d556..5f49f80f 100644 --- a/src/client/component/bots.cpp +++ b/src/client/component/bots.cpp @@ -41,12 +41,16 @@ namespace bots } } - struct component final : client_component + struct component final : generic_component { void post_unpack() override { - utils::hook::jump(0x141653B70_g, get_bot_name); - utils::hook::jump(0x141654280_g, get_bot_name); + utils::hook::jump(game::select(0x141653B70, 0x1402732E0), get_bot_name); + + if (!game::is_server()) + { + utils::hook::jump(0x141654280_g, get_bot_name); + } command::add("spawnBot", [](const command::params& params) { diff --git a/src/client/component/command.cpp b/src/client/component/command.cpp index 7c0b31d4..6ca8d9dc 100644 --- a/src/client/component/command.cpp +++ b/src/client/component/command.cpp @@ -2,8 +2,8 @@ #include "loader/component_loader.hpp" #include "command.hpp" -#include "scheduler.hpp" #include +#include #include #include @@ -21,9 +21,10 @@ namespace command void execute_custom_command() { const params params{}; + const auto command = utils::string::to_lower(params[0]); auto& map = get_command_map(); - const auto entry = map.find(params[0]); + const auto entry = map.find(command); if (entry != map.end()) { entry->second(params); @@ -46,12 +47,12 @@ namespace command } } - struct component final : client_component + struct component final : generic_component { void post_unpack() override { // Disable whitelist - utils::hook::jump(0x14133CF70_g, update_whitelist_stub); + utils::hook::jump(game::select(0x1420EF190, 0x1404F9CD0), update_whitelist_stub); } }; @@ -88,30 +89,34 @@ namespace command return result; } - void add(std::string command, command_function function) + void add(const std::string& command, command_function function) { - add(std::move(command), [f = std::move(function)](const params&) + add(command, [f = std::move(function)](const params&) { f(); }); } - void add(std::string command, command_param_function function) + void add(const std::string& command, command_param_function function) { + auto lower_command = utils::string::to_lower(command); + auto& map = get_command_map(); - const auto reregister = map.contains(command); + const auto is_registered = map.contains(lower_command); - if (!reregister) + map[std::move(lower_command)] = std::move(function); + + if (is_registered) { - auto& allocator = *utils::memory::get_allocator(); - auto* cmd_function = allocator.allocate(); - const auto* cmd_string = allocator.duplicate_string(command); - - game::Cmd_AddCommandInternal(cmd_string, execute_custom_command, cmd_function); - cmd_function->autoComplete = 1; + return; } - map[std::move(command)] = std::move(function); + auto& allocator = *utils::memory::get_allocator(); + auto* cmd_function = allocator.allocate(); + const auto* cmd_string = allocator.duplicate_string(command); + + game::Cmd_AddCommandInternal(cmd_string, execute_custom_command, cmd_function); + cmd_function->autoComplete = 1; } } diff --git a/src/client/component/command.hpp b/src/client/component/command.hpp index 3ab882ab..94c9b1aa 100644 --- a/src/client/component/command.hpp +++ b/src/client/component/command.hpp @@ -23,6 +23,6 @@ namespace command using command_function = std::function; using command_param_function = std::function; - void add(std::string command, command_function function); - void add(std::string command, command_param_function function); + void add(const std::string& command, command_function function); + void add(const std::string& command, command_param_function function); } diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index f8ad7b45..28cd008c 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -23,7 +23,7 @@ namespace game WEAK symbol Cbuf_AddText{0x1420EC8B0}; WEAK symbol Cmd_AddCommandInternal{ - 0x1420ED530 + 0x1420ED530, 0x1404F8210 }; WEAK symbol Cmd_ExecuteSingleCommand{ @@ -49,7 +49,7 @@ namespace game // Sys WEAK symbol Sys_Milliseconds{0x142333430}; WEAK symbol Sys_ShowConsole{0x142333F80}; - WEAK symbol Sys_GetTLS{0x142184210}; + WEAK symbol Sys_GetTLS{0x142184210, 0x140525EB0}; // Dvar WEAK symbol Dvar_FindVar{0x1422BD730, 0x140575540}; @@ -68,11 +68,11 @@ namespace game }; // Rendering - WEAK symbol SV_AddTestClient{0x1422499A0}; + WEAK symbol SV_AddTestClient{0x1422499A0, 0x14052E3E0}; // Variables - WEAK symbol cmd_functions{0x15689FF58}; + WEAK symbol cmd_functions{0x15689FF58, 0x14946F860}; WEAK symbol sv_cmd_args{0x15689CE30}; WEAK symbol ip_socket{0x157E77818, 0x14A640988};