Prevent cg_fov/scale from being reset
This commit is contained in:
parent
d80d19d2ee
commit
0b02fab071
@ -5,11 +5,15 @@
|
|||||||
#include "game/dvars.hpp"
|
#include "game/dvars.hpp"
|
||||||
|
|
||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
namespace patches
|
namespace patches
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
utils::hook::detour gscr_set_save_dvar_hook;
|
||||||
|
utils::hook::detour dvar_register_float_hook;
|
||||||
|
|
||||||
void* sub_46148()
|
void* sub_46148()
|
||||||
{
|
{
|
||||||
static uint64_t off_11C52460 = 0xAD0C58_b;
|
static uint64_t off_11C52460 = 0xAD0C58_b;
|
||||||
@ -21,6 +25,30 @@ namespace patches
|
|||||||
component_loader::pre_destroy();
|
component_loader::pre_destroy();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gscr_set_save_dvar_stub()
|
||||||
|
{
|
||||||
|
const auto string = utils::string::to_lower(utils::hook::invoke<const char*>(0x5C7C20_b, 0));
|
||||||
|
if (string == "cg_fov" || string == "cg_fovscale")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gscr_set_save_dvar_hook.invoke<void>();
|
||||||
|
}
|
||||||
|
|
||||||
|
game::dvar_t* dvar_register_float_stub(int hash, const char* dvarName, float value, float min, float max, unsigned int flags)
|
||||||
|
{
|
||||||
|
static const auto cg_fov_hash = game::generateHashValue("cg_fov");
|
||||||
|
static const auto cg_fov_scale_hash = game::generateHashValue("cg_fovscale");
|
||||||
|
|
||||||
|
if (hash == cg_fov_hash || hash == cg_fov_scale_hash)
|
||||||
|
{
|
||||||
|
flags |= game::DvarFlags::DVAR_FLAG_SAVED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dvar_register_float_hook.invoke<game::dvar_t*>(hash, dvarName, value, min, max, flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class component final : public component_interface
|
class component final : public component_interface
|
||||||
@ -40,6 +68,13 @@ namespace patches
|
|||||||
|
|
||||||
// Disable battle net popup
|
// Disable battle net popup
|
||||||
utils::hook::nop(0x5F4496_b, 5);
|
utils::hook::nop(0x5F4496_b, 5);
|
||||||
|
|
||||||
|
// Prevent game from overriding cg_fov and cg_fovscale values
|
||||||
|
gscr_set_save_dvar_hook.create(0x504C60_b, &gscr_set_save_dvar_stub);
|
||||||
|
// Make cg_fov and cg_fovscale saved dvars
|
||||||
|
dvar_register_float_hook.create(game::Dvar_RegisterFloat.get(), dvar_register_float_stub);
|
||||||
|
// Don't make the game reset cg_fov and cg_fovscale along with other dvars
|
||||||
|
utils::hook::nop(0x4C8A08_b, 5);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user