From 68043fc6086a777d81a464f5d3fe186a0609a108 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 9 Sep 2014 00:21:34 +0200 Subject: [PATCH] DOUBLE_RWHEELS fix for trailers (front wheels now get their duplicates too) --- IIIFix/SilentPatchIII.cpp | 13 ++-- SAFix/SilentPatchSA.cpp | 128 +++++++++++++++++++++++++++----------- SAFix/StdAfxSA.h | 1 - SAFix/VehicleSA.h | 16 +++++ VCFix/SilentPatchVC.cpp | 12 ++-- 5 files changed, 121 insertions(+), 49 deletions(-) diff --git a/IIIFix/SilentPatchIII.cpp b/IIIFix/SilentPatchIII.cpp index bc3d49e..1fd090e 100644 --- a/IIIFix/SilentPatchIII.cpp +++ b/IIIFix/SilentPatchIII.cpp @@ -7,8 +7,8 @@ struct RsGlobalType { const char* AppName; unsigned int unkWidth, unkHeight; - unsigned int MaximumWidth; - unsigned int MaximumHeight; + signed int MaximumWidth; + signed int MaximumHeight; unsigned int frameLimit; BOOL quit; void* ps; @@ -154,7 +154,7 @@ void __declspec(naked) SubtitlesShadowFix() } } -__forceinline void Patch_III_10() +void Patch_III_10() { using namespace MemoryVP; @@ -259,9 +259,12 @@ __forceinline void Patch_III_10() // Armour cheat as TORTOISE - like in 1.1 and Steam Patch(0x4925FB, "ESIOTROT"); + + // BOOOOORING fixed + Patch(0x4925D7, 10); } -__forceinline void Patch_III_11() +void Patch_III_11() { using namespace MemoryVP; @@ -365,7 +368,7 @@ __forceinline void Patch_III_11() InjectHook(0x57ED45, AlteredPrintString<0x57ED3E,0x57ED1D>); } -__forceinline void Patch_III_Steam() +void Patch_III_Steam() { using namespace MemoryVP; diff --git a/SAFix/SilentPatchSA.cpp b/SAFix/SilentPatchSA.cpp index a2ca8f6..4c64b2e 100644 --- a/SAFix/SilentPatchSA.cpp +++ b/SAFix/SilentPatchSA.cpp @@ -1116,6 +1116,68 @@ void __declspec(naked) CacheCRC32() } } +static void* const TrailerDoubleRWheelsFix_ReturnFalse = AddressByVersion(0x4C9333, 0x4C9533, 0x4D3C59); +static void* const TrailerDoubleRWheelsFix_ReturnTrue = AddressByVersion(0x4C9235, 0x4C9435, 0x4D3B59); +void __declspec(naked) TrailerDoubleRWheelsFix() +{ + _asm + { + cmp [edi]CVehicleModelInfo.m_dwType, VEHICLE_TRAILER + je TrailerDoubleRWheelsFix_DoWheels + cmp eax, 2 + je TrailerDoubleRWheelsFix_False + cmp eax, 5 + je TrailerDoubleRWheelsFix_False + +TrailerDoubleRWheelsFix_DoWheels: + jmp TrailerDoubleRWheelsFix_ReturnTrue + +TrailerDoubleRWheelsFix_False: + jmp TrailerDoubleRWheelsFix_ReturnFalse + } +} + +void __declspec(naked) TrailerDoubleRWheelsFix2() +{ + _asm + { + add esp, 18h + mov eax, [ebx] + mov eax, [esi+eax+4] + jmp TrailerDoubleRWheelsFix + } +} + +void __declspec(naked) TrailerDoubleRWheelsFix_Steam() +{ + _asm + { + cmp [esi]CVehicleModelInfo.m_dwType, VEHICLE_TRAILER + je TrailerDoubleRWheelsFix_DoWheels + cmp eax, 2 + je TrailerDoubleRWheelsFix_False + cmp eax, 5 + je TrailerDoubleRWheelsFix_False + +TrailerDoubleRWheelsFix_DoWheels: + jmp TrailerDoubleRWheelsFix_ReturnTrue + +TrailerDoubleRWheelsFix_False: + jmp TrailerDoubleRWheelsFix_ReturnFalse + } +} + +void __declspec(naked) TrailerDoubleRWheelsFix2_Steam() +{ + _asm + { + add esp, 18h + mov eax, [ebp] + mov eax, [ebx+eax+4] + jmp TrailerDoubleRWheelsFix_Steam + } +} + static void* LoadFLAC_JumpBack = AddressByVersion(0x4F3743, *(BYTE*)0x4F3A50 == 0x6A ? 0x4F3BA3 : 0x5B6B81, 0x4FFC3F); void __declspec(naked) LoadFLAC() { @@ -1409,17 +1471,11 @@ BOOL InjectDelayedPatches_10() GetModuleFileNameW(hDLLModule, wcModulePath, MAX_PATH); - wchar_t* pSlash = wcsrchr(wcModulePath, '\\'); - if ( pSlash ) - { - *pSlash = '\0'; - PathAppendW(wcModulePath, L"SilentPatchSA.ini"); - } - else - { - // Should never happen - if it does, something's fucking up - return TRUE; - } + // ASI -> INI + size_t nLen = wcslen(wcModulePath); + wcModulePath[nLen-1] = L'i'; + wcModulePath[nLen-2] = L'n'; + wcModulePath[nLen-3] = L'i'; bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr; @@ -1587,17 +1643,11 @@ BOOL InjectDelayedPatches_11() GetModuleFileNameW(hDLLModule, wcModulePath, MAX_PATH); - wchar_t* pSlash = wcsrchr(wcModulePath, '\\'); - if ( pSlash ) - { - *pSlash = '\0'; - PathAppendW(wcModulePath, L"SilentPatchSA.ini"); - } - else - { - // Should never happen - if it does, something's fucking up - return TRUE; - } + // ASI -> INI + size_t nLen = wcslen(wcModulePath); + wcModulePath[nLen-1] = L'i'; + wcModulePath[nLen-2] = L'n'; + wcModulePath[nLen-3] = L'i'; bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr; @@ -1773,17 +1823,11 @@ BOOL InjectDelayedPatches_Steam() GetModuleFileNameW(hDLLModule, wcModulePath, MAX_PATH); - wchar_t* pSlash = wcsrchr(wcModulePath, '\\'); - if ( pSlash ) - { - *pSlash = '\0'; - PathAppendW(wcModulePath, L"SilentPatchSA.ini"); - } - else - { - // Should never happen - if it does, something's fucking up - return TRUE; - } + // ASI -> INI + size_t nLen = wcslen(wcModulePath); + wcModulePath[nLen-1] = L'i'; + wcModulePath[nLen-2] = L'n'; + wcModulePath[nLen-3] = L'i'; bool bHasImVehFt = GetModuleHandle("ImVehFt.asi") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr; @@ -1935,7 +1979,7 @@ BOOL InjectDelayedPatches_Steam() return TRUE; } -__forceinline void Patch_SA_10() +void Patch_SA_10() { using namespace MemoryVP; @@ -1983,6 +2027,10 @@ __forceinline void Patch_SA_10() Patch(0x4C9290, 0xE281); Patch(0x4C9292, ~(rwMATRIXTYPEMASK|rwMATRIXINTERNALIDENTITY)); + // A fix for DOUBLE_RWHEELS trailers + InjectHook(0x4C9223, TrailerDoubleRWheelsFix, PATCH_JUMP); + InjectHook(0x4C92F4, TrailerDoubleRWheelsFix2, PATCH_JUMP); + // No framedelay Patch(0x53E923, 0x43EB); Patch(0x53E99F, 0x10); @@ -2157,7 +2205,7 @@ __forceinline void Patch_SA_10() strncpy(pScannerNames + (8*134), "????", 8); } -__forceinline void Patch_SA_11() +void Patch_SA_11() { using namespace MemoryVP; @@ -2190,6 +2238,10 @@ __forceinline void Patch_SA_11() Patch(0x4C9490, 0xE281); Patch(0x4C9492, ~(rwMATRIXTYPEMASK|rwMATRIXINTERNALIDENTITY)); + // A fix for DOUBLE_RWHEELS trailers + InjectHook(0x4C9423, TrailerDoubleRWheelsFix, PATCH_JUMP); + InjectHook(0x4C94F4, TrailerDoubleRWheelsFix2, PATCH_JUMP); + // No framedelay Patch(0x53EDC3, 0x43EB); Patch(0x53EE3F, 0x10); @@ -2356,7 +2408,7 @@ __forceinline void Patch_SA_11() Patch(0x4E124C, 0x4DEBC78B); } -__forceinline void Patch_SA_Steam() +void Patch_SA_Steam() { using namespace MemoryVP; @@ -2388,6 +2440,10 @@ __forceinline void Patch_SA_Steam() Patch(0x4D3B9D, 0x6781); Patch(0x4D3BA0, ~(rwMATRIXTYPEMASK|rwMATRIXINTERNALIDENTITY)); + // A fix for DOUBLE_RWHEELS trailers + InjectHook(0x4D3B47, TrailerDoubleRWheelsFix_Steam, PATCH_JUMP); + InjectHook(0x4D3C1A, TrailerDoubleRWheelsFix2_Steam, PATCH_JUMP); + // No framedelay Patch(0x551113, 0x46EB); Patch(0x551195, 0xC); diff --git a/SAFix/StdAfxSA.h b/SAFix/StdAfxSA.h index e21c2f5..4a42ebe 100644 --- a/SAFix/StdAfxSA.h +++ b/SAFix/StdAfxSA.h @@ -15,7 +15,6 @@ #include #include #include -#include /*#include #include diff --git a/SAFix/VehicleSA.h b/SAFix/VehicleSA.h index 6a59116..703f32d 100644 --- a/SAFix/VehicleSA.h +++ b/SAFix/VehicleSA.h @@ -4,6 +4,22 @@ #include "GeneralSA.h" #include "ModelInfoSA.h" +enum eVehicleType +{ + VEHICLE_AUTOMOBILE, + VEHICLE_MTRUCK, + VEHICLE_QUAD, + VEHICLE_HELI, + VEHICLE_PLANE, + VEHICLE_BOAT, + VEHICLE_TRAIN, + VEHICLE_FHELI, + VEHICLE_FPLANE, + VEHICLE_BIKE, + VEHICLE_BMX, + VEHICLE_TRAILER +}; + struct CVehicleFlags { //0x428 diff --git a/VCFix/SilentPatchVC.cpp b/VCFix/SilentPatchVC.cpp index 5fcbd67..9b9f988 100644 --- a/VCFix/SilentPatchVC.cpp +++ b/VCFix/SilentPatchVC.cpp @@ -6,8 +6,8 @@ struct RsGlobalType { const char* AppName; unsigned int unkWidth, unkHeight; - unsigned int MaximumWidth; - unsigned int MaximumHeight; + signed int MaximumWidth; + signed int MaximumHeight; unsigned int frameLimit; BOOL quit; void* ps; @@ -23,8 +23,6 @@ static const void* RosieAudioFix_JumpBack; void (__stdcall *AudioResetTimers)(unsigned int); static void (*PrintString)(float,float,const wchar_t*); -static bool* bWantsToDrawHud; -static bool* bCamCheck; static RsGlobalType* RsGlobal; static const float* ResolutionWidthMult; static const float* ResolutionHeightMult; @@ -99,7 +97,7 @@ void __declspec(naked) SubtitlesShadowFix() } -__forceinline void Patch_VC_10() +void Patch_VC_10() { using namespace MemoryVP; @@ -159,7 +157,7 @@ __forceinline void Patch_VC_10() InjectHook(0x54474D, AlteredPrintStringMinus<0x544727,0x544727>); } -__forceinline void Patch_VC_11() +void Patch_VC_11() { using namespace MemoryVP; @@ -219,7 +217,7 @@ __forceinline void Patch_VC_11() InjectHook(0x54476D, AlteredPrintStringMinus<0x544747,0x544747>); } -__forceinline void Patch_VC_Steam() +void Patch_VC_Steam() { using namespace MemoryVP;