[QuickPatch]: Cleanup (#717)

This commit is contained in:
Edo 2023-01-11 19:37:35 +00:00 committed by GitHub
parent 7ace1d24d1
commit fca9c2d234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 44 deletions

View File

@ -36,6 +36,10 @@ namespace Components
// Removed on IW5 MP (unprotected) but present on IW5 SP (protected) - CEG uninitialization / Steam Shutdown
Utils::Hook::Set<std::uint8_t>(0x4F6370, 0xC3);
// Remove 'Steam Start' checking for DRM IPC
Utils::Hook::Nop(0x451145, 5);
Utils::Hook::Set<BYTE>(0x45114C, 0xEB);
// Disable some checks on certain game events
Utils::Hook::Nop(0x43EC96, 9);
Utils::Hook::Nop(0x4675C6, 9);

View File

@ -331,22 +331,22 @@ namespace Components
{
AssertSize(Game::netadr_t, 20);
// maximum size in NET_OutOfBandPrint
Utils::Hook::Set<DWORD>(0x4AEF08, 0x1FFFC);
Utils::Hook::Set<DWORD>(0x4AEFA3, 0x1FFFC);
// Maximum size in NET_OutOfBandPrint
Utils::Hook::Set<std::uint32_t>(0x4AEF08, 0x1FFFC);
Utils::Hook::Set<std::uint32_t>(0x4AEFA3, 0x1FFFC);
// increase max port binding attempts from 10 to 100
Utils::Hook::Set<BYTE>(0x4FD48A, 100);
// Increase max port binding attempts from 10 to 100
Utils::Hook::Set<std::uint8_t>(0x4FD48A, 100);
// increase cl_maxpackets limit
Utils::Hook::Set<BYTE>(0x4050A1, 125);
// Increase cl_maxpackets dvar limit
Utils::Hook::Set<std::uint8_t>(0x4050A1, 125);
// increase snaps
// Increase snaps (disabled for unknown reasons)
//Utils::Hook::Set<BYTE>(0x405357, 40);
// default maxpackets and snaps
Utils::Hook::Set<BYTE>(0x40535B, 30);
Utils::Hook::Set<BYTE>(0x4050A5, 125);
// Set default value of snaps and cl_maxpackets dvar
Utils::Hook::Set<std::uint8_t>(0x40535B, 30);
Utils::Hook::Set<std::uint8_t>(0x4050A5, 125);
// Parse port as short in Net_AddrToString
Utils::Hook::Set<const char*>(0x4698E3, "%u.%u.%u.%u:%hu");
@ -364,11 +364,29 @@ namespace Components
Utils::Hook(0x5AA703, CL_HandleCommandStub, HOOK_JUMP).install()->quick();
// Disable unused OOB packets handlers just to be sure
Utils::Hook::Set<BYTE>(0x5AA5B6, 0xEB); // CL_SteamServerAuth
Utils::Hook::Set<BYTE>(0x5AA69F, 0xEB); // echo
Utils::Hook::Set<BYTE>(0x5AAA82, 0xEB); // SP
Utils::Hook::Set<BYTE>(0x5A9F18, 0xEB); // CL_VoiceConnectionTestPacket
Utils::Hook::Set<BYTE>(0x5A9FF3, 0xEB); // CL_HandleRelayPacket
Utils::Hook::Set<std::uint8_t>(0x5AA5B6, 0xEB); // CL_SteamServerAuth
Utils::Hook::Set<std::uint8_t>(0x5AA69F, 0xEB); // echo
Utils::Hook::Set<std::uint8_t>(0x5AAA82, 0xEB); // SP
Utils::Hook::Set<std::uint8_t>(0x5A9F18, 0xEB); // CL_VoiceConnectionTestPacket
Utils::Hook::Set<std::uint8_t>(0x5A9FF3, 0xEB); // CL_HandleRelayPacket
// Com_GetProtocol
Utils::Hook::Set<std::uint32_t>(0x4FB501, PROTOCOL);
// Set the default, min and max of the protocol dvar
Utils::Hook::Set<std::uint32_t>(0x4D36A9, PROTOCOL);
Utils::Hook::Set<std::uint32_t>(0x4D36AE, PROTOCOL);
Utils::Hook::Set<std::uint32_t>(0x4D36B3, PROTOCOL);
// Internal version is 99, most servers should accept it
Utils::Hook::Set<std::uint32_t>(0x463C61, 208); // getBuildNumberAsInt
// LSP disabled
Utils::Hook::Set<std::uint8_t>(0x435950, 0xC3); // LSP HELLO
Utils::Hook::Set<std::uint8_t>(0x49C220, 0xC3); // We wanted to send a logging packet, but we haven't connected to LSP!
Utils::Hook::Set<std::uint8_t>(0x4BD900, 0xC3); // main LSP response func
Utils::Hook::Set<std::uint8_t>(0x682170, 0xC3); // Telling LSP that we're playing a private match
Utils::Hook::Nop(0x4FD448, 5); // Don't create lsp_socket
OnClientPacket("resolveAddress", [](const Address& address, [[maybe_unused]] const std::string& data)
{

View File

@ -5,6 +5,8 @@
namespace Components
{
Dvar::Var QuickPatch::UIMousePitch;
Dvar::Var QuickPatch::r_customAspectRatio;
void QuickPatch::UnlockStats()
@ -248,7 +250,7 @@ namespace Components
using namespace Game;
static const char* msg = "SND_GetAliasOffset: Could not find sound alias '%s'";
static const DWORD func = 0x4B22D0; // Com_Error
using namespace Game;
__asm
{
@ -270,7 +272,7 @@ namespace Components
push [esi] // alias->aliasName
push msg
push ERR_DROP
call func // Going to longjmp back to safety
call Com_Error // Going to longjmp back to safety
add esp, 0xC
xor eax, eax
@ -318,31 +320,9 @@ namespace Components
// Fix crash as nullptr goes unchecked
Utils::Hook(0x437CAD, QuickPatch::SND_GetAliasOffset_Stub, HOOK_JUMP).install()->quick();
// protocol version (workaround for hacks)
Utils::Hook::Set<int>(0x4FB501, PROTOCOL);
// protocol command
Utils::Hook::Set<int>(0x4D36A9, PROTOCOL);
Utils::Hook::Set<int>(0x4D36AE, PROTOCOL);
Utils::Hook::Set<int>(0x4D36B3, PROTOCOL);
// internal version is 99, most servers should accept it
Utils::Hook::Set<int>(0x463C61, 208);
// remove system pre-init stuff (improper quit, disk full)
Utils::Hook::Set<BYTE>(0x411350, 0xC3);
// remove STEAMSTART checking for DRM IPC
Utils::Hook::Nop(0x451145, 5);
Utils::Hook::Set<BYTE>(0x45114C, 0xEB);
// LSP disabled
Utils::Hook::Set<BYTE>(0x435950, 0xC3); // LSP HELLO
Utils::Hook::Set<BYTE>(0x49C220, 0xC3); // We wanted to send a logging packet, but we haven't connected to LSP!
Utils::Hook::Set<BYTE>(0x4BD900, 0xC3); // main LSP response func
Utils::Hook::Set<BYTE>(0x682170, 0xC3); // Telling LSP that we're playing a private match
Utils::Hook::Nop(0x4FD448, 5); // Don't create lsp_socket
// Don't delete config files if corrupted
Utils::Hook::Set<BYTE>(0x47DCB3, 0xEB);
Utils::Hook::Set<BYTE>(0x4402B6, 0);
@ -519,16 +499,16 @@ namespace Components
}, Scheduler::Pipeline::RENDERER);
// Fix mouse pitch adjustments
Dvar::Register<bool>("ui_mousePitch", false, Game::DVAR_ARCHIVE, "");
UIMousePitch = Dvar::Register<bool>("ui_mousePitch", false, Game::DVAR_ARCHIVE, "");
UIScript::Add("updateui_mousePitch", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
{
if (Dvar::Var("ui_mousePitch").get<bool>())
if (UIMousePitch.get<bool>())
{
Dvar::Var("m_pitch").set(-0.022f);
Game::Dvar_SetFloatByName("m_pitch", -0.022f);
}
else
{
Dvar::Var("m_pitch").set(0.022f);
Game::Dvar_SetFloatByName("m_pitch", 0.022f);
}
});

View File

@ -12,6 +12,8 @@ namespace Components
static void UnlockStats();
private:
static Dvar::Var UIMousePitch;
static Dvar::Var r_customAspectRatio;
static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description);
static void SetAspectRatio_Stub();

View File

@ -29,6 +29,7 @@ namespace Game
Dvar_SetBool_t Dvar_SetBool = Dvar_SetBool_t(0x4A9510);
Dvar_SetBoolByName_t Dvar_SetBoolByName = Dvar_SetBoolByName_t(0x45C4D0);
Dvar_SetFloat_t Dvar_SetFloat = Dvar_SetFloat_t(0x40BB20);
Dvar_SetFloatByName_t Dvar_SetFloatByName = Dvar_SetFloatByName_t(0x466320);
Dvar_SetInt_t Dvar_SetInt = Dvar_SetInt_t(0x421DA0);
const dvar_t** com_developer = reinterpret_cast<const dvar_t**>(0x1AD78E8);

View File

@ -54,6 +54,9 @@ namespace Game
typedef void(*Dvar_SetFloat_t)(const dvar_t* dvar, float value);
extern Dvar_SetFloat_t Dvar_SetFloat;
typedef void(*Dvar_SetFloatByName_t)(const char* dvarName, float value);
extern Dvar_SetFloatByName_t Dvar_SetFloatByName;
typedef void(*Dvar_SetInt_t)(const dvar_t* dvar, int integer);
extern Dvar_SetInt_t Dvar_SetInt;