Compare commits

..

25 commits

Author SHA1 Message Date
Echo J.
a3b3e4dbd8
Merge dc04c3ca39 into d191bdf3b4 2024-11-20 23:43:17 +02:00
Echo J
dc04c3ca39 SilentPatchVC: Add GCC-style inline assembly statements
This also includes a small wrapper to call a C++ function from GCC-style inline ASM

These statements almost work on llvm-mingw too (but there's some stubborn call instructions)
2024-11-20 23:42:38 +02:00
Echo J
8362b0a1d0 SilentPatchIII: Add GCC-style inline assembly statements
These almost work on llvm-mingw too (but there's some stubborn call instructions)
2024-11-20 23:41:41 +02:00
Echo J
184f3c60f9 SilentPatchIII: Add a missing functional header include
MinGW GCC doesn't implicitly include it either
2024-11-20 23:39:29 +02:00
Echo J
74e16c5f04 SilentPatch: Add missing cmath header include
It's required for the modf() function (and it isn't implicitly
included on MinGW GCC)
2024-11-20 23:39:29 +02:00
Echo J
44b9f507cf SilentPatch: Move a header include in SVF
This makes sure the fixed-width integer types are included in SVF.h
2024-11-20 23:39:29 +02:00
Echo J
de2536a984 SilentPatch: Define a replacement for _stricmp() on non-MSVC
MinGW GCC doesn't have this MSVC-specific function
2024-11-20 23:39:29 +02:00
Echo J
3120120ea4 SilentPatch: Move RwEngineInstance definition to headers
MinGW GCC can't locate it in some files otherwise
2024-11-20 23:39:29 +02:00
Echo J
83ac060e53 SilentPatch: Simplify RwIm2DRenderLine function pointer declaration
MinGW GCC doesn't seem to unwind the layers of the macro define
properly (which causes it to not find the declaration type)
2024-11-20 23:39:29 +02:00
Echo J
d5c3398606 SilentPatch: Don't define certain Rw* functions if not needed
Redefining them can cause strange compile errors with MinGW GCC
2024-11-20 23:39:29 +02:00
Echo J
8093c055e6 DDraw: Cast the memcpy() source argument
This works around the MinGW GCC type strictness
2024-11-20 23:39:29 +02:00
Echo J
b80ee9d8ca DDraw: Use a pragma for DirectDrawCreateEx export on MSVC
The .def file is either going to have issues on MSVC or MinGW GCC
(so replace it with a pragma on MSVC)
2024-11-20 23:39:29 +02:00
Echo J
3106c51455 SilentPatchIII/VC/SA: Mark some function pointers as inline
MinGW GCC's linker can't find them otherwise
2024-11-20 23:39:29 +02:00
Echo J
277515a56b SilentPatchIII/VC: Remove extern from ppUserFilesDir variable definitions
This fixes compile warnings with MinGW GCC
2024-11-20 23:39:29 +02:00
Echo J
9cbc846dbd SilentPatchIII/VC/SA: Add GCC/Clang-compatible safebuffers equivalent
And switch to a common define for this attribute (this fixes
compile warnings on MinGW GCC)
2024-11-20 23:39:29 +02:00
Echo J
2bd71990de Use reinterpret_cast for function pointer casts
MSVC (wrongly) allows those casts to succeed with static_cast:
https://stackoverflow.com/questions/74002657/why-cant-i-static-cast-a-void-to-a-pointer-to-function
(so adjust those casts for better compiler compatibility including MinGW GCC)
2024-11-20 23:39:29 +02:00
Echo J
4cccda9da6 Set Windows defines earlier
This avoids compile warnings on MinGW GCC (because standard C++
headers eventually import the Windows stuff)
2024-11-20 23:39:29 +02:00
Echo J
a360f693d3 Use lowercase names for Windows headers
This fixes missing header issues on a case-sensitive filesystem
with MinGW GCC
2024-11-20 23:39:29 +02:00
Echo J
4c78e857f0 Remove unused dllmain.cpp file
It seems to be used in the early days of SilentPatch (but it's
no longer included since the III/VC/SA code split and serves no purpose)
2024-11-20 23:39:29 +02:00
Echo J
d191bdf3b4 SilentPatchSA: Fixup the MSVC inline assembly statements (part 3)
Also clean them up in general
2024-11-18 19:33:06 +01:00
Echo J
5738eb5d75 SilentPatchSA: Fixup the MSVC inline assembly statements (part 2)
Also clean them up in general
2024-11-18 19:33:06 +01:00
Echo J
94f967245b SilentPatchSA: Fixup the MSVC inline assembly statements (part 1)
Also clean them up in general
2024-11-18 19:33:06 +01:00
Echo J
5d90ed55d7 SilentPatchVC: Fixup the MSVC inline assembly statements
Also clean them up in general
2024-11-18 19:33:06 +01:00
Echo J
7819f30c75 SilentPatchIII: Fixup the MSVC inline assembly statements
Some of them use the deference operator incorrectly (also clean them
up in general)
2024-11-18 19:33:06 +01:00
Silent
73600974c5
SA: Fix 1.0 EU executable crashes when losing police pursuit and triggering the replay
US and EU no-DVD executables were decrypted slightly differently, and the patches
did not account for that previously.

Fixes #76
2024-11-18 18:32:09 +01:00
5 changed files with 352 additions and 337 deletions

View file

@ -194,16 +194,16 @@ void ResetMousePos()
orgConstructRenderList();
}
void __declspec(naked) M16StatsFix()
__declspec(naked) void M16StatsFix()
{
#ifdef _MSC_VER
_asm
{
add eax, 34h
add ebx, 34h
mov ecx, [InstantHitsFiredByPlayer]
inc [ecx]
retn
add eax, 0x34
add ebx, 0x34
mov ecx, InstantHitsFiredByPlayer
inc dword ptr [ecx]
ret
}
#else
__asm__ volatile
@ -219,25 +219,25 @@ void __declspec(naked) M16StatsFix()
}
static const float fMinusOne = -1.0f;
void __declspec(naked) HeadlightsFix()
__declspec(naked) void HeadlightsFix()
{
#ifdef _MSC_VER
_asm
{
fld [esp+708h-690h]
fld dword ptr [esp+0x708-0x690]
fcomp fMinusOne
fnstsw ax
and ah, 5
cmp ah, 1
jnz HeadlightsFix_DontLimit
fld fMinusOne
fstp [esp+708h-690h]
fstp dword ptr [esp+0x708-0x690]
HeadlightsFix_DontLimit:
fld [esp+708h-690h]
fld dword ptr [esp+0x708-0x690]
fabs
fld st
jmp [HeadlightsFix_JumpBack]
jmp HeadlightsFix_JumpBack
}
#else
__asm__ volatile
@ -346,15 +346,15 @@ float FixedRefValue()
return 1.0f;
}
void __declspec(naked) SubtitlesShadowFix()
__declspec(naked) void SubtitlesShadowFix()
{
#ifdef _MSC_VER
_asm
{
push eax
call Recalculate
fadd [esp+50h+8]
fadd [fShadowYSize]
fadd dword ptr [esp+0x50+8]
fadd fShadowYSize
jmp SubtitlesShadowFix_JumpBack
}
#else
@ -372,19 +372,19 @@ void __declspec(naked) SubtitlesShadowFix()
#endif
}
void __declspec(naked) III_SensResetFix()
__declspec(naked) void III_SensResetFix()
{
#ifdef _MSC_VER
_asm
{
mov ecx, 3A76h
mov ecx, 0x3A76
mov edi, ebp
fld dword ptr [ebp+194h]
fld dword ptr [ebp+198h]
fld dword ptr [ebp+0x194]
fld dword ptr [ebp+0x198]
rep stosd
fstp dword ptr [ebp+198h]
fstp dword ptr [ebp+194h]
retn
fstp dword ptr [ebp+0x198]
fstp dword ptr [ebp+0x194]
ret
}
#else
__asm__ volatile
@ -403,12 +403,12 @@ void __declspec(naked) III_SensResetFix()
static void* RadarBoundsCheckCoordBlip_JumpBack = AddressByVersion<void*>(0x4A55B8, 0x4A56A8, 0x4A5638);
static void* RadarBoundsCheckCoordBlip_Count = AddressByVersion<void*>(0x4A55AF, 0x4A569F, 0x4A562F);
void __declspec(naked) RadarBoundsCheckCoordBlip()
__declspec(naked) void RadarBoundsCheckCoordBlip()
{
#ifdef _MSC_VER
_asm
{
mov edx, dword ptr [RadarBoundsCheckCoordBlip_Count]
mov edx, RadarBoundsCheckCoordBlip_Count
cmp cl, byte ptr [edx]
jnb OutOfBounds
mov edx, ecx
@ -418,7 +418,7 @@ void __declspec(naked) RadarBoundsCheckCoordBlip()
OutOfBounds:
or eax, -1
fcompp
retn
ret
}
#else
__asm__ volatile
@ -441,12 +441,12 @@ OutOfBounds:
}
static void* RadarBoundsCheckEntityBlip_JumpBack = AddressByVersion<void*>(0x4A565E, 0x4A574E, 0x4A56DE);
void __declspec(naked) RadarBoundsCheckEntityBlip()
__declspec(naked) void RadarBoundsCheckEntityBlip()
{
#ifdef _MSC_VER
_asm
{
mov edx, dword ptr [RadarBoundsCheckCoordBlip_Count]
mov edx, RadarBoundsCheckCoordBlip_Count
cmp cl, byte ptr [edx]
jnb OutOfBounds
mov edx, ecx
@ -455,7 +455,7 @@ void __declspec(naked) RadarBoundsCheckEntityBlip()
OutOfBounds:
or eax, -1
retn
ret
}
#else
__asm__ volatile
@ -510,10 +510,11 @@ unsigned int __cdecl AutoPilotTimerCalculation_III(unsigned int nTimer, int nSca
return nTimer - static_cast<unsigned int>(nScaleFactor * fScaleCoef);
}
void __declspec(naked) AutoPilotTimerFix_III()
__declspec(naked) void AutoPilotTimerFix_III()
{
#ifdef _MSC_VER
_asm {
_asm
{
push dword ptr [esp + 0x4]
push dword ptr [ebx + 0x10]
push eax
@ -524,7 +525,7 @@ void __declspec(naked) AutoPilotTimerFix_III()
pop ebp
pop esi
pop ebx
retn 4
ret 4
}
#else
__asm__ volatile
@ -693,23 +694,23 @@ namespace SirenSwitchingFix
// ============= Fixed vehicles exploding twice if the driver leaves the car while it's exploding =============
namespace RemoveDriverStatusFix
{
__declspec(naked) void RemoveDriver_SetStatus()
__declspec(naked) static void RemoveDriver_SetStatus()
{
// if (m_nStatus != STATUS_WRECKED)
// m_nStatus = STATUS_ABANDONED;
#ifdef _MSC_VER
_asm
{
mov ah, [ecx+50h]
mov ah, [ecx+0x50]
mov al, ah
and ah, 0F8h
cmp ah, 28h
and ah, 0xF8
cmp ah, 0x28
je DontSetStatus
and al, 7
or al, 20h
or al, 0x20
DontSetStatus:
retn
ret
}
#else
__asm__ volatile
@ -756,18 +757,18 @@ namespace EvasiveDiveFix
return CGeneral::LimitRadianAngle(angle);
}
__declspec(naked) void CalculateAngle_Hook()
__declspec(naked) static void CalculateAngle_Hook()
{
#ifdef _MSC_VER
_asm
{
push dword ptr [esi+7Ch]
push dword ptr [esi+78h]
push dword ptr [esi+0x7C]
push dword ptr [esi+0x78]
call CalculateAngle
add esp, 8
mov ecx, ebp
retn
ret
}
#else
__asm__ volatile
@ -799,7 +800,7 @@ namespace NullTerminatedLines
{
mov eax, [esp+4]
mov byte ptr [eax+ecx], 0
jmp [orgSscanf_LoadPath]
jmp orgSscanf_LoadPath
}
#else
__asm__ volatile
@ -820,7 +821,7 @@ namespace NullTerminatedLines
{
mov eax, [esp+4]
mov byte ptr [eax+ecx], 0
jmp [orgSscanf1]
jmp orgSscanf1
}
#else
__asm__ volatile
@ -838,12 +839,12 @@ namespace NullTerminatedLines
#ifdef _MSC_VER
_asm
{
mov ecx, [gString]
mov ecx, gString
mov byte ptr [ecx+edx], 0
mov ecx, [esi]
inc ebp
add ecx, [esp+0ACh-98h]
retn
add ecx, [esp+0xAC-0x98]
ret
}
#else
__asm__ volatile
@ -886,14 +887,14 @@ namespace DodoKeyboardControls
#ifdef _MSC_VER
_asm
{
call [orgFindPlayerVehicle]
mov ecx, [bAllDodosCheat]
call orgFindPlayerVehicle
mov ecx, bAllDodosCheat
cmp byte ptr [ecx], 0
je CheatDisabled
mov byte ptr [esp+1Ch-14h], 1
mov byte ptr [esp+0x1C-0x14], 1
CheatDisabled:
retn
ret
}
#else
__asm__ volatile
@ -964,12 +965,12 @@ namespace GenerateNewPickup_ReuseObjectFix
static void* pPickupObject;
static void (*orgGiveUsAPickUpObject)(int);
__declspec(naked) void GiveUsAPickUpObject_CleanUpObject()
__declspec(naked) static void GiveUsAPickUpObject_CleanUpObject()
{
#ifdef _MSC_VER
_asm
{
mov eax, [pPickupObject]
mov eax, pPickupObject
add eax, ebp
mov eax, [eax]
test eax, eax
@ -978,7 +979,7 @@ namespace GenerateNewPickup_ReuseObjectFix
mov edi, eax
push edi
call [WorldRemove]
call WorldRemove
add esp, 4
// Call dtor
@ -990,7 +991,7 @@ namespace GenerateNewPickup_ReuseObjectFix
pop edi
NoPickup:
jmp [orgGiveUsAPickUpObject]
jmp orgGiveUsAPickUpObject
}
#else
__asm__ volatile

View file

@ -6,7 +6,7 @@
<SILENTPATCH_EXT>.asi</SILENTPATCH_EXT>
<SILENTPATCH_FULL_NAME>SilentPatch for GTA III</SILENTPATCH_FULL_NAME>
<SILENTPATCH_REVISION_ID>9</SILENTPATCH_REVISION_ID>
<SILENTPATCH_BUILD_ID>1</SILENTPATCH_BUILD_ID>
<SILENTPATCH_BUILD_ID>2</SILENTPATCH_BUILD_ID>
<SILENTPATCH_COPYRIGHT>2013-2024</SILENTPATCH_COPYRIGHT>
</PropertyGroup>
<PropertyGroup />

View file

@ -131,7 +131,7 @@ uint8_t CPed::GetWeaponSkillForRenderWeaponPedsForPC_SAMP()
bool CTaskComplexSequence::Contains(int taskID) const
{
for (CTask* task : m_taskSequence)
for (const CTask* task : m_taskSequence)
{
if (task != nullptr && task->GetTaskType() == taskID)
{

File diff suppressed because it is too large Load diff

View file

@ -669,13 +669,13 @@ float FixedRefValue()
return 1.0f;
}
void __declspec(naked) SubtitlesShadowFix()
__declspec(naked) void SubtitlesShadowFix()
{
#ifdef MSC_VER
_asm
{
mov [esp], eax
fild [esp]
fild dword ptr [esp]
push eax
lea eax, [esp+20h-18h]
push eax
@ -708,7 +708,7 @@ RwFrame* __thiscall CVehicleModelInfo_GetExtrasFrame(CVehicleModelInfo* modelInf
return modelInfo->GetExtrasFrame(clump);
}
void __declspec(naked) CreateInstance_BikeFix()
__declspec(naked) void CreateInstance_BikeFix()
{
#ifdef MSC_VER
_asm
@ -716,7 +716,7 @@ void __declspec(naked) CreateInstance_BikeFix()
push eax
mov ecx, ebp
call CVehicleModelInfo::GetExtrasFrame
retn
ret
}
#else
__asm__ volatile
@ -765,10 +765,11 @@ unsigned int __cdecl AutoPilotTimerCalculation_VC(unsigned int nTimer, int nScal
return nTimer - static_cast<unsigned int>(nScaleFactor * fScaleCoef);
}
void __declspec(naked) AutoPilotTimerFix_VC()
__declspec(naked) void AutoPilotTimerFix_VC()
{
#ifdef MSC_VER
_asm {
_asm
{
push dword ptr [esp + 0xC]
push dword ptr [ebx + 0x10]
push eax
@ -778,7 +779,7 @@ void __declspec(naked) AutoPilotTimerFix_VC()
add esp, 0x30
pop ebp
pop ebx
retn 4
ret 4
}
#else
__asm__ volatile
@ -914,24 +915,24 @@ namespace Localization
// ============= Corrected FBI Washington sirens sound =============
namespace SirenSwitchingFix
{
void __declspec(naked) IsFBIRanchOrFBICar()
__declspec(naked) static void IsFBIRanchOrFBICar()
{
#ifdef MSC_VER
_asm
{
mov dword ptr [esi+1Ch], 1Ch
mov dword ptr [esi+0x1C], 0x1C
// al = 0 - high pitched siren
// al = 1 - normal siren
cmp dword ptr [ebp+14h], 90 // fbiranch
cmp dword ptr [ebp+0x14], 90 // fbiranch
je IsFBIRanchOrFBICar_HighPitchSiren
cmp dword ptr [ebp+14h], 17 // fbicar
cmp dword ptr [ebp+0x14], 17 // fbicar
setne al
retn
ret
IsFBIRanchOrFBICar_HighPitchSiren:
xor al, al
retn
ret
}
#else
__asm__ volatile
@ -1015,23 +1016,23 @@ namespace FBISirenCoronaFix
// ============= Fixed vehicles exploding twice if the driver leaves the car while it's exploding =============
namespace RemoveDriverStatusFix
{
__declspec(naked) void RemoveDriver_SetStatus()
__declspec(naked) static void RemoveDriver_SetStatus()
{
// if (m_nStatus != STATUS_WRECKED)
// m_nStatus = STATUS_ABANDONED;
#ifdef MSC_VER
_asm
{
mov cl, [ebx+50h]
mov cl, [ebx+0x50]
mov al, cl
and cl, 0F8h
cmp cl, 28h
and cl, 0xF8
cmp cl, 0x28
je DontSetStatus
and al, 7
or al, 20h
or al, 0x20
DontSetStatus:
retn
ret
}
#else
__asm__ volatile
@ -1125,7 +1126,7 @@ namespace NullTerminatedLines
{
mov eax, [esp+4]
mov byte ptr [eax+ecx], 0
jmp [orgSscanf_LoadPath]
jmp orgSscanf_LoadPath
}
#else
__asm__ volatile
@ -1163,9 +1164,9 @@ namespace PickupEffectsFixes
#ifdef MSC_VER
_asm
{
mov byte ptr [esp+184h-170h], 0
mov dword ptr [esp+184h-174h], 37
retn
mov byte ptr [esp+0x184-0x170], 0
mov dword ptr [esp+0x184-0x174], 37
ret
}
#else
__asm__ volatile
@ -1184,7 +1185,7 @@ namespace PickupEffectsFixes
{
cmp ecx, 294 // minigun2
jnz NotMinigun2
mov byte ptr [esp+184h-170h], 0
mov byte ptr [esp+0x184-0x170], 0
xor eax, eax
jmp Return
@ -1193,7 +1194,7 @@ namespace PickupEffectsFixes
Return:
mov ebx, ecx
retn
ret
}
#else
__asm__ volatile
@ -1233,21 +1234,21 @@ namespace IsPlayerTargettingCharFix
{
test bl, bl
jnz ReturnToUpdateCompareFlag
mov eax, [bUseMouse3rdPerson]
mov eax, bUseMouse3rdPerson
cmp byte ptr [eax], 0
jne CmpAndReturn
mov ecx, [TheCamera]
call [Using1stPersonWeaponMode]
mov ecx, TheCamera
call Using1stPersonWeaponMode
test al, al
jz ReturnToUpdateCompareFlag
CmpAndReturn:
cmp byte ptr [esp+11Ch-10Ch], 0
retn
cmp byte ptr [esp+0x11C-0x10C], 0
ret
ReturnToUpdateCompareFlag:
xor al, al
retn
ret
}
#else
__asm__ volatile
@ -1364,8 +1365,8 @@ namespace SelectableBackfaceCulling
{
push ebx
mov ebx, ecx
cmp dword ptr [ebx+4Ch], 0
jmp [EntityRender_Prologue_JumpBack]
cmp dword ptr [ebx+0x4C], 0
jmp EntityRender_Prologue_JumpBack
}
#else
__asm__ volatile
@ -1550,7 +1551,7 @@ namespace TommyFistShakeWithWeapons
return !bWeaponAllowsFistShake;
}
static __declspec(naked) void CheckWeaponGroupHook()
__declspec(naked) static void CheckWeaponGroupHook()
{
#ifdef MSC_VER
_asm
@ -1559,7 +1560,7 @@ namespace TommyFistShakeWithWeapons
call WeaponProhibitsFistShake
add esp, 4
test al, al
retn
ret
}
#else
__asm__ volatile