From 76c4c44583a32b7df91f18f99d5c56475ec8fd78 Mon Sep 17 00:00:00 2001 From: BrentVL-1952840 <70229620+Brentdevent@users.noreply.github.com> Date: Sat, 18 Mar 2023 16:08:50 +0100 Subject: [PATCH 1/3] Fix registering sessionmode bool dvars not setting its value --- src/client/component/dvars_patches.cpp | 8 +++++++- src/client/game/symbols.hpp | 9 ++++++--- src/client/game/utils.cpp | 3 ++- src/client/game/utils.hpp | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/client/component/dvars_patches.cpp b/src/client/component/dvars_patches.cpp index e9a01a17..a91a0117 100644 --- a/src/client/component/dvars_patches.cpp +++ b/src/client/component/dvars_patches.cpp @@ -13,7 +13,7 @@ namespace dvars_patches { void patch_dvars() { - game::register_sessionmode_dvar_bool("com_pauseSupported", !game::is_server(), game::DVAR_SERVERINFO, "Whether is pause is ever supported by the game mode"); + game::register_sessionmode_dvar_bool("com_pauseSupported", !game::is_server(), game::DVAR_SERVERINFO, "Whether is pause is ever supported by the game mode", game::MODE_ZOMBIES); } void patch_flags() @@ -66,6 +66,12 @@ namespace dvars_patches // toggle ADS dof based on r_dof_enable utils::hook::jump(0x141116EBB_g, utils::hook::assemble(dof_enabled_stub)); + + // De-Arxan Dvar_SessionModeSetDefaultBool + utils::hook::nop(0x1422D0EDB_g, 9); + utils::hook::jump(0x1422D0EE6_g, 0x1422D11BA_g); + utils::hook::jump(0x1422D11D1_g, 0x1422D11EC_g); + utils::hook::jump(0x1422D11F1_g, 0x1422D142C_g); } }; } diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 70394a54..f594a8dc 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -108,19 +108,22 @@ namespace game const char* description)> Dvar_RegisterBool{ 0x1422D0900, 0x14057B500 }; - WEAK symbol Dvar_SessionModeRegisterBool{ 0x1422D0D40, 0x14057BAA0 }; + WEAK symbol Dvar_SessionModeSetDefaultBool{ + 0x1422D0E90, 0x14057BCE0 + }; WEAK symbol Dvar_RegisterString{ 0x1422D0B70 }; - WEAK symbol Dvar_ForEach{0x1422BCD00}; + WEAK symbol Dvar_ForEach{0x1422BCD00}; WEAK symbol Dvar_SetFromStringByName{ 0x1422C7500 }; - WEAK symbol Dvar_GetSessionModeSpecificDvar{ + WEAK symbol Dvar_GetSessionModeSpecificDvar{ 0x1422BF500, 0x140575D90 }; diff --git a/src/client/game/utils.cpp b/src/client/game/utils.cpp index 13923087..18918a3f 100644 --- a/src/client/game/utils.cpp +++ b/src/client/game/utils.cpp @@ -38,7 +38,7 @@ namespace game return dvar->current.value.enabled; } - dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description) + dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description, const eModes mode) { const auto hash = Dvar_GenerateHash(dvar_name); auto registered_dvar = Dvar_SessionModeRegisterBool(hash, dvar_name, value, flags, description); @@ -46,6 +46,7 @@ namespace game if (registered_dvar) { registered_dvar->debugName = dvar_name; + game::Dvar_SessionModeSetDefaultBool(hash, value, mode); } return registered_dvar; diff --git a/src/client/game/utils.hpp b/src/client/game/utils.hpp index abef6952..41f87e20 100644 --- a/src/client/game/utils.hpp +++ b/src/client/game/utils.hpp @@ -9,7 +9,7 @@ namespace game bool get_dvar_bool(const char* dvar_name); dvar_t* register_dvar_bool(const char* dvar_name, bool value, dvarFlags_e flags, const char* description); - dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description); + dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description, const eModes mode); void dvar_add_flags(const char* dvar, dvarFlags_e flags); void dvar_set_flags(const char* dvar_name, dvarFlags_e flags); } From f4f50d2c557ff38d2678bbb977a68132e7573179 Mon Sep 17 00:00:00 2001 From: BrentVL-1952840 <70229620+Brentdevent@users.noreply.github.com> Date: Sat, 18 Mar 2023 18:37:30 +0100 Subject: [PATCH 2/3] Patch value sessionmode bool dvar for every mode by default --- src/client/component/dvars_patches.cpp | 2 +- src/client/game/utils.cpp | 13 ++++++++++++- src/client/game/utils.hpp | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/client/component/dvars_patches.cpp b/src/client/component/dvars_patches.cpp index a91a0117..e45f793a 100644 --- a/src/client/component/dvars_patches.cpp +++ b/src/client/component/dvars_patches.cpp @@ -13,7 +13,7 @@ namespace dvars_patches { void patch_dvars() { - game::register_sessionmode_dvar_bool("com_pauseSupported", !game::is_server(), game::DVAR_SERVERINFO, "Whether is pause is ever supported by the game mode", game::MODE_ZOMBIES); + game::register_sessionmode_dvar_bool("com_pauseSupported", !game::is_server(), game::DVAR_SERVERINFO, "Whether is pause is ever supported by the game mode"); } void patch_flags() diff --git a/src/client/game/utils.cpp b/src/client/game/utils.cpp index 18918a3f..69c8a9a6 100644 --- a/src/client/game/utils.cpp +++ b/src/client/game/utils.cpp @@ -46,7 +46,18 @@ namespace game if (registered_dvar) { registered_dvar->debugName = dvar_name; - game::Dvar_SessionModeSetDefaultBool(hash, value, mode); + + if (mode == MODE_COUNT) + { + for (int i = MODE_FIRST; i < MODE_COUNT; ++i) + { + game::Dvar_SessionModeSetDefaultBool(hash, value, static_cast(i)); + } + } + else + { + game::Dvar_SessionModeSetDefaultBool(hash, value, mode); + } } return registered_dvar; diff --git a/src/client/game/utils.hpp b/src/client/game/utils.hpp index 41f87e20..07ffc164 100644 --- a/src/client/game/utils.hpp +++ b/src/client/game/utils.hpp @@ -9,7 +9,7 @@ namespace game bool get_dvar_bool(const char* dvar_name); dvar_t* register_dvar_bool(const char* dvar_name, bool value, dvarFlags_e flags, const char* description); - dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description, const eModes mode); + dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description, const eModes mode = MODE_COUNT); void dvar_add_flags(const char* dvar, dvarFlags_e flags); void dvar_set_flags(const char* dvar_name, dvarFlags_e flags); } From ab10d3641fe47d77d86747c2a8de7340c98044dc Mon Sep 17 00:00:00 2001 From: BrentVL-1952840 <70229620+Brentdevent@users.noreply.github.com> Date: Mon, 20 Mar 2023 21:38:15 +0100 Subject: [PATCH 3/3] Use call_safe method instead --- src/client/component/dvars_patches.cpp | 6 ------ src/client/game/utils.cpp | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/client/component/dvars_patches.cpp b/src/client/component/dvars_patches.cpp index e45f793a..e9a01a17 100644 --- a/src/client/component/dvars_patches.cpp +++ b/src/client/component/dvars_patches.cpp @@ -66,12 +66,6 @@ namespace dvars_patches // toggle ADS dof based on r_dof_enable utils::hook::jump(0x141116EBB_g, utils::hook::assemble(dof_enabled_stub)); - - // De-Arxan Dvar_SessionModeSetDefaultBool - utils::hook::nop(0x1422D0EDB_g, 9); - utils::hook::jump(0x1422D0EE6_g, 0x1422D11BA_g); - utils::hook::jump(0x1422D11D1_g, 0x1422D11EC_g); - utils::hook::jump(0x1422D11F1_g, 0x1422D142C_g); } }; } diff --git a/src/client/game/utils.cpp b/src/client/game/utils.cpp index 69c8a9a6..ed5642f2 100644 --- a/src/client/game/utils.cpp +++ b/src/client/game/utils.cpp @@ -51,12 +51,12 @@ namespace game { for (int i = MODE_FIRST; i < MODE_COUNT; ++i) { - game::Dvar_SessionModeSetDefaultBool(hash, value, static_cast(i)); + game::Dvar_SessionModeSetDefaultBool.call_safe(hash, value, static_cast(i)); } } else { - game::Dvar_SessionModeSetDefaultBool(hash, value, mode); + game::Dvar_SessionModeSetDefaultBool.call_safe(hash, value, mode); } }