This commit is contained in:
Federico Cecchetto 2022-02-26 23:53:08 +01:00
commit 8e85d100fa
4 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,63 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include <utils/hook.hpp>
namespace virtuallobby
{
namespace
{
game::dvar_t* virtualLobby_fovscale;
const auto get_fovscale_stub = 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);
// virtuallobby
a.popad64();
a.mov(rax, ptr(reinterpret_cast<int64_t>(&virtualLobby_fovscale)));
a.jmp(ret);
// original
a.bind(original);
a.popad64();
a.mov(rax, qword_ptr(0x1413A8580));
a.jmp(ret);
a.bind(ret);
a.mov(rcx, 0x142935000);
a.jmp(0x1400B556A);
});
}
class component final : public component_interface
{
public:
void post_unpack() override
{
if (!game::environment::is_mp())
{
return;
}
virtualLobby_fovscale = dvars::register_float("virtualLobby_fovScale", 0.7f, 0.0f, 2.0f, game::DVAR_FLAG_SAVED);
utils::hook::nop(0x1400B555C, 14);
utils::hook::jump(0x1400B555C, get_fovscale_stub, true);
}
};
}
REGISTER_COMPONENT(virtuallobby::component)

View File

@ -199,6 +199,7 @@ namespace dvars
"cg_legacyCrashHandling", "cg_legacyCrashHandling",
"cl_maxpackets", "cl_maxpackets",
"cl_maxPing", "cl_maxPing",
"cl_connectTimeout",
"com_introPlayed", "com_introPlayed",
"com_isNotice", "com_isNotice",
"com_maxclients", "com_maxclients",
@ -332,6 +333,7 @@ namespace dvars
"sv_mapRotation", "sv_mapRotation",
"sv_mapRotationCurrent", "sv_mapRotationCurrent",
"cl_maxpackets", "cl_maxpackets",
"cl_timeout",
"sv_maxclients", "sv_maxclients",
"sv_maxPhysExplosionSpheres", "sv_maxPhysExplosionSpheres",
"sv_maxPing", "sv_maxPing",
@ -389,6 +391,7 @@ namespace dvars
"sv_mapRotationCurrent", "sv_mapRotationCurrent",
"sv_autoPriority", "sv_autoPriority",
//"xpartygo", //"xpartygo",
"ui_mousePitch",
"svwp", "svwp",
"syncTimeTimeout", "syncTimeTimeout",
"sys_configSum", "sys_configSum",
@ -469,6 +472,7 @@ namespace dvars
"custom_scr_game_onlyheadshots", "custom_scr_game_onlyheadshots",
"custom_scr_game_perks", "custom_scr_game_perks",
"custom_scr_game_spectatetype", "custom_scr_game_spectatetype",
"scr_game_spectatetype",
"custom_scr_hardcore", "custom_scr_hardcore",
"custom_scr_num_bots", "custom_scr_num_bots",
"custom_scr_num_bots_enemy", "custom_scr_num_bots_enemy",
@ -496,8 +500,14 @@ namespace dvars
"custom_scr_team_fftype", "custom_scr_team_fftype",
"custom_scr_team_teamkillspawndelay", "custom_scr_team_teamkillspawndelay",
"custom_scr_vehicles_enabled", "custom_scr_vehicles_enabled",
//"name",
"custom_timelimit", "custom_timelimit",
"safeArea_adjusted_horizontal",
"safeArea_adjusted_vertical",
"safeArea_horizontal",
"safeArea_vertical",
"elite_clan_active",
"codPointStore_enabled",
"sensitivity",
"map" "map"
}; };

View File

@ -23,6 +23,11 @@ namespace game
return sv_cmd_args->argv[sv_cmd_args->nesting][index]; return sv_cmd_args->argv[sv_cmd_args->nesting][index];
} }
bool VirtualLobby_Loaded()
{
return !game::environment::is_sp() && *mp::virtualLobby_loaded == 1;
}
namespace environment namespace environment
{ {
launcher::mode mode = launcher::mode::none; launcher::mode mode = launcher::mode::none;

View File

@ -125,6 +125,8 @@ namespace game
WEAK symbol<void(unsigned int id, scr_string_t stringValue, unsigned int paramcount)> Scr_NotifyId{0, 0x1405C8240}; WEAK symbol<void(unsigned int id, scr_string_t stringValue, unsigned int paramcount)> Scr_NotifyId{0, 0x1405C8240};
WEAK symbol<const char* (scr_string_t stringValue)> SL_ConvertToString{0x14036D420, 0x1405BFBB0}; WEAK symbol<const char* (scr_string_t stringValue)> SL_ConvertToString{0x14036D420, 0x1405BFBB0};
WEAK symbol<scr_string_t(const char* str)> SL_FindString{ 0x140314AF0, 0x14043B470 }; // H1(1.4)
WEAK symbol<scr_string_t(const char* str, unsigned int user)> SL_GetString{0x14036D9A0, 0x1405C0170}; WEAK symbol<scr_string_t(const char* str, unsigned int user)> SL_GetString{0x14036D9A0, 0x1405C0170};
WEAK symbol<void(netadr_s* from)> SV_DirectConnect{0, 0x140480860}; WEAK symbol<void(netadr_s* from)> SV_DirectConnect{0, 0x140480860};
@ -204,6 +206,8 @@ namespace game
WEAK symbol<gentity_s> g_entities{0, 0x14621E530}; WEAK symbol<gentity_s> g_entities{0, 0x14621E530};
WEAK symbol<client_t> svs_clients{0, 0x14B204A10}; WEAK symbol<client_t> svs_clients{0, 0x14B204A10};
WEAK symbol<int> gameTime{0, 0x14621BDBC}; WEAK symbol<int> gameTime{0, 0x14621BDBC};
WEAK symbol<bool> virtualLobby_loaded{ 0, 0x142D077FD };
} }
namespace sp namespace sp