[Dvar]: Improve patch (#735)

This commit is contained in:
Edo 2023-01-27 19:07:17 +00:00 committed by GitHub
parent 024440a55e
commit 3444e0fa8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 14 deletions

View File

@ -144,11 +144,6 @@ namespace Components
Network::SendCommand(master, "heartbeat", "IW4");
}
Game::dvar_t* Dedicated::Dvar_RegisterSVNetworkFps(const char* dvarName, int, int min, int, int, const char* description)
{
return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::DVAR_NONE, description);
}
Dedicated::Dedicated()
{
COMLogFilter = Dvar::Register<bool>("com_logFilter", true,
@ -200,9 +195,6 @@ namespace Components
// isHost script call return 0
Utils::Hook::Set<DWORD>(0x5DEC04, 0);
// Manually register sv_network_fps
Utils::Hook(0x4D3C7B, Dvar_RegisterSVNetworkFps, HOOK_CALL).install()->quick();
// r_loadForRenderer default to 0
Utils::Hook::Set<BYTE>(0x519DDF, 0);

View File

@ -26,7 +26,5 @@ namespace Components
static void TransmitGuids();
static void TimeWrapStub(Game::errorParm_t code, const char* message);
static Game::dvar_t* Dvar_RegisterSVNetworkFps(const char* dvarName, int value, int min, int max, int flags, const char* description);
};
}

View File

@ -203,7 +203,7 @@ namespace Components
return Game::Dvar_RegisterFloat(dvarName, value, min, max, flag, description);
}
Game::dvar_t* Dvar::Dvar_RegisterName(const char* name, const char* /*default*/, std::uint16_t flags, const char* description)
const Game::dvar_t* Dvar::Dvar_RegisterName(const char* dvarName, const char* /*value*/, std::uint16_t flags, const char* description)
{
// Name watcher
if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled())
@ -237,16 +237,21 @@ namespace Components
{
const char* steamName = Steam::Proxy::SteamFriends->GetPersonaName();
if (steamName && *steamName != '\0')
if (steamName && *steamName)
{
username = steamName;
}
}
Name = Register<const char*>(name, username.data(), flags | Game::DVAR_ARCHIVE, description);
Name = Register<const char*>(dvarName, username.data(), flags | Game::DVAR_ARCHIVE, description);
return Name.get<Game::dvar_t*>();
}
const Game::dvar_t* Dvar::Dvar_RegisterSVNetworkFps(const char* dvarName, int /*value*/, int min, int /*max*/, std::uint16_t /*flags*/, const char* description)
{
return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::DVAR_NONE, description);
}
void Dvar::SetFromStringByNameSafeExternal(const char* dvarName, const char* string)
{
static std::array<const char*, 8> exceptions =
@ -409,6 +414,9 @@ namespace Components
// Hook dvar 'name' registration
Utils::Hook(0x40531C, Dvar_RegisterName, HOOK_CALL).install()->quick();
// Hook dvar 'sv_network_fps' registration
Utils::Hook(0x4D3C7B, Dvar_RegisterSVNetworkFps, HOOK_CALL).install()->quick();
// un-cheat safeArea_* and add archive flags
Utils::Hook::Xor<std::uint32_t>(0x42E3F5, Game::DVAR_ROM | Game::DVAR_ARCHIVE); //safeArea_adjusted_horizontal
Utils::Hook::Xor<std::uint32_t>(0x42E423, Game::DVAR_ROM | Game::DVAR_ARCHIVE); //safeArea_adjusted_vertical

View File

@ -40,7 +40,8 @@ namespace Components
private:
static Var Name;
static Game::dvar_t* Dvar_RegisterName(const char* name, const char* defaultVal, std::uint16_t flags, const char* description);
static const Game::dvar_t* Dvar_RegisterName(const char* dvarName, const char* value, std::uint16_t flags, const char* description);
static const Game::dvar_t* Dvar_RegisterSVNetworkFps(const char* dvarName, int value, int min, int max, std::uint16_t flags, const char* description);
static void SetFromStringByNameExternal(const char* dvarName, const char* string);
static void SetFromStringByNameSafeExternal(const char* dvarName, const char* string);