diff --git a/src/client/component/console.cpp b/src/client/component/console.cpp index 381f16f1..0d887199 100644 --- a/src/client/component/console.cpp +++ b/src/client/component/console.cpp @@ -125,8 +125,10 @@ namespace console this->console_thread_.join(); } +#ifndef NATIVE_CONSOLE _close(this->handles_[0]); _close(this->handles_[1]); +#endif messages.access([&](message_queue& msgs) { diff --git a/src/client/component/dvars.cpp b/src/client/component/dvars.cpp index d8221d67..4a086a27 100644 --- a/src/client/component/dvars.cpp +++ b/src/client/component/dvars.cpp @@ -144,6 +144,7 @@ namespace dvars static std::unordered_map set_float_overrides; static std::unordered_map set_int_overrides; static std::unordered_map set_string_overrides; + static std::unordered_map set_from_string_overrides; void register_bool(const std::string& name, const bool value, const unsigned int flags) { @@ -228,6 +229,11 @@ namespace dvars { set_string_overrides[name] = value; } + + void set_from_string(const std::string& name, const std::string& value) + { + set_from_string_overrides[name] = value; + } } utils::hook::detour dvar_register_bool_hook; @@ -241,6 +247,7 @@ namespace dvars utils::hook::detour dvar_set_float_hook; utils::hook::detour dvar_set_int_hook; utils::hook::detour dvar_set_string_hook; + utils::hook::detour dvar_set_from_string_hook; game::dvar_t* dvar_register_bool(const int hash, const char* name, bool value, unsigned int flags) { @@ -395,6 +402,23 @@ namespace dvars return dvar_set_string_hook.invoke(dvar, string); } + void dvar_set_from_string(game::dvar_t* dvar, const char* string, game::DvarSetSource source) + { + const auto disabled = find_dvar(disable::set_string_disables, dvar->hash); + if (disabled) + { + return; + } + + auto* var = find_dvar(override::set_from_string_overrides, dvar->hash); + if (var) + { + string = var->data(); + } + + return dvar_set_from_string_hook.invoke(dvar, string, source); + } + class component final : public component_interface { public: @@ -411,6 +435,7 @@ namespace dvars dvar_set_float_hook.create(SELECT_VALUE(0x1403C7420, 0x1404FD360), &dvar_set_float); dvar_set_int_hook.create(SELECT_VALUE(0x1403C76C0, 0x1404FD5E0), &dvar_set_int); dvar_set_string_hook.create(SELECT_VALUE(0x1403C7900, 0x1404FD8D0), &dvar_set_string); + dvar_set_from_string_hook.create(SELECT_VALUE(0, 0x1404FD520), &dvar_set_from_string); } }; } diff --git a/src/client/component/dvars.hpp b/src/client/component/dvars.hpp index 057c4d1b..66d6912d 100644 --- a/src/client/component/dvars.hpp +++ b/src/client/component/dvars.hpp @@ -23,5 +23,6 @@ namespace dvars void set_float(const std::string& name, float fl); void set_int(const std::string& name, int integer); void set_string(const std::string& name, const std::string& string); + void set_from_string(const std::string& name, const std::string& value); } } diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index dc12fbab..42295455 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -33,7 +33,6 @@ namespace patches { return; } - return sv_kick_client_num_hook.invoke(client_num, reason); } @@ -134,6 +133,14 @@ namespace patches reinterpret_cast(0x140481A00)(client, msg); } + + void aim_assist_add_to_target_list(void* a1, void* a2) + { + if (!dvars::aimassist_enabled->current.enabled) + return; + + game::AimAssist_AddToTargetList(a1, a2); + } } class component final : public component_interface @@ -160,6 +167,10 @@ namespace patches // Make cg_fov and cg_fovscale saved dvars dvars::override::register_float("cg_fov", 65.f, 40.f, 200.f, game::DvarFlags::DVAR_FLAG_SAVED); dvars::override::register_float("cg_fovScale", 1.f, 0.1f, 2.f, game::DvarFlags::DVAR_FLAG_SAVED); + + // Allow kbam input when gamepad is enabled + utils::hook::nop(SELECT_VALUE(0x14018797E, 0x14024EF60), 2); + utils::hook::nop(SELECT_VALUE(0x1401856DC, 0x14024C6B0), 6); if (game::environment::is_mp()) { @@ -182,10 +193,10 @@ namespace patches utils::hook::call(0x1402BA26B, bsp_sys_error_stub); // H1(1.4) // client side aim assist dvar - //dvars::aimassist_enabled = game::Dvar_RegisterBool("aimassist_enabled", true, - // game::DvarFlags::DVAR_FLAG_SAVED, - // "Enables aim assist for controllers"); - //utils::hook::call(0x140003609, aim_assist_add_to_target_list); + dvars::aimassist_enabled = dvars::register_bool("aimassist_enabled", true, + game::DvarFlags::DVAR_FLAG_SAVED, + true); + utils::hook::call(0x14009EE9E, aim_assist_add_to_target_list); // unlock all items utils::hook::jump(0x140413E60, is_item_unlocked); // LiveStorage_IsItemUnlockedFromTable_LocalClient H1(1.4) diff --git a/src/client/component/shaders.cpp b/src/client/component/shaders.cpp new file mode 100644 index 00000000..ec632115 --- /dev/null +++ b/src/client/component/shaders.cpp @@ -0,0 +1,50 @@ +#include +#include "loader/component_loader.hpp" + +#include "scheduler.hpp" +#include "dvars.hpp" + +#include "game/game.hpp" +#include "game/dvars.hpp" + +#include +#include +#include + +namespace shaders +{ + namespace + { + game::dvar_t* disable_shader_caching = nullptr; + + bool shader_should_show_dialog_stub() + { + return !disable_shader_caching->current.enabled; + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + if (!game::environment::is_mp()) + { + return; + } + + const auto has_flag = utils::flags::has_flag("noshadercaching"); + + disable_shader_caching = dvars::register_bool("disable_shader_caching", has_flag, game::DVAR_FLAG_SAVED, true); + if (has_flag) + { + dvars::override::set_bool("disable_shader_caching", 1); + dvars::override::set_from_string("disable_shader_caching", "1"); + } + + utils::hook::jump(0x14007E710, shader_should_show_dialog_stub); + } + }; +} + +REGISTER_COMPONENT(shaders::component) diff --git a/src/client/game/dvars.cpp b/src/client/game/dvars.cpp index 5145d5d7..8d0c361f 100644 --- a/src/client/game/dvars.cpp +++ b/src/client/game/dvars.cpp @@ -9,15 +9,7 @@ namespace dvars { - struct dvar_base - { - unsigned int flags{}; - }; - - struct dvar_bool : dvar_base - { - bool value{}; - }; + game::dvar_t* aimassist_enabled = nullptr; game::dvar_t* con_inputBoxColor = nullptr; game::dvar_t* con_inputHintBoxColor = nullptr; diff --git a/src/client/game/dvars.hpp b/src/client/game/dvars.hpp index f803aaa9..1a48de7c 100644 --- a/src/client/game/dvars.hpp +++ b/src/client/game/dvars.hpp @@ -6,6 +6,8 @@ namespace dvars { + extern game::dvar_t* aimassist_enabled; + extern game::dvar_t* con_inputBoxColor; extern game::dvar_t* con_inputHintBoxColor; extern game::dvar_t* con_outputBarColor; diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index cb0feba9..d82ee023 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -18,6 +18,8 @@ namespace game WEAK symbol Cmd_TokenizeString{0x140344110, 0x1404046F0}; WEAK symbol Cmd_EndTokenizeString{0x140343630, 0x140403C20}; + WEAK symbol AimAssist_AddToTargetList{0, 0x14009D0F0}; + WEAK symbol Com_Frame_Try_Block_Function{0, 0x1400D8310}; WEAK symbol Com_GetCurrentCoDPlayMode{0, 0x1405039A0}; WEAK symbol Com_SetSlowMotion{0, 0x1400DB790}; diff --git a/src/common/utils/flags.cpp b/src/common/utils/flags.cpp index cbada183..09f13114 100644 --- a/src/common/utils/flags.cpp +++ b/src/common/utils/flags.cpp @@ -37,6 +37,7 @@ namespace utils::flags if (!parsed) { parse_flags(enabled_flags); + parsed = true; } for (const auto& entry : enabled_flags)