Virtual lobby fovscale

This commit is contained in:
Federico Cecchetto 2022-05-22 19:11:42 +02:00
parent af0474e246
commit 32b65c011c
4 changed files with 58 additions and 38 deletions

View File

@ -10,15 +10,17 @@ namespace virtuallobby
{ {
namespace namespace
{ {
game::dvar_t* virtualLobby_fovscale; game::dvar_t* virtual_lobby_fovscale;
const auto get_fovscale_stub = utils::hook::assemble([](utils::hook::assembler& a) void* get_get_fovscale_stub()
{
return utils::hook::assemble([](utils::hook::assembler& a)
{ {
const auto ret = a.newLabel(); const auto ret = a.newLabel();
const auto original = a.newLabel(); const auto original = a.newLabel();
a.pushad64(); a.pushad64();
a.mov(rax, qword_ptr(0x1425F7210)); // virtualLobbyInFiringRange a.mov(rax, qword_ptr(0x2999CE8_b)); // virtualLobbyInFiringRange
a.cmp(byte_ptr(rax, 0x10), 1); a.cmp(byte_ptr(rax, 0x10), 1);
a.je(original); a.je(original);
a.call_aligned(game::VirtualLobby_Loaded); a.call_aligned(game::VirtualLobby_Loaded);
@ -27,20 +29,22 @@ namespace virtuallobby
// virtuallobby // virtuallobby
a.popad64(); a.popad64();
a.mov(rax, ptr(reinterpret_cast<int64_t>(&virtualLobby_fovscale))); a.mov(rax, ptr(reinterpret_cast<int64_t>(&virtual_lobby_fovscale)));
a.jmp(ret); a.jmp(ret);
// original // original
a.bind(original); a.bind(original);
a.popad64(); a.popad64();
a.mov(rax, qword_ptr(0x1413A8580)); a.mov(rax, qword_ptr(0x14C4EC8_b));
a.jmp(ret); a.jmp(ret);
a.bind(ret); a.bind(ret);
a.mov(rcx, 0x142935000); a.mov(rdi, rax);
a.jmp(0x1400B556A); a.mov(ecx, 8);
a.jmp(0x104545_b);
}); });
} }
}
class component final : public component_interface class component final : public component_interface
{ {
@ -52,13 +56,12 @@ namespace virtuallobby
return; return;
} }
virtualLobby_fovscale = dvars::register_float("virtualLobby_fovScale", 0.7f, 0.0f, 2.0f, virtual_lobby_fovscale = dvars::register_float_hashed("virtualLobby_fovScale", 0.7f, 0.0f, 2.0f,
game::DVAR_FLAG_SAVED, "Field of view scaled for the virtual lobby"); game::DVAR_FLAG_SAVED, "Field of view scaled for the virtual lobby");
utils::hook::nop(0x1400B555C, 14); utils::hook::jump(0x104539_b, get_get_fovscale_stub(), true);
utils::hook::jump(0x1400B555C, get_fovscale_stub, true);
} }
}; };
} }
//REGISTER_COMPONENT(virtuallobby::component) REGISTER_COMPONENT(virtuallobby::component)

View File

@ -11839,7 +11839,7 @@ namespace dvars
} }
game::dvar_t* register_int(const std::string& name, int value, int min, int max, game::dvar_t* register_int(const std::string& name, int value, int min, int max,
game::DvarFlags flags, const std::string& description) unsigned int flags, const std::string& description)
{ {
const auto hash = game::generateHashValue(name.data()); const auto hash = game::generateHashValue(name.data());
@ -11852,7 +11852,7 @@ namespace dvars
} }
game::dvar_t* register_bool(const std::string& name, bool value, game::dvar_t* register_bool(const std::string& name, bool value,
game::DvarFlags flags, const std::string& description) unsigned int flags, const std::string& description)
{ {
const auto hash = game::generateHashValue(name.data()); const auto hash = game::generateHashValue(name.data());
@ -11865,7 +11865,7 @@ namespace dvars
} }
game::dvar_t* register_string(const std::string& name, const char* value, game::dvar_t* register_string(const std::string& name, const char* value,
game::DvarFlags flags, const std::string& description) unsigned int flags, const std::string& description)
{ {
const auto hash = game::generateHashValue(name.data()); const auto hash = game::generateHashValue(name.data());
@ -11878,7 +11878,7 @@ namespace dvars
} }
game::dvar_t* register_float(const std::string& name, float value, float min, game::dvar_t* register_float(const std::string& name, float value, float min,
float max, game::DvarFlags flags, const std::string& description) float max, unsigned int flags, const std::string& description)
{ {
const auto hash = game::generateHashValue(name.data()); const auto hash = game::generateHashValue(name.data());
@ -11890,8 +11890,21 @@ namespace dvars
return game::Dvar_RegisterFloat(hash, "", value, min, max, flags); return game::Dvar_RegisterFloat(hash, "", value, min, max, flags);
} }
game::dvar_t* register_float_hashed(const std::string& name, float value, float min,
float max, unsigned int flags, const std::string& description)
{
const auto hash = game::generateHashValue(name.data());
if (can_add_dvar_to_list(name))
{
dvar_list.push_back({ name, description });
}
return game::Dvar_RegisterFloatHashed(hash, "", value, min, max, flags);
}
game::dvar_t* register_vec4(const std::string& name, float x, float y, float z, game::dvar_t* register_vec4(const std::string& name, float x, float y, float z,
float w, float min, float max, game::DvarFlags flags, const std::string& description) float w, float min, float max, unsigned int flags, const std::string& description)
{ {
const auto hash = game::generateHashValue(name.data()); const auto hash = game::generateHashValue(name.data());

View File

@ -50,13 +50,15 @@ namespace dvars
std::optional<dvar_info> get_dvar_info_from_hash(const int hash); std::optional<dvar_info> get_dvar_info_from_hash(const int hash);
game::dvar_t* register_int(const std::string& name, int value, int min, int max, game::dvar_t* register_int(const std::string& name, int value, int min, int max,
game::DvarFlags flags, const std::string& description); unsigned int flags, const std::string& description);
game::dvar_t* register_bool(const std::string& name, bool value, game::dvar_t* register_bool(const std::string& name, bool value,
game::DvarFlags flags, const std::string& description); unsigned int flags, const std::string& description);
game::dvar_t* register_string(const std::string& name, const char* value, game::dvar_t* register_string(const std::string& name, const char* value,
game::DvarFlags flags, const std::string& description); unsigned int flags, const std::string& description);
game::dvar_t* register_float(const std::string& name, float value, float min, float max, game::dvar_t* register_float(const std::string& name, float value, float min, float max,
game::DvarFlags flags, const std::string& description); unsigned int flags, const std::string& description);
game::dvar_t* register_float_hashed(const std::string& name, float value, float min, float max,
unsigned int flags, const std::string& description);
game::dvar_t* register_vec4(const std::string& name, float x, float y, float z, float w, float min, game::dvar_t* register_vec4(const std::string& name, float x, float y, float z, float w, float min,
float max, game::DvarFlags flags, const std::string& description); float max, unsigned int flags, const std::string& description);
} }

View File

@ -66,6 +66,8 @@ namespace game
unsigned int flags)> Dvar_RegisterInt{0x0, 0x182A10}; unsigned int flags)> Dvar_RegisterInt{0x0, 0x182A10};
WEAK symbol<dvar_t*(int hash, const char* dvarName, float value, float min, WEAK symbol<dvar_t*(int hash, const char* dvarName, float value, float min,
float max, unsigned int flags)> Dvar_RegisterFloat{0x0, 0x1827F0}; float max, unsigned int flags)> Dvar_RegisterFloat{0x0, 0x1827F0};
WEAK symbol<dvar_t*(int hash, const char* dvarName, float value, float min,
float max, unsigned int flags)> Dvar_RegisterFloatHashed{0x0, 0x182900};
WEAK symbol<dvar_t*(int hash, const char* dvarName, const char* value, WEAK symbol<dvar_t*(int hash, const char* dvarName, const char* value,
unsigned int flags)> Dvar_RegisterString{0x0, 0x182BD0}; unsigned int flags)> Dvar_RegisterString{0x0, 0x182BD0};
WEAK symbol<dvar_t*(int dvarName, const char* a2, float x, float y, float z, WEAK symbol<dvar_t*(int dvarName, const char* a2, float x, float y, float z,