Compare commits

...

7 commits

Author SHA1 Message Date
Echo J.
52a2798b40
Merge fdce60d22f into c733f3e7d1 2024-11-17 01:29:39 +03:00
Echo J
c733f3e7d1 III: Fix the missing window icon
For some reason GTA 3 sets the hIcon value in WNDCLASSA struct to
NULL which causes the window icon to be the default one (this was
fixed in Vice City)
2024-11-16 22:20:03 +01:00
Echo J
fdce60d22f SilentPatchSA: Fixup the MSVC inline assembly statements (part 3)
Also clean them up in general
2024-11-13 21:18:58 +02:00
Echo J
9b6e5096e7 SilentPatchSA: Fixup the MSVC inline assembly statements (part 2)
Also clean them up in general
2024-11-13 21:18:58 +02:00
Echo J
65925ef8e8 SilentPatchSA: Fixup the MSVC inline assembly statements (part 1)
Also clean them up in general
2024-11-13 21:18:58 +02:00
Echo J
d0c35bd852 SilentPatchVC: Fixup the MSVC inline assembly statements
Also clean them up in general
2024-11-13 21:18:58 +02:00
Echo J
602ac27b38 SilentPatchIII: Fixup the MSVC inline assembly statements
Some of them use the deference operator incorrectly (also clean them
up in general)
2024-11-13 21:18:52 +02:00
5 changed files with 348 additions and 336 deletions

View file

@ -71,6 +71,7 @@ All the remaining, non-critical fixes.
* Detached limbs now have properly working LODs, instead of rendering the normal and low-detail models at the same time.
* Low Brightness options now load and save correctly, instead of reverting to overly bright values.
* Support for the `brakelights` dummy has been restored, allowing brake and reverse lights to work as they did in the PS2 version, rather than always sharing the same placement with the tail lights.
* The correct window icon is now displayed.
* ⚙️ Fixed siren corona placements in Firetruck, Ambulance, and Enforcer.
* ⚙️ Fixed taxi light corona placement for Taxi.
* ⚙️ Fixed police chopper's searchlight placement.

View file

@ -229,6 +229,16 @@ namespace Common {
}
TXN_CATCH();
// III: Patch the icon handle to fix missing window icon
// (This is fixed since VC)
try
{
auto addr = get_pattern("c7 44 24 1c 00 00 00 00 c7 44 24 08 00 20 00", 0x4);
HICON wndIconIII = LoadIconA(GetModuleHandleA(nullptr), MAKEINTRESOURCEA(0x412)); // Group icon ID
Patch<HICON>(addr, wndIconIII);
}
TXN_CATCH();
// No censorships
try
@ -249,4 +259,4 @@ namespace Common {
TXN_CATCH();
}
}
}
}

View file

@ -194,37 +194,37 @@ void ResetMousePos()
orgConstructRenderList();
}
void __declspec(naked) M16StatsFix()
__declspec(naked) void M16StatsFix()
{
_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
}
}
void __declspec(naked) HeadlightsFix()
static const float fMinusOne = -1.0f;
__declspec(naked) void HeadlightsFix()
{
static const float fMinusOne = -1.0f;
_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]
HeadlightsFix_DontLimit:
fld dword ptr [esp+0x708-0x690]
fabs
fld st
jmp [HeadlightsFix_JumpBack]
jmp HeadlightsFix_JumpBack
}
}
@ -312,68 +312,68 @@ float FixedRefValue()
return 1.0f;
}
void __declspec(naked) SubtitlesShadowFix()
__declspec(naked) void SubtitlesShadowFix()
{
_asm
{
push eax
call Recalculate
fadd [esp+50h+8]
fadd [fShadowYSize]
fadd dword ptr [esp+0x50+8]
fadd fShadowYSize
jmp SubtitlesShadowFix_JumpBack
}
}
void __declspec(naked) III_SensResetFix()
__declspec(naked) void III_SensResetFix()
{
_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
}
}
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()
{
_asm
{
mov edx, dword ptr [RadarBoundsCheckCoordBlip_Count]
mov edx, RadarBoundsCheckCoordBlip_Count
cmp cl, byte ptr [edx]
jnb OutOfBounds
mov edx, ecx
mov eax, [esp+4]
jmp RadarBoundsCheckCoordBlip_JumpBack
OutOfBounds:
OutOfBounds:
or eax, -1
fcompp
retn
ret
}
}
static void* RadarBoundsCheckEntityBlip_JumpBack = AddressByVersion<void*>(0x4A565E, 0x4A574E, 0x4A56DE);
void __declspec(naked) RadarBoundsCheckEntityBlip()
__declspec(naked) void RadarBoundsCheckEntityBlip()
{
_asm
{
mov edx, dword ptr [RadarBoundsCheckCoordBlip_Count]
mov edx, RadarBoundsCheckCoordBlip_Count
cmp cl, byte ptr [edx]
jnb OutOfBounds
mov edx, ecx
mov eax, [esp+4]
jmp RadarBoundsCheckEntityBlip_JumpBack
OutOfBounds:
OutOfBounds:
or eax, -1
retn
ret
}
}
@ -411,11 +411,12 @@ 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()
{
_asm {
push dword ptr[esp + 0x4]
push dword ptr[ebx + 0x10]
_asm
{
push dword ptr [esp + 0x4]
push dword ptr [ebx + 0x10]
push eax
call AutoPilotTimerCalculation_III
add esp, 0xC
@ -424,7 +425,7 @@ void __declspec(naked) AutoPilotTimerFix_III()
pop ebp
pop esi
pop ebx
retn 4
ret 4
}
}
@ -576,22 +577,22 @@ 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;
_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
}
}
}
@ -623,17 +624,17 @@ namespace EvasiveDiveFix
return CGeneral::LimitRadianAngle(angle);
}
__declspec(naked) void CalculateAngle_Hook()
__declspec(naked) static void CalculateAngle_Hook()
{
_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
}
}
}
@ -651,7 +652,7 @@ namespace NullTerminatedLines
{
mov eax, [esp+4]
mov byte ptr [eax+ecx], 0
jmp [orgSscanf_LoadPath]
jmp orgSscanf_LoadPath
}
}
@ -662,7 +663,7 @@ namespace NullTerminatedLines
{
mov eax, [esp+4]
mov byte ptr [eax+ecx], 0
jmp [orgSscanf1]
jmp orgSscanf1
}
}
@ -670,12 +671,12 @@ namespace NullTerminatedLines
{
_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
}
}
}
@ -705,14 +706,14 @@ namespace DodoKeyboardControls
{
_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
}
}
}
@ -768,11 +769,11 @@ namespace GenerateNewPickup_ReuseObjectFix
static void* pPickupObject;
static void (*orgGiveUsAPickUpObject)(int);
__declspec(naked) void GiveUsAPickUpObject_CleanUpObject()
__declspec(naked) static void GiveUsAPickUpObject_CleanUpObject()
{
_asm
{
mov eax, [pPickupObject]
mov eax, pPickupObject
add eax, ebp
mov eax, [eax]
test eax, eax
@ -781,7 +782,7 @@ namespace GenerateNewPickup_ReuseObjectFix
mov edi, eax
push edi
call [WorldRemove]
call WorldRemove
add esp, 4
// Call dtor
@ -793,7 +794,7 @@ namespace GenerateNewPickup_ReuseObjectFix
pop edi
NoPickup:
jmp [orgGiveUsAPickUpObject]
jmp orgGiveUsAPickUpObject
}
}
}
@ -2499,4 +2500,4 @@ extern "C" __declspec(dllexport)
uint32_t GetBuildNumber()
{
return (SILENTPATCH_REVISION_ID << 8) | SILENTPATCH_BUILD_ID;
}
}

File diff suppressed because it is too large Load diff

View file

@ -669,12 +669,12 @@ float FixedRefValue()
return 1.0f;
}
void __declspec(naked) SubtitlesShadowFix()
__declspec(naked) void SubtitlesShadowFix()
{
_asm
{
mov [esp], eax
fild [esp]
fild dword ptr [esp]
push eax
lea eax, [esp+20h-18h]
push eax
@ -685,14 +685,14 @@ void __declspec(naked) SubtitlesShadowFix()
}
}
void __declspec(naked) CreateInstance_BikeFix()
__declspec(naked) void CreateInstance_BikeFix()
{
_asm
{
push eax
mov ecx, ebp
call CVehicleModelInfo::GetExtrasFrame
retn
ret
}
}
@ -731,11 +731,12 @@ 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()
{
_asm {
push dword ptr[esp + 0xC]
push dword ptr[ebx + 0x10]
_asm
{
push dword ptr [esp + 0xC]
push dword ptr [ebx + 0x10]
push eax
call AutoPilotTimerCalculation_VC
add esp, 0xC
@ -743,7 +744,7 @@ void __declspec(naked) AutoPilotTimerFix_VC()
add esp, 0x30
pop ebp
pop ebx
retn 4
ret 4
}
}
@ -863,23 +864,23 @@ namespace Localization
// ============= Corrected FBI Washington sirens sound =============
namespace SirenSwitchingFix
{
void __declspec(naked) IsFBIRanchOrFBICar()
__declspec(naked) static void IsFBIRanchOrFBICar()
{
_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
}
}
}
@ -945,22 +946,22 @@ 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;
_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
}
}
}
@ -1038,7 +1039,7 @@ namespace NullTerminatedLines
{
mov eax, [esp+4]
mov byte ptr [eax+ecx], 0
jmp [orgSscanf_LoadPath]
jmp orgSscanf_LoadPath
}
}
}
@ -1066,9 +1067,9 @@ namespace PickupEffectsFixes
{
_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
}
}
@ -1078,7 +1079,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
@ -1087,7 +1088,7 @@ namespace PickupEffectsFixes
Return:
mov ebx, ecx
retn
ret
}
}
}
@ -1109,21 +1110,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
}
}
}
@ -1214,8 +1215,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
}
}
@ -1390,7 +1391,7 @@ namespace TommyFistShakeWithWeapons
return !bWeaponAllowsFistShake;
}
static __declspec(naked) void CheckWeaponGroupHook()
__declspec(naked) static void CheckWeaponGroupHook()
{
_asm
{
@ -1398,7 +1399,7 @@ namespace TommyFistShakeWithWeapons
call WeaponProhibitsFistShake
add esp, 4
test al, al
retn
ret
}
}
@ -2982,4 +2983,4 @@ extern "C" __declspec(dllexport)
uint32_t GetBuildNumber()
{
return (SILENTPATCH_REVISION_ID << 8) | SILENTPATCH_BUILD_ID;
}
}