diff --git a/src/client/component/command.cpp b/src/client/component/command.cpp index a83e0f85..90c06bca 100644 --- a/src/client/component/command.cpp +++ b/src/client/component/command.cpp @@ -118,8 +118,8 @@ namespace command const auto current = game::Dvar_ValueToString(dvar, true, dvar->current); const auto reset = game::Dvar_ValueToString(dvar, true, dvar->reset); - console::info("\"%s\" is: \"%s\" default: \"%s\" hash: 0x%08lX\n", - args[0], current, reset, dvar->hash); + console::info("\"%s\" is: \"%s\" default: \"%s\" hash: 0x%08lX type: %i\n", + args[0], current, reset, dvar->hash, dvar->type); const auto dvar_info = dvars::dvar_get_description(args[0]); diff --git a/src/client/component/dvars.cpp b/src/client/component/dvars.cpp index f1eca327..8b6b5770 100644 --- a/src/client/component/dvars.cpp +++ b/src/client/component/dvars.cpp @@ -237,8 +237,11 @@ namespace dvars } utils::hook::detour dvar_register_bool_hook; + utils::hook::detour dvar_register_bool_hashed_hook; utils::hook::detour dvar_register_float_hook; + utils::hook::detour dvar_register_float_hashed_hook; utils::hook::detour dvar_register_int_hook; + utils::hook::detour dvar_register_int_hashed_hook; utils::hook::detour dvar_register_string_hook; utils::hook::detour dvar_register_vector2_hook; utils::hook::detour dvar_register_vector3_hook; @@ -249,38 +252,6 @@ namespace dvars utils::hook::detour dvar_set_string_hook; utils::hook::detour dvar_set_from_string_hook; - utils::hook::detour dvar_re_register_hook; - utils::hook::detour dvar_register_new_hook; - - game::dvar_type get_normal_type(const game::dvar_type type) - { - switch (type) - { - case game::dvar_type::boolean_hashed: - return game::dvar_type::boolean; - case game::dvar_type::integer_hashed: - return game::dvar_type::integer; - case game::dvar_type::value_hashed: - return game::dvar_type::value; - default: - return type; - } - } - - void dvar_re_register_stub(game::dvar_t* dvar, const int hash, const char* name, game::dvar_type type, - const unsigned int flags, game::dvar_value* value, game::dvar_limits* domain) - { - type = get_normal_type(type); - dvar_re_register_hook.invoke(dvar, hash, name, type, flags, value, domain); - } - - game::dvar_t* dvar_register_new_stub(const int hash, const char* name, game::dvar_type type, - const unsigned int flags, game::dvar_value* value, game::dvar_limits* domain) - { - type = get_normal_type(type); - return dvar_register_new_hook.invoke(hash, name, type, flags, value, domain); - } - game::dvar_t* dvar_register_bool(const int hash, const char* name, bool value, unsigned int flags) { auto* var = find_dvar(override::register_bool_overrides, hash); @@ -293,6 +264,18 @@ namespace dvars return dvar_register_bool_hook.invoke(hash, name, value, flags); } + game::dvar_t* dvar_register_bool_hashed(const int hash, const char* name, bool value, unsigned int flags) + { + auto* var = find_dvar(override::register_bool_overrides, hash); + if (var) + { + value = var->value; + flags = var->flags; + } + + return dvar_register_bool_hashed_hook.invoke(hash, name, value, flags); + } + game::dvar_t* dvar_register_float(const int hash, const char* name, float value, float min, float max, unsigned int flags) { auto* var = find_dvar(override::register_float_overrides, hash); @@ -307,6 +290,20 @@ namespace dvars return dvar_register_float_hook.invoke(hash, name, value, min, max, flags); } + game::dvar_t* dvar_register_float_hashed(const int hash, const char* name, float value, float min, float max, unsigned int flags) + { + auto* var = find_dvar(override::register_float_overrides, hash); + if (var) + { + value = var->value; + min = var->min; + max = var->max; + flags = var->flags; + } + + return dvar_register_float_hashed_hook.invoke(hash, name, value, min, max, flags); + } + game::dvar_t* dvar_register_int(const int hash, const char* name, int value, int min, int max, unsigned int flags) { auto* var = find_dvar(override::register_int_overrides, hash); @@ -321,6 +318,20 @@ namespace dvars return dvar_register_int_hook.invoke(hash, name, value, min, max, flags); } + game::dvar_t* dvar_register_int_hashed(const int hash, const char* name, int value, int min, int max, unsigned int flags) + { + auto* var = find_dvar(override::register_int_overrides, hash); + if (var) + { + value = var->value; + min = var->min; + max = var->max; + flags = var->flags; + } + + return dvar_register_int_hashed_hook.invoke(hash, name, value, min, max, flags); + } + game::dvar_t* dvar_register_string(const int hash, const char* name, const char* value, unsigned int flags) { auto* var = find_dvar(override::register_string_overrides, hash); @@ -456,24 +467,21 @@ namespace dvars public: void post_unpack() override { - if (game::environment::is_mp()) - { - // dvar_register_new_hook.create(0x184DF0_b, dvar_register_new_stub); - // dvar_re_register_hook.create(0x185150_b, dvar_re_register_stub); - } + dvar_register_bool_hook.create(SELECT_VALUE(0x0, 0x182340_b), &dvar_register_bool); + dvar_register_bool_hashed_hook.create(SELECT_VALUE(0x0, 0x182420_b), &dvar_register_bool_hashed); + dvar_register_float_hook.create(SELECT_VALUE(0x0, 0x1827F0_b), &dvar_register_float); + dvar_register_float_hashed_hook.create(SELECT_VALUE(0x0, 0x182900_b), &dvar_register_float_hashed); + dvar_register_int_hook.create(SELECT_VALUE(0x0, 0x182A10_b), &dvar_register_int); + dvar_register_int_hashed_hook.create(SELECT_VALUE(0x0, 0x182AF0_b), &dvar_register_int_hashed); + dvar_register_string_hook.create(SELECT_VALUE(0x0, 0x182BD0_b), &dvar_register_string); + dvar_register_vector2_hook.create(SELECT_VALUE(0x0, 0x182CB0_b), &dvar_register_vector2); + dvar_register_vector3_hook.create(SELECT_VALUE(0x0, 0x182DB0_b), &dvar_register_vector3); - dvar_register_bool_hook.create(SELECT_VALUE(0x0, 0x182340_b), &dvar_register_bool); // good - //dvar_register_float_hook.create(SELECT_VALUE(0x0, 0x182900_b), &dvar_register_float); // FLOAT HASHED (TYPE 11 INSTEAD OF 1) - dvar_register_int_hook.create(SELECT_VALUE(0x0, 0x182A10_b), &dvar_register_int); // goood - //dvar_register_string_hook.create(SELECT_VALUE(0x0, 0x182AF0_b), &dvar_register_string); // INT HASHED (TYPE 12, INSTEAD OF 7) - //dvar_register_vector2_hook.create(SELECT_VALUE(0x0, 0x182BD0_b), &dvar_register_vector2); // STRING (TYPE 7 INSTEAD OF 2) - //dvar_register_vector3_hook.create(SELECT_VALUE(0x0, 0x182CB0_b), &dvar_register_vector3); // VEC2 (TYPE 2 INSTEAD OF 3) - - dvar_set_bool_hook.create(SELECT_VALUE(0x0, 0x185520_b), &dvar_set_bool); // good - dvar_set_float_hook.create(SELECT_VALUE(0x0, 0x185AA0_b), &dvar_set_float); // good - dvar_set_int_hook.create(SELECT_VALUE(0x0, 0x185D10_b), &dvar_set_int); // good - dvar_set_string_hook.create(SELECT_VALUE(0x0, 0x186080_b), &dvar_set_string); // good - dvar_set_from_string_hook.create(SELECT_VALUE(0x0, 0x185C60_b), &dvar_set_from_string); // good + dvar_set_bool_hook.create(SELECT_VALUE(0x0, 0x185520_b), &dvar_set_bool); + dvar_set_float_hook.create(SELECT_VALUE(0x0, 0x185AA0_b), &dvar_set_float); + dvar_set_int_hook.create(SELECT_VALUE(0x0, 0x185D10_b), &dvar_set_int); + dvar_set_string_hook.create(SELECT_VALUE(0x0, 0x186080_b), &dvar_set_string); + dvar_set_from_string_hook.create(SELECT_VALUE(0x0, 0x185C60_b), &dvar_set_from_string); } }; } diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index 73fdbdfe..d102e3ec 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -65,6 +65,8 @@ namespace patches return com_register_dvars_hook.invoke(); } + utils::hook::detour set_client_dvar_from_server_hook; + void set_client_dvar_from_server_stub(void* a1, void* a2, const char* dvar, const char* value) { if (dvar == "cg_fov"s || dvar == "cg_fovMin"s) @@ -72,8 +74,7 @@ namespace patches return; } - // CG_SetClientDvarFromServer - utils::hook::invoke(0x11AA90_b, a1, a2, dvar, value); + set_client_dvar_from_server_hook.invoke(0x11AA90_b, a1, a2, dvar, value); } const char* db_read_raw_file_stub(const char* filename, char* buf, const int size) @@ -156,15 +157,15 @@ namespace patches void post_unpack() override { // Register dvars - com_register_dvars_hook.create(SELECT_VALUE(0x140351B80, 0x1400D9320), &com_register_dvars_stub); + //com_register_dvars_hook.create(SELECT_VALUE(0x140351B80, 0x1400D9320), &com_register_dvars_stub); // Unlock fps in main menu - utils::hook::set(SELECT_VALUE(0x14018D47B, 0x14025B86B), 0xEB); + utils::hook::set(SELECT_VALUE(0, 0x34396B_b), 0xEB); if (!game::environment::is_dedi()) { // Fix mouse lag - utils::hook::nop(SELECT_VALUE(0x1403E3C05, 0x1404DB1AF), 6); + // utils::hook::nop(SELECT_VALUE(0x1403E3C05, 0x1404DB1AF), 6); scheduler::loop([]() { SetThreadExecutionState(ES_DISPLAY_REQUIRED); @@ -177,11 +178,11 @@ namespace patches dvars::override::register_float("cg_fovMin", 1.f, 1.0f, 90.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); + // utils::hook::nop(SELECT_VALUE(0x14018797E, 0x14024EF60), 2); + // utils::hook::nop(SELECT_VALUE(0x1401856DC, 0x14024C6B0), 6); // Allow executing custom cfg files with the "exec" command - utils::hook::call(SELECT_VALUE(0x140343855, 0x140403E28), db_read_raw_file_stub); + // utils::hook::call(SELECT_VALUE(0x140343855, 0x140403E28), db_read_raw_file_stub); if (!game::environment::is_sp()) { @@ -192,10 +193,10 @@ namespace patches static void patch_mp() { // Use name dvar - utils::hook::jump(0x14050FF90, &live_get_local_client_name); + //utils::hook::jump(0x5BB9C0_b, &live_get_local_client_name, true); // Patch SV_KickClientNum - sv_kick_client_num_hook.create(0x14047ED00, &sv_kick_client_num); + /*sv_kick_client_num_hook.create(0x14047ED00, &sv_kick_client_num); // block changing name in-game utils::hook::set(0x14047FC90, 0xC3); @@ -218,29 +219,29 @@ namespace patches // disable elite_clan dvars::override::register_int("elite_clan_active", 0, 0, 0, game::DVAR_FLAG_NONE); - utils::hook::set(0x140585680, 0xC3); // don't register commands + utils::hook::set(0x140585680, 0xC3); // don't register commands*/ // disable codPointStore dvars::override::register_int("codPointStore_enabled", 0, 0, 0, game::DVAR_FLAG_NONE); // don't register every replicated dvar as a network dvar - utils::hook::nop(0x14039E58E, 5); // dvar_foreach + utils::hook::nop(0x47408E_b, 5); // dvar_foreach // patch "Server is different version" to show the server client version - utils::hook::inject(0x140480955, VERSION); + // utils::hook::inject(0x140480955, VERSION); // prevent servers overriding our fov - utils::hook::call(0xF4500_b, set_client_dvar_from_server_stub); - // utils::hook::nop(0x1400DAF69, 5); - // utils::hook::nop(0x140190C16, 5); + set_client_dvar_from_server_hook.create(0x11AA90_b, set_client_dvar_from_server_stub); + utils::hook::nop(0x17DA96_b, 0x16); + utils::hook::nop(0xE00BE_b, 0x17); utils::hook::set(0x307F39_b, 0xEB); // some [data validation] anti tamper thing that kills performance dvars::override::register_int("dvl", 0, 0, 0, game::DVAR_FLAG_READ); // unlock safeArea_* - utils::hook::jump(0x1402624F5, 0x140262503); - utils::hook::jump(0x14026251C, 0x140262547); + /*utils::hook::jump(0x1402624F5, 0x140262503); + utils::hook::jump(0x14026251C, 0x140262547);*/ dvars::override::register_float("safeArea_adjusted_horizontal", 1, 0, 1, game::DVAR_FLAG_SAVED); dvars::override::register_float("safeArea_adjusted_vertical", 1, 0, 1, game::DVAR_FLAG_SAVED); dvars::override::register_float("safeArea_horizontal", 1, 0, 1, game::DVAR_FLAG_SAVED); @@ -262,7 +263,7 @@ namespace patches dvars::override::register_int("com_maxfps", 0, 0, 1000, game::DVAR_FLAG_SAVED); // Prevent clients from ending the game as non host by sending 'end_game' lui notification - cmd_lui_notify_server_hook.create(0x140335A70, cmd_lui_notify_server_stub); + /*cmd_lui_notify_server_hook.create(0x140335A70, cmd_lui_notify_server_stub); // Prevent clients from sending invalid reliableAcknowledge utils::hook::call(0x1404899C6, sv_execute_client_message_stub); @@ -275,7 +276,7 @@ namespace patches utils::hook::jump(0x140578C40, free); utils::hook::jump(0x140578D30, realloc); utils::hook::jump(0x140578B60, _aligned_realloc); - } + }*/ // Change default hostname and make it replicated dvars::override::register_string("sv_hostname", "^2H1-Mod^7 Default Server", game::DVAR_FLAG_REPLICATED); @@ -283,4 +284,4 @@ namespace patches }; } -//REGISTER_COMPONENT(patches::component) +REGISTER_COMPONENT(patches::component) diff --git a/src/client/component/ranked.cpp b/src/client/component/ranked.cpp index 4ec15b44..955a1984 100644 --- a/src/client/component/ranked.cpp +++ b/src/client/component/ranked.cpp @@ -27,21 +27,19 @@ namespace ranked dvars::override::register_bool("xblive_privatematch", false, game::DVAR_FLAG_REPLICATED); } - if (game::environment::is_dedi() && !utils::flags::has_flag("unranked")) + if (game::environment::is_dedi()) { dvars::override::register_bool("xblive_privatematch", false, game::DVAR_FLAG_REPLICATED | game::DVAR_FLAG_WRITE); - - // Skip some check in _menus.gsc - dvars::register_bool("force_ranking", true, game::DVAR_FLAG_WRITE, ""); + dvars::register_bool("force_ranking", true, game::DVAR_FLAG_WRITE, ""); // Skip some check in _menus.gsc } // Always run bots, even if xblive_privatematch is 0 - utils::hook::set(0x1401D9300, 0xC301B0); // BG_BotSystemEnabled - utils::hook::set(0x1401D90D0, 0xC301B0); // BG_AISystemEnabled - utils::hook::set(0x1401D92A0, 0xC301B0); // BG_BotFastFileEnabled - utils::hook::set(0x1401D9400, 0xC301B0); // BG_BotsUsingTeamDifficulty + utils::hook::set(0x2C10B0_b, 0xC301B0); // BG_BotSystemEnabled + utils::hook::set(0x2C0E60_b, 0xC301B0); // BG_AISystemEnabled + utils::hook::set(0x2C1040_b, 0xC301B0); // BG_BotFastFileEnabled + utils::hook::set(0x2C11B0_b, 0xC301B0); // BG_BotsUsingTeamDifficulty } }; } -//REGISTER_COMPONENT(ranked::component) +REGISTER_COMPONENT(ranked::component)