diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index ed7ff440..445fb1e7 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -13,7 +13,6 @@ namespace patches { utils::hook::detour gscr_set_save_dvar_hook; utils::hook::detour dvar_register_float_hook; - utils::hook::detour dvar_register_bool_hook; void* sub_46148() { @@ -30,7 +29,7 @@ namespace patches void gscr_set_save_dvar_stub() { const auto string = utils::string::to_lower(utils::hook::invoke(0x1405C7C20, 0)); - if (string == "cg_fov" || string == "cg_fovscale" || string == "snd_musicdisabledforcustomsoundtrack") + if (string == "cg_fov" || string == "cg_fovscale") { return; } @@ -59,20 +58,6 @@ namespace patches return dvar_register_float_hook.invoke(hash, dvarName, value, min, max, flags); } - game::dvar_t* snd_musicDisabledForCustomSoundtrack = nullptr; - - game::dvar_t* dvar_register_bool_stub(int hash, const char* name, bool value, unsigned int flags) - { - static const auto snd_musicdisabledforcustomsoundtrack_hash = game::generateHashValue("snd_musicdisabledforcustomsoundtrack"); - - if (hash == snd_musicdisabledforcustomsoundtrack_hash) - { - return snd_musicDisabledForCustomSoundtrack; - } - - return dvar_register_bool_hook.invoke(hash, name, value, flags); - } - void free_lui_memory() { utils::hook::invoke(0x14032A540); // properly free lui memory @@ -89,6 +74,11 @@ namespace patches free_lui_memory(); utils::hook::invoke(0x1406B5290); } + + game::dvar_t* register_snd_music_stub(int hash, const char* name, bool value, unsigned int /*flags*/) + { + return game::Dvar_RegisterBool(hash, name, value, game::DVAR_FLAG_SAVED); + } } class component final : public component_interface @@ -123,17 +113,14 @@ namespace patches cg_fovScale = dvars::register_float("cg_fovScale", 1.f, 0.1f, 2.f, game::DVAR_FLAG_SAVED, "Scale applied to the field of view"); - // Make snd_musicDisabledForCustomSoundtrack saved dvar - - snd_musicDisabledForCustomSoundtrack = dvars::register_bool("snd_musicDisabledForCustomSoundtrack", 0, - game::DVAR_FLAG_SAVED, "Disable all in-game music"); - dvar_register_float_hook.create(game::Dvar_RegisterFloat.get(), dvar_register_float_stub); - dvar_register_bool_hook.create(game::Dvar_RegisterBool.get(), dvar_register_bool_stub); // fix vid_restart crashing utils::hook::call(0x1403D7413, vid_restart_stub_1); utils::hook::jump(0x1403D7402, vid_restart_stub_2); + + // make snd_musicDisabledForCustomSoundtrack saved + utils::hook::call(0x1405D05FB, register_snd_music_stub); } }; }