mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 23:33:02 +05:00
Compare commits
10 commits
870e3d63a1
...
8871042371
Author | SHA1 | Date | |
---|---|---|---|
|
8871042371 | ||
|
af090bc76a | ||
|
723765e441 | ||
|
84ba52d98d | ||
|
500718176c | ||
|
ae7973f068 | ||
|
60977fd74d | ||
|
135d1b322e | ||
|
a696e2c389 | ||
|
9dbda6951b |
11 changed files with 426 additions and 11 deletions
|
@ -198,7 +198,7 @@ static bool PatchIAT()
|
|||
static bool PatchIAT_ByPointers()
|
||||
{
|
||||
pOrgSystemParametersInfoA = SystemParametersInfoA;
|
||||
memcpy( orgCode, pOrgSystemParametersInfoA, sizeof(orgCode) );
|
||||
memcpy( orgCode, reinterpret_cast<void*>(pOrgSystemParametersInfoA), sizeof(orgCode) );
|
||||
Memory::VP::InjectHook( pOrgSystemParametersInfoA, SystemParametersInfoA_OverwritingHook, Memory::HookType::Jump );
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace HandlingNameLoadFix
|
|||
// ============= Corona lines rendering fix =============
|
||||
namespace CoronaLinesFix
|
||||
{
|
||||
static decltype(RwIm2DRenderLine)* orgRwIm2DRenderLine;
|
||||
static RwIm2DRenderLineFunction orgRwIm2DRenderLine;
|
||||
static RwBool RenderLine_SetRecipZ( RwIm2DVertex *vertices, RwInt32 numVertices, RwInt32 vert1, RwInt32 vert2 )
|
||||
{
|
||||
const RwReal nearScreenZ = RwIm2DGetNearScreenZ();
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "Utils/MemoryMgr.h"
|
||||
#include "Utils/Patterns.h"
|
||||
|
||||
#define RwEngineInstance (*rwengine)
|
||||
|
||||
#include <rwcore.h>
|
||||
#include "RWGTA.h"
|
||||
|
||||
|
@ -52,6 +50,7 @@ void RwD3D8GetRenderState(RwUInt32 state, void* value)
|
|||
fnRwD3D8GetRenderState(state, value);
|
||||
}
|
||||
|
||||
#ifndef RwIm2DGetNearScreenZ
|
||||
RwReal RwIm2DGetNearScreenZ()
|
||||
{
|
||||
return RWSRCGLOBAL(dOpenDevice).zBufferNear;
|
||||
|
@ -66,6 +65,7 @@ RwBool RwRenderStateSet(RwRenderState state, void *value)
|
|||
{
|
||||
return RWSRCGLOBAL(dOpenDevice).fpRenderStateSet(state, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Unreachable stub
|
||||
RwBool RwMatrixDestroy(RwMatrix* /*mpMat*/) { assert(!"Unreachable!"); return TRUE; }
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#define RwEngineInstance (*rwengine)
|
||||
|
||||
extern void** rwengine;
|
||||
|
||||
namespace RWGTA::Patches
|
||||
{
|
||||
bool TryLocateRwD3D8();
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
#include <rwcore.h>
|
||||
#include <rpworld.h>
|
||||
|
||||
#define RwEngineInstance (*rwengine)
|
||||
|
||||
extern void** rwengine;
|
||||
|
||||
template<RwRenderState State>
|
||||
class RwScopedRenderState
|
||||
{
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#include "SVF.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <cstring>
|
||||
#define _stricmp strcasecmp
|
||||
#endif
|
||||
|
||||
namespace SVF
|
||||
{
|
||||
Feature GetFeatureFromName( const char* featureName )
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __TIMER
|
||||
#define __TIMER
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class CTimer
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include "Maths.h"
|
||||
|
||||
#include <rwcore.h>
|
||||
|
|
|
@ -196,6 +196,7 @@ void ResetMousePos()
|
|||
|
||||
void __declspec(naked) M16StatsFix()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
add eax, 34h
|
||||
|
@ -204,11 +205,23 @@ void __declspec(naked) M16StatsFix()
|
|||
inc [ecx]
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"add eax, 0x34\n"
|
||||
"add ebx, 0x34\n"
|
||||
"mov ecx, %[InstantHitsFiredByPlayer]\n"
|
||||
"inc dword ptr [ecx]\n"
|
||||
"ret"
|
||||
:: [InstantHitsFiredByPlayer] "m" (InstantHitsFiredByPlayer)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const float fMinusOne = -1.0f;
|
||||
void __declspec(naked) HeadlightsFix()
|
||||
{
|
||||
static const float fMinusOne = -1.0f;
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
fld [esp+708h-690h]
|
||||
|
@ -226,6 +239,27 @@ HeadlightsFix_DontLimit:
|
|||
fld st
|
||||
jmp [HeadlightsFix_JumpBack]
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"fld dword ptr [esp+0x708-0x690]\n"
|
||||
"fcomp %[fMinusOne]\n"
|
||||
"fnstsw ax\n"
|
||||
"and ah, 5\n"
|
||||
"cmp ah, 1\n"
|
||||
"jnz HeadlightsFix_DontLimit\n"
|
||||
"fld %[fMinusOne]\n"
|
||||
"fstp dword ptr [esp+0x708-0x690]\n"
|
||||
|
||||
"HeadlightsFix_DontLimit:\n"
|
||||
"fld dword ptr [esp+0x708-0x690]\n"
|
||||
"fabs\n"
|
||||
"fld st\n"
|
||||
"jmp %[HeadlightsFix_JumpBack]"
|
||||
:: [fMinusOne] "f" (fMinusOne),
|
||||
[HeadlightsFix_JumpBack] "m" (HeadlightsFix_JumpBack)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
static float fShadowXSize, fShadowYSize;
|
||||
|
@ -314,6 +348,7 @@ float FixedRefValue()
|
|||
|
||||
void __declspec(naked) SubtitlesShadowFix()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
push eax
|
||||
|
@ -322,10 +357,24 @@ void __declspec(naked) SubtitlesShadowFix()
|
|||
fadd [fShadowYSize]
|
||||
jmp SubtitlesShadowFix_JumpBack
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"push eax\n"
|
||||
"call %[Recalculate]\n"
|
||||
"fadd dword ptr [esp+0x50+8]\n"
|
||||
"fadd %[fShadowYSize]\n"
|
||||
"jmp %[SubtitlesShadowFix_JumpBack]"
|
||||
:: [Recalculate] "i" (Recalculate),
|
||||
[fShadowYSize] "m" (fShadowYSize),
|
||||
[SubtitlesShadowFix_JumpBack] "m" (SubtitlesShadowFix_JumpBack)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void __declspec(naked) III_SensResetFix()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov ecx, 3A76h
|
||||
|
@ -337,12 +386,26 @@ void __declspec(naked) III_SensResetFix()
|
|||
fstp dword ptr [ebp+194h]
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov ecx, 0x3A76\n"
|
||||
"mov edi, ebp\n"
|
||||
"fld dword ptr [ebp+0x194]\n"
|
||||
"fld dword ptr [ebp+0x198]\n"
|
||||
"rep stosd\n"
|
||||
"fstp dword ptr [ebp+0x198]\n"
|
||||
"fstp dword ptr [ebp+0x194]\n"
|
||||
"ret"
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void* RadarBoundsCheckCoordBlip_JumpBack = AddressByVersion<void*>(0x4A55B8, 0x4A56A8, 0x4A5638);
|
||||
static void* RadarBoundsCheckCoordBlip_Count = AddressByVersion<void*>(0x4A55AF, 0x4A569F, 0x4A562F);
|
||||
void __declspec(naked) RadarBoundsCheckCoordBlip()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov edx, dword ptr [RadarBoundsCheckCoordBlip_Count]
|
||||
|
@ -357,11 +420,30 @@ OutOfBounds:
|
|||
fcompp
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov edx, %[RadarBoundsCheckCoordBlip_Count]\n"
|
||||
"cmp cl, byte ptr [edx]\n"
|
||||
"jnb OutOfBounds\n"
|
||||
"mov edx, ecx\n"
|
||||
"mov eax, [esp+4]\n"
|
||||
"jmp %[RadarBoundsCheckCoordBlip_JumpBack]\n"
|
||||
|
||||
"OutOfBounds:\n"
|
||||
"or eax, -1\n"
|
||||
"fcompp\n"
|
||||
"ret"
|
||||
:: [RadarBoundsCheckCoordBlip_Count] "m" (RadarBoundsCheckCoordBlip_Count),
|
||||
[RadarBoundsCheckCoordBlip_JumpBack] "m" (RadarBoundsCheckCoordBlip_JumpBack)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void* RadarBoundsCheckEntityBlip_JumpBack = AddressByVersion<void*>(0x4A565E, 0x4A574E, 0x4A56DE);
|
||||
void __declspec(naked) RadarBoundsCheckEntityBlip()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov edx, dword ptr [RadarBoundsCheckCoordBlip_Count]
|
||||
|
@ -375,6 +457,23 @@ void __declspec(naked) RadarBoundsCheckEntityBlip()
|
|||
or eax, -1
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov edx, %[RadarBoundsCheckCoordBlip_Count]\n"
|
||||
"cmp cl, byte ptr [edx]\n"
|
||||
"jnb OutOfBounds2\n"
|
||||
"mov edx, ecx\n"
|
||||
"mov eax, [esp+4]\n"
|
||||
"jmp %[RadarBoundsCheckEntityBlip_JumpBack]\n"
|
||||
|
||||
"OutOfBounds2:\n"
|
||||
"or eax, -1\n"
|
||||
"ret"
|
||||
:: [RadarBoundsCheckCoordBlip_Count] "m" (RadarBoundsCheckCoordBlip_Count),
|
||||
[RadarBoundsCheckEntityBlip_JumpBack] "m" (RadarBoundsCheckEntityBlip_JumpBack)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
char** ppUserFilesDir = AddressByVersion<char**>(0x580C16, 0x580F66, 0x580E66);
|
||||
|
@ -413,6 +512,7 @@ unsigned int __cdecl AutoPilotTimerCalculation_III(unsigned int nTimer, int nSca
|
|||
|
||||
void __declspec(naked) AutoPilotTimerFix_III()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm {
|
||||
push dword ptr[esp + 0x4]
|
||||
push dword ptr[ebx + 0x10]
|
||||
|
@ -426,6 +526,23 @@ void __declspec(naked) AutoPilotTimerFix_III()
|
|||
pop ebx
|
||||
retn 4
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"push dword ptr [esp + 0x4]\n"
|
||||
"push dword ptr [ebx + 0x10]\n"
|
||||
"push eax\n"
|
||||
"call %[AutoPilotTimerCalculation_III]\n"
|
||||
"add esp, 0xC\n"
|
||||
"mov [ebx + 0xC], eax\n"
|
||||
"add esp, 0x28\n"
|
||||
"pop ebp\n"
|
||||
"pop esi\n"
|
||||
"pop ebx\n"
|
||||
"ret 4"
|
||||
:: [AutoPilotTimerCalculation_III] "i" (AutoPilotTimerCalculation_III)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace ZeroAmmoFix
|
||||
|
@ -580,6 +697,7 @@ namespace RemoveDriverStatusFix
|
|||
{
|
||||
// if (m_nStatus != STATUS_WRECKED)
|
||||
// m_nStatus = STATUS_ABANDONED;
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov ah, [ecx+50h]
|
||||
|
@ -593,6 +711,21 @@ namespace RemoveDriverStatusFix
|
|||
DontSetStatus:
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov ah, [ecx+0x50]\n"
|
||||
"mov al, ah\n"
|
||||
"and ah, 0xF8\n"
|
||||
"cmp ah, 0x28\n"
|
||||
"je DontSetStatus\n"
|
||||
"and al, 7\n"
|
||||
"or al, 0x20\n"
|
||||
|
||||
"DontSetStatus:\n"
|
||||
"ret"
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -625,6 +758,7 @@ namespace EvasiveDiveFix
|
|||
|
||||
__declspec(naked) void CalculateAngle_Hook()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
push dword ptr [esi+7Ch]
|
||||
|
@ -635,6 +769,19 @@ namespace EvasiveDiveFix
|
|||
mov ecx, ebp
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"push dword ptr [esi+0x7C]\n"
|
||||
"push dword ptr [esi+0x78]\n"
|
||||
"call %[CalculateAngle]\n"
|
||||
"add esp, 8\n"
|
||||
|
||||
"mov ecx, ebp\n"
|
||||
"ret"
|
||||
:: [CalculateAngle] "i" (CalculateAngle)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,27 +794,48 @@ namespace NullTerminatedLines
|
|||
static void* orgSscanf_LoadPath;
|
||||
__declspec(naked) static void sscanf1_LoadPath_Terminate()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov eax, [esp+4]
|
||||
mov byte ptr [eax+ecx], 0
|
||||
jmp [orgSscanf_LoadPath]
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov eax, [esp+4]\n"
|
||||
"mov byte ptr [eax+ecx], 0\n"
|
||||
"jmp %[orgSscanf_LoadPath]"
|
||||
:: [orgSscanf_LoadPath] "m" (orgSscanf_LoadPath)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void* orgSscanf1;
|
||||
__declspec(naked) static void sscanf1_Terminate()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov eax, [esp+4]
|
||||
mov byte ptr [eax+ecx], 0
|
||||
jmp [orgSscanf1]
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov eax, [esp+4]\n"
|
||||
"mov byte ptr [eax+ecx], 0\n"
|
||||
"jmp %[orgSscanf1]"
|
||||
:: [orgSscanf1] "m" (orgSscanf1)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
__declspec(naked) static void ReadTrackFile_Terminate()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov ecx, [gString]
|
||||
|
@ -677,6 +845,18 @@ namespace NullTerminatedLines
|
|||
add ecx, [esp+0ACh-98h]
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov ecx, %[gString]\n"
|
||||
"mov byte ptr [ecx+edx], 0\n"
|
||||
"mov ecx, [esi]\n"
|
||||
"inc ebp\n"
|
||||
"add ecx, [esp+0xAC-0x98]\n"
|
||||
"ret"
|
||||
:: [gString] "m" (gString)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -703,6 +883,7 @@ namespace DodoKeyboardControls
|
|||
static void* (*orgFindPlayerVehicle)();
|
||||
__declspec(naked) static void FindPlayerVehicle_DodoCheck()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
call [orgFindPlayerVehicle]
|
||||
|
@ -714,6 +895,21 @@ namespace DodoKeyboardControls
|
|||
CheatDisabled:
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"call %[orgFindPlayerVehicle]\n"
|
||||
"mov ecx, %[bAllDodosCheat]\n"
|
||||
"cmp byte ptr [ecx], 0\n"
|
||||
"je CheatDisabled\n"
|
||||
"mov byte ptr [esp+0x1C-0x14], 1\n"
|
||||
|
||||
"CheatDisabled:\n"
|
||||
"ret"
|
||||
:: [orgFindPlayerVehicle] "m" (orgFindPlayerVehicle),
|
||||
[bAllDodosCheat] "m" (bAllDodosCheat)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -770,6 +966,7 @@ namespace GenerateNewPickup_ReuseObjectFix
|
|||
|
||||
__declspec(naked) void GiveUsAPickUpObject_CleanUpObject()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov eax, [pPickupObject]
|
||||
|
@ -795,6 +992,36 @@ namespace GenerateNewPickup_ReuseObjectFix
|
|||
NoPickup:
|
||||
jmp [orgGiveUsAPickUpObject]
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov eax, %[pPickupObject]\n"
|
||||
"add eax, ebp\n"
|
||||
"mov eax, [eax]\n"
|
||||
"test eax, eax\n"
|
||||
"jz NoPickup\n"
|
||||
"push edi\n"
|
||||
"mov edi, eax\n"
|
||||
|
||||
"push edi\n"
|
||||
"call offset %[WorldRemove]\n"
|
||||
"add esp, 4\n"
|
||||
|
||||
// Call dtor
|
||||
"mov ecx, edi\n"
|
||||
"mov eax, [edi]\n"
|
||||
"push 1\n"
|
||||
"call dword ptr [eax]\n"
|
||||
|
||||
"pop edi\n"
|
||||
|
||||
"NoPickup:\n"
|
||||
"jmp %[orgGiveUsAPickUpObject]"
|
||||
:: [pPickupObject] "m" (pPickupObject),
|
||||
[WorldRemove] "m" (WorldRemove),
|
||||
[orgGiveUsAPickUpObject] "m" (orgGiveUsAPickUpObject)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -671,6 +671,7 @@ float FixedRefValue()
|
|||
|
||||
void __declspec(naked) SubtitlesShadowFix()
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov [esp], eax
|
||||
|
@ -683,10 +684,33 @@ void __declspec(naked) SubtitlesShadowFix()
|
|||
call Recalculate
|
||||
jmp SubtitlesShadowFix_JumpBack
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov [esp], eax\n"
|
||||
"fild dword ptr [esp]\n"
|
||||
"push eax\n"
|
||||
"lea eax, [esp+0x20-0x18]\n"
|
||||
"push eax\n"
|
||||
"lea eax, [esp+0x24-0x14]\n"
|
||||
"push eax\n"
|
||||
"call %[Recalculate]\n"
|
||||
"jmp %[SubtitlesShadowFix_JumpBack]"
|
||||
:: [Recalculate] "i" (Recalculate),
|
||||
[SubtitlesShadowFix_JumpBack] "m" (SubtitlesShadowFix_JumpBack)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
// C-style wrapper for calling a C++ function in GCC-style inline assembly (the function signature is really important here)
|
||||
RwFrame* __thiscall CVehicleModelInfo_GetExtrasFrame(CVehicleModelInfo* modelInfo, RpClump* clump)
|
||||
{
|
||||
return modelInfo->GetExtrasFrame(clump);
|
||||
}
|
||||
|
||||
void __declspec(naked) CreateInstance_BikeFix()
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
push eax
|
||||
|
@ -694,6 +718,16 @@ void __declspec(naked) CreateInstance_BikeFix()
|
|||
call CVehicleModelInfo::GetExtrasFrame
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"push eax\n"
|
||||
"mov ecx, ebp\n"
|
||||
"call %[CVehicleModelInfo_GetExtrasFrame]\n"
|
||||
"ret"
|
||||
:: [CVehicleModelInfo_GetExtrasFrame] "i" (CVehicleModelInfo_GetExtrasFrame)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
char** ppUserFilesDir = AddressByVersion<char**>(0x6022AA, 0x60228A, 0x601ECA);
|
||||
|
@ -733,6 +767,7 @@ unsigned int __cdecl AutoPilotTimerCalculation_VC(unsigned int nTimer, int nScal
|
|||
|
||||
void __declspec(naked) AutoPilotTimerFix_VC()
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm {
|
||||
push dword ptr[esp + 0xC]
|
||||
push dword ptr[ebx + 0x10]
|
||||
|
@ -745,6 +780,22 @@ void __declspec(naked) AutoPilotTimerFix_VC()
|
|||
pop ebx
|
||||
retn 4
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"push dword ptr [esp + 0xC]\n"
|
||||
"push dword ptr [ebx + 0x10]\n"
|
||||
"push eax\n"
|
||||
"call %[AutoPilotTimerCalculation_VC]\n"
|
||||
"add esp, 0xC\n"
|
||||
"mov [ebx + 0xC], eax\n"
|
||||
"add esp, 0x30\n"
|
||||
"pop ebp\n"
|
||||
"pop ebx\n"
|
||||
"ret 4"
|
||||
:: [AutoPilotTimerCalculation_VC] "i" (AutoPilotTimerCalculation_VC)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -865,6 +916,7 @@ namespace SirenSwitchingFix
|
|||
{
|
||||
void __declspec(naked) IsFBIRanchOrFBICar()
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov dword ptr [esi+1Ch], 1Ch
|
||||
|
@ -881,6 +933,24 @@ namespace SirenSwitchingFix
|
|||
xor al, al
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov dword ptr [esi+0x1C], 0x1C\n"
|
||||
|
||||
// al = 0 - high pitched siren
|
||||
// al = 1 - normal siren
|
||||
"cmp dword ptr [ebp+0x14], 90\n" // fbiranch
|
||||
"je IsFBIRanchOrFBICar_HighPitchSiren\n"
|
||||
"cmp dword ptr [ebp+0x14], 17\n" // fbicar
|
||||
"setne al\n"
|
||||
"ret\n"
|
||||
|
||||
"IsFBIRanchOrFBICar_HighPitchSiren:\n"
|
||||
"xor al, al\n"
|
||||
"ret"
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -949,6 +1019,7 @@ namespace RemoveDriverStatusFix
|
|||
{
|
||||
// if (m_nStatus != STATUS_WRECKED)
|
||||
// m_nStatus = STATUS_ABANDONED;
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov cl, [ebx+50h]
|
||||
|
@ -962,6 +1033,21 @@ namespace RemoveDriverStatusFix
|
|||
DontSetStatus:
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov cl, [ebx+0x50]\n"
|
||||
"mov al, cl\n"
|
||||
"and cl, 0xF8\n"
|
||||
"cmp cl, 0x28\n"
|
||||
"je DontSetStatus\n"
|
||||
"and al, 7\n"
|
||||
"or al, 0x20\n"
|
||||
|
||||
"DontSetStatus:\n"
|
||||
"ret"
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1034,12 +1120,22 @@ namespace NullTerminatedLines
|
|||
static void* orgSscanf_LoadPath;
|
||||
__declspec(naked) static void sscanf1_LoadPath_Terminate()
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov eax, [esp+4]
|
||||
mov byte ptr [eax+ecx], 0
|
||||
jmp [orgSscanf_LoadPath]
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov eax, [esp+4]\n"
|
||||
"mov byte ptr [eax+ecx], 0\n"
|
||||
"jmp %[orgSscanf_LoadPath]"
|
||||
:: [orgSscanf_LoadPath] "m" (orgSscanf_LoadPath)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1064,16 +1160,26 @@ namespace PickupEffectsFixes
|
|||
{
|
||||
__declspec(naked) static void PickUpEffects_BigDollarColor()
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
mov byte ptr [esp+184h-170h], 0
|
||||
mov dword ptr [esp+184h-174h], 37
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"mov byte ptr [esp+0x184-0x170], 0\n"
|
||||
"mov dword ptr [esp+0x184-0x174], 37\n"
|
||||
"ret"
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
__declspec(naked) static void PickUpEffects_Minigun2Glow()
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
cmp ecx, 294 // minigun2
|
||||
|
@ -1089,6 +1195,23 @@ namespace PickupEffectsFixes
|
|||
mov ebx, ecx
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"cmp ecx, 294\n" // minigun2
|
||||
"jnz NotMinigun2\n"
|
||||
"mov byte ptr [esp+0x184-0x170], 0\n"
|
||||
"xor eax, eax\n"
|
||||
"jmp Return\n"
|
||||
|
||||
"NotMinigun2:\n"
|
||||
"lea eax, [ecx+1]\n"
|
||||
|
||||
"Return:\n"
|
||||
"mov ebx, ecx\n"
|
||||
"ret"
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1105,6 +1228,7 @@ namespace IsPlayerTargettingCharFix
|
|||
__declspec(naked) static void IsPlayerTargettingChar_ExtraChecks()
|
||||
{
|
||||
// After this extra block of code, there is a jz Return, so set ZF to 0 here if this path is to be entered
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
test bl, bl
|
||||
|
@ -1125,6 +1249,31 @@ namespace IsPlayerTargettingCharFix
|
|||
xor al, al
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"test bl, bl\n"
|
||||
"jnz ReturnToUpdateCompareFlag\n"
|
||||
"mov eax, %[bUseMouse3rdPerson]\n"
|
||||
"cmp byte ptr [eax], 0\n"
|
||||
"jne CmpAndReturn\n"
|
||||
"mov ecx, %[TheCamera]\n"
|
||||
"call %[Using1stPersonWeaponMode]\n"
|
||||
"test al, al\n"
|
||||
"jz ReturnToUpdateCompareFlag\n"
|
||||
|
||||
"CmpAndReturn:\n"
|
||||
"cmp byte ptr [esp+0x11C-0x10C], 0\n"
|
||||
"ret\n"
|
||||
|
||||
"ReturnToUpdateCompareFlag:\n"
|
||||
"xor al, al\n"
|
||||
"ret"
|
||||
:: [bUseMouse3rdPerson] "m" (bUseMouse3rdPerson),
|
||||
[TheCamera] "m" (TheCamera),
|
||||
[Using1stPersonWeaponMode] "m" (Using1stPersonWeaponMode)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1210,6 +1359,7 @@ namespace SelectableBackfaceCulling
|
|||
static void* EntityRender_Prologue_JumpBack;
|
||||
__declspec(naked) static void __fastcall EntityRender_Original(CEntity*)
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
push ebx
|
||||
|
@ -1217,6 +1367,16 @@ namespace SelectableBackfaceCulling
|
|||
cmp dword ptr [ebx+4Ch], 0
|
||||
jmp [EntityRender_Prologue_JumpBack]
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"push ebx\n"
|
||||
"mov ebx, ecx\n"
|
||||
"cmp dword ptr [ebx+0x4C], 0\n"
|
||||
"jmp %[EntityRender_Prologue_JumpBack]"
|
||||
:: [EntityRender_Prologue_JumpBack] "m" (EntityRender_Prologue_JumpBack)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool ShouldDisableBackfaceCulling(const CEntity* entity)
|
||||
|
@ -1392,6 +1552,7 @@ namespace TommyFistShakeWithWeapons
|
|||
|
||||
static __declspec(naked) void CheckWeaponGroupHook()
|
||||
{
|
||||
#ifdef MSC_VER
|
||||
_asm
|
||||
{
|
||||
push dword ptr [eax]
|
||||
|
@ -1400,6 +1561,17 @@ namespace TommyFistShakeWithWeapons
|
|||
test al, al
|
||||
retn
|
||||
}
|
||||
#else
|
||||
__asm__ volatile
|
||||
(
|
||||
"push dword ptr [eax]\n"
|
||||
"call %[WeaponProhibitsFistShake]\n"
|
||||
"add esp, 4\n"
|
||||
"test al, al\n"
|
||||
"ret"
|
||||
:: [WeaponProhibitsFistShake] "i" (WeaponProhibitsFistShake)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<std::size_t Index>
|
||||
|
|
Loading…
Reference in a new issue