DOUBLE_RWHEELS fix for trailers (front wheels now get their duplicates too)

This commit is contained in:
Silent 2014-09-09 00:21:34 +02:00
parent 3b817a2fe7
commit 68043fc608
5 changed files with 121 additions and 49 deletions

View file

@ -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<const char*>(0x4925FB, "ESIOTROT");
// BOOOOORING fixed
Patch<BYTE>(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;

View file

@ -1116,6 +1116,68 @@ void __declspec(naked) CacheCRC32()
}
}
static void* const TrailerDoubleRWheelsFix_ReturnFalse = AddressByVersion<void*>(0x4C9333, 0x4C9533, 0x4D3C59);
static void* const TrailerDoubleRWheelsFix_ReturnTrue = AddressByVersion<void*>(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<void*>(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<WORD>(0x4C9290, 0xE281);
Patch<int>(0x4C9292, ~(rwMATRIXTYPEMASK|rwMATRIXINTERNALIDENTITY));
// A fix for DOUBLE_RWHEELS trailers
InjectHook(0x4C9223, TrailerDoubleRWheelsFix, PATCH_JUMP);
InjectHook(0x4C92F4, TrailerDoubleRWheelsFix2, PATCH_JUMP);
// No framedelay
Patch<WORD>(0x53E923, 0x43EB);
Patch<BYTE>(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<WORD>(0x4C9490, 0xE281);
Patch<int>(0x4C9492, ~(rwMATRIXTYPEMASK|rwMATRIXINTERNALIDENTITY));
// A fix for DOUBLE_RWHEELS trailers
InjectHook(0x4C9423, TrailerDoubleRWheelsFix, PATCH_JUMP);
InjectHook(0x4C94F4, TrailerDoubleRWheelsFix2, PATCH_JUMP);
// No framedelay
Patch<WORD>(0x53EDC3, 0x43EB);
Patch<BYTE>(0x53EE3F, 0x10);
@ -2356,7 +2408,7 @@ __forceinline void Patch_SA_11()
Patch<DWORD>(0x4E124C, 0x4DEBC78B);
}
__forceinline void Patch_SA_Steam()
void Patch_SA_Steam()
{
using namespace MemoryVP;
@ -2388,6 +2440,10 @@ __forceinline void Patch_SA_Steam()
Patch<WORD>(0x4D3B9D, 0x6781);
Patch<int>(0x4D3BA0, ~(rwMATRIXTYPEMASK|rwMATRIXINTERNALIDENTITY));
// A fix for DOUBLE_RWHEELS trailers
InjectHook(0x4D3B47, TrailerDoubleRWheelsFix_Steam, PATCH_JUMP);
InjectHook(0x4D3C1A, TrailerDoubleRWheelsFix2_Steam, PATCH_JUMP);
// No framedelay
Patch<WORD>(0x551113, 0x46EB);
Patch<BYTE>(0x551195, 0xC);

View file

@ -15,7 +15,6 @@
#include <utility>
#include <cassert>
#include <tuple>
#include <shlwapi.h>
/*#include <windows.h>
#include <limits>

View file

@ -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

View file

@ -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;