Virtual lobby fovscale

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

View File

@ -10,36 +10,40 @@ namespace virtuallobby
{
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()
{
const auto ret = a.newLabel();
const auto original = a.newLabel();
return utils::hook::assemble([](utils::hook::assembler& a)
{
const auto ret = a.newLabel();
const auto original = a.newLabel();
a.pushad64();
a.mov(rax, qword_ptr(0x1425F7210)); // virtualLobbyInFiringRange
a.cmp(byte_ptr(rax, 0x10), 1);
a.je(original);
a.call_aligned(game::VirtualLobby_Loaded);
a.cmp(al, 0);
a.je(original);
a.pushad64();
a.mov(rax, qword_ptr(0x2999CE8_b)); // virtualLobbyInFiringRange
a.cmp(byte_ptr(rax, 0x10), 1);
a.je(original);
a.call_aligned(game::VirtualLobby_Loaded);
a.cmp(al, 0);
a.je(original);
// virtuallobby
a.popad64();
a.mov(rax, ptr(reinterpret_cast<int64_t>(&virtualLobby_fovscale)));
a.jmp(ret);
// virtuallobby
a.popad64();
a.mov(rax, ptr(reinterpret_cast<int64_t>(&virtual_lobby_fovscale)));
a.jmp(ret);
// original
a.bind(original);
a.popad64();
a.mov(rax, qword_ptr(0x1413A8580));
a.jmp(ret);
// original
a.bind(original);
a.popad64();
a.mov(rax, qword_ptr(0x14C4EC8_b));
a.jmp(ret);
a.bind(ret);
a.mov(rcx, 0x142935000);
a.jmp(0x1400B556A);
});
a.bind(ret);
a.mov(rdi, rax);
a.mov(ecx, 8);
a.jmp(0x104545_b);
});
}
}
class component final : public component_interface
@ -52,13 +56,12 @@ namespace virtuallobby
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");
utils::hook::nop(0x1400B555C, 14);
utils::hook::jump(0x1400B555C, get_fovscale_stub, true);
utils::hook::jump(0x104539_b, get_get_fovscale_stub(), true);
}
};
}
//REGISTER_COMPONENT(virtuallobby::component)
REGISTER_COMPONENT(virtuallobby::component)