diff --git a/src/client/component/bullet.cpp b/src/client/component/bullet.cpp new file mode 100644 index 00000000..d58e42b1 --- /dev/null +++ b/src/client/component/bullet.cpp @@ -0,0 +1,46 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" +#include "game/dvars.hpp" + +#include + +namespace bullet +{ + namespace + { + game::dvar_t* bg_surface_penetration = nullptr; + utils::hook::detour bg_get_surface_penetration_depth_hook; + + float bg_get_surface_penetration_depth_stub(game::Weapon weapon, bool is_alternate, int surface_type) + { + if (bg_surface_penetration->current.value > 0.0f) + { + return bg_surface_penetration->current.value; + } + + return bg_get_surface_penetration_depth_hook.invoke(weapon, is_alternate, surface_type); + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + if (game::environment::is_sp()) + { + return; + } + + bg_surface_penetration = dvars::register_float("bg_surfacePenetration", 0.0f, + 0.0f, std::numeric_limits::max(), game::DVAR_FLAG_SAVED, + "Set to a value greater than 0 to override the surface penetration depth"); + + bg_get_surface_penetration_depth_hook.create(0x2E1110_b, &bg_get_surface_penetration_depth_stub); + } + }; +} + +REGISTER_COMPONENT(bullet::component) diff --git a/src/client/component/dvars.cpp b/src/client/component/dvars.cpp index cb2a6914..3b285f20 100644 --- a/src/client/component/dvars.cpp +++ b/src/client/component/dvars.cpp @@ -35,7 +35,6 @@ namespace dvars struct dvar_vector3 : dvar_base { - float x{}; float y{}; float z{}; @@ -43,6 +42,12 @@ namespace dvars float max{}; }; + struct dvar_enum : dvar_base + { + const char* const* value_list{}; + int default_index{}; + }; + struct dvar_int : dvar_base { int value{}; @@ -139,6 +144,7 @@ namespace dvars static std::unordered_map register_string_overrides; static std::unordered_map register_vector2_overrides; static std::unordered_map register_vector3_overrides; + static std::unordered_map register_enum_overrides; static std::unordered_map set_bool_overrides; static std::unordered_map set_float_overrides; @@ -210,6 +216,16 @@ namespace dvars register_vector3_overrides[name] = std::move(values); } + void register_enum(const std::string& name, /*const char* const* value_list, int default_index,*/ + const unsigned int flags) + { + dvar_enum values; + //values.value_list = value_list; + //values.default_index = default_index; + values.flags = flags; + register_enum_overrides[name] = std::move(values); + } + void set_bool(const std::string& name, const bool value) { set_bool_overrides[name] = value; @@ -245,6 +261,7 @@ namespace dvars utils::hook::detour dvar_register_string_hook; utils::hook::detour dvar_register_vector2_hook; utils::hook::detour dvar_register_vector3_hook; + utils::hook::detour dvar_register_enum_hook; utils::hook::detour dvar_set_bool_hook; utils::hook::detour dvar_set_float_hook; @@ -377,6 +394,19 @@ namespace dvars return dvar_register_vector3_hook.invoke(hash, name, x, y, z, min, max, flags); } + game::dvar_t* dvar_register_enum(const int hash, const char* name, const char* const value_list, int default_index, unsigned int flags) + { + auto* var = find_dvar(override::register_enum_overrides, hash); + if (var) + { + //value_list = var->value_list; + //default_index = var->default_index; + flags = var->flags; + } + + return dvar_register_enum_hook.invoke(hash, name, value_list, default_index, flags); + } + void dvar_set_bool(game::dvar_t* dvar, bool boolean) { const auto disabled = find_dvar(disable::set_bool_disables, dvar->hash); @@ -473,6 +503,7 @@ namespace dvars dvar_register_string_hook.create(SELECT_VALUE(0x4197E0_b, 0x182BD0_b), &dvar_register_string); dvar_register_vector2_hook.create(SELECT_VALUE(0x4198C0_b, 0x182CB0_b), &dvar_register_vector2); dvar_register_vector3_hook.create(SELECT_VALUE(0x419A00_b, 0x182DB0_b), &dvar_register_vector3); + dvar_register_enum_hook.create(SELECT_VALUE(0x419500_b, 0x182700_b), &dvar_register_enum); if (!game::environment::is_sp()) { diff --git a/src/client/component/dvars.hpp b/src/client/component/dvars.hpp index 66d6912d..419530e2 100644 --- a/src/client/component/dvars.hpp +++ b/src/client/component/dvars.hpp @@ -18,6 +18,7 @@ namespace dvars void register_string(const std::string& name, const std::string& value, const unsigned int flags); void register_vec2(const std::string& name, float x, float y, float min, float max, const unsigned int flags); void register_vec3(const std::string& name, float x, float y, float z, float min, float max, const unsigned int flags); + void register_enum(const std::string& name, /*const char* const* value_list, int default_index,*/ const unsigned int flags); void set_bool(const std::string& name, bool boolean); void set_float(const std::string& name, float fl); diff --git a/src/client/component/renderer.cpp b/src/client/component/renderer.cpp index 666ae0f0..eed4cd4e 100644 --- a/src/client/component/renderer.cpp +++ b/src/client/component/renderer.cpp @@ -1,5 +1,8 @@ #include #include "loader/component_loader.hpp" + +#include "dvars.hpp" + #include "game/game.hpp" #include "game/dvars.hpp" @@ -30,7 +33,6 @@ namespace renderer void gfxdrawmethod() { game::gfxDrawMethod->drawScene = game::GFX_DRAW_SCENE_STANDARD; - game::gfxDrawMethod->baseTechType = dvars::r_fullbright->current.enabled ? get_fullbright_technique() : game::TECHNIQUE_LIT; game::gfxDrawMethod->emissiveTechType = dvars::r_fullbright->current.enabled ? get_fullbright_technique() : game::TECHNIQUE_EMISSIVE; game::gfxDrawMethod->forceTechType = dvars::r_fullbright->current.enabled ? get_fullbright_technique() : 242; @@ -67,19 +69,15 @@ namespace renderer dvars::r_fullbright = dvars::register_int("r_fullbright", 0, 0, 4, game::DVAR_FLAG_SAVED, "Toggles rendering without lighting"); - r_init_draw_method_hook.create(SELECT_VALUE(0x1404BD140, 0x1405C46E0), &r_init_draw_method_stub); - r_update_front_end_dvar_options_hook.create(SELECT_VALUE(0x1404F8870, 0x1405FF9E0), &r_update_front_end_dvar_options_stub); + r_init_draw_method_hook.create(SELECT_VALUE(0x5467E0_b, 0x669580_b), &r_init_draw_method_stub); + r_update_front_end_dvar_options_hook.create(SELECT_VALUE(0x583560_b, 0x6A78C0_b), &r_update_front_end_dvar_options_stub); - // use "saved" flags for "r_normalMap" - utils::hook::set(SELECT_VALUE(0x1404CF5CA, 0x1405D460E), game::DVAR_FLAG_SAVED); - - // use "saved" flags for "r_specularMap" - utils::hook::set(SELECT_VALUE(0x1404CF5F5, 0x1405D4639), game::DVAR_FLAG_SAVED); - - // use "saved" flags for "r_specOccMap" - utils::hook::set(SELECT_VALUE(0x1404CF620, 0x1405D4664), game::DVAR_FLAG_SAVED); + // use "saved" flags + dvars::override::register_enum("r_normalMap", game::DVAR_FLAG_SAVED); + dvars::override::register_enum("r_specularMap", game::DVAR_FLAG_SAVED); + dvars::override::register_enum("r_specOccMap", game::DVAR_FLAG_SAVED); } }; } -//REGISTER_COMPONENT(renderer::component) \ No newline at end of file +REGISTER_COMPONENT(renderer::component) diff --git a/src/client/component/slowmotion.cpp b/src/client/component/slowmotion.cpp index 486230d9..f7ed223a 100644 --- a/src/client/component/slowmotion.cpp +++ b/src/client/component/slowmotion.cpp @@ -45,9 +45,9 @@ namespace slowmotion return; } - utils::hook::jump(0x140365480, scr_cmd_set_slow_motion); + utils::hook::jump(0x43D2E0_b, scr_cmd_set_slow_motion); } }; } -//REGISTER_COMPONENT(slowmotion::component) +REGISTER_COMPONENT(slowmotion::component) diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 37e285ed..517feb2d 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -71,7 +71,7 @@ namespace game WEAK symbol Dvar_SetCommand{0x41BAD0, 0x1857D0}; WEAK symbol Dvar_FindVar{0x41A600, 0x183EB0}; - WEAK symbol Dvar_ClearModified{0x0, 0x0}; + WEAK symbol Dvar_ClearModified{0x41A4F0, 0x183D50}; WEAK symbol Dvar_GetCombinedString{0x3A7D60, 0x4EA020}; WEAK symbol Dvar_ValueToString{0x41CE00, 0x187000}; WEAK symbol Dvar_Reset{0x41B5F0, 0x185390}; @@ -135,7 +135,7 @@ namespace game WEAK symbol R_TextWidth{0x55C7A0, 0x67F8F0}; WEAK symbol R_GetFontHeight{0x55C5C0, 0x67F710}; WEAK symbol R_GetSomething{0x55BB90, 0x67ECE0}; - WEAK symbol R_SyncRenderThread{0x0, 0x0}; + WEAK symbol R_SyncRenderThread{0x582F30, 0x6A78C0}; WEAK symbol scr_VmPub{0xC3F4E20, 0xB7AE3C0}; WEAK symbol scr_function_stack{0xC4015C0, 0xB7B8940}; - WEAK symbol gfxDrawMethod{0x0, 0x0}; + WEAK symbol gfxDrawMethod{0xF7530B0, 0xE9213F0}; WEAK symbol dvarCount{0xC90E550, 0x2999C34}; WEAK symbol dvarPool{0xC90E560, 0x344DF20};