III/VC and SA files split

This commit is contained in:
Silent 2014-08-03 15:38:53 +02:00
parent f5ea953e95
commit b80846091f
25 changed files with 1664 additions and 581 deletions

View file

@ -1,11 +1,12 @@
#include "StdAfx.h"
#include "AudioHardware.h"
#include "StdAfxSA.h"
#include "AudioHardwareSA.h"
//WRAPPER HRESULT STDMETHODCALLTYPE CAEDataStream::Seek(LARGE_INTEGER liDistanceToMove, DWORD dwOrigin, ULARGE_INTEGER* lpNewFilePointer)
// { EAXJMP(0x4DC340); }
//WRAPPER HRESULT STDMETHODCALLTYPE CAEDataStream::Stat(STATSTG* pStatstg, DWORD grfStatFlag) { EAXJMP(0x4DC3A0); }
WRAPPER bool CAEDataStream::Initialise() { EAXJMP(0x4DC2B0); }
static void* CAEDataStream__Initialise = AddressByVersion<void*>(0x4DC2B0, 0, 0);
WRAPPER bool CAEDataStream::Initialise() { VARJMP(CAEDataStream__Initialise); }
unsigned int CAEStreamingDecoder::nMallocRefCount = 0;

View file

@ -1,5 +1,5 @@
#include "StdAfx.h"
#include "General.h"
#include "StdAfxSA.h"
#include "GeneralSA.h"
// Wrappers
WRAPPER bool CalcScreenCoors(const CVector& vecIn, CVector* vecOut) { WRAPARG(vecIn); WRAPARG(vecOut); EAXJMP(0x71DAB0); }
@ -31,7 +31,7 @@ static void ResetEditableMaterials(std::pair<void*,int>* pData)
void CObject::Render()
{
if ( m_bDoNotRender )
if ( m_bDoNotRender || !m_pRwObject )
return;
bool bCallRestore;

View file

@ -345,6 +345,9 @@ public:
float m_fParticlesIntensity;
public:
inline void Render_Stub()
{ CObject::Render(); }
virtual void Render() override;
};

View file

@ -2,13 +2,13 @@
#define __LINKLIST__
template <class T>
class CLink
class CLinkSA
{
public:
inline void Insert(CLink<T>* pAttach) {
inline void Insert(CLinkSA<T>* pAttach) {
pAttach->m_pNext = m_pNext;
m_pNext->m_pPrev = pAttach;
pAttach->m_pPrev = this;
m_pNext = pAttach;
}
@ -24,22 +24,22 @@ public:
T m_pItem; // 0-4
// an item
CLink<T>* m_pPrev; // 4-8
CLinkSA<T>* m_pPrev; // 4-8
//next link in the list
CLink<T>* m_pNext; // 8-12
CLinkSA<T>* m_pNext; // 8-12
//prev link in the list
};
template <class T>
class CLinkList {
class CLinkListSA {
public:
CLinkList(void)
CLinkListSA(void)
: m_plnLinks(nullptr)
{
}
void Init(int nNumLinks) {
m_plnLinks = new CLink<T>[nNumLinks];
m_plnLinks = new CLinkSA<T>[nNumLinks];
m_lnListHead.m_pNext = &m_lnListTail;
m_lnListTail.m_pPrev = &m_lnListHead;
@ -58,8 +58,8 @@ public:
m_plnLinks = nullptr;
}
CLink<T>* InsertSorted(const T& pItem) {
CLink<T>* pLink = m_lnFreeListHead.m_pNext;
CLinkSA<T>* InsertSorted(const T& pItem) {
CLinkSA<T>* pLink = m_lnFreeListHead.m_pNext;
if(pLink == &m_lnFreeListTail) {
return nullptr;
@ -69,7 +69,7 @@ public:
pLink->Remove();
CLink<T>* pInsertAfter = &m_lnListHead;
CLinkSA<T>* pInsertAfter = &m_lnListHead;
while(pInsertAfter->m_pNext != &m_lnListTail && pInsertAfter->m_pNext->m_pItem < pItem) {
pInsertAfter = pInsertAfter->m_pNext;
@ -80,8 +80,8 @@ public:
return pLink;
}
CLink<T>* Insert(const T& pItem) {
CLink<T>* pLink = m_lnFreeListHead.m_pNext;
CLinkSA<T>* Insert(const T& pItem) {
CLinkSA<T>* pLink = m_lnFreeListHead.m_pNext;
if(pLink == &m_lnFreeListTail) {
return nullptr;
@ -101,12 +101,12 @@ public:
}
}
void Remove(CLink<T>* pLink) {
void Remove(CLinkSA<T>* pLink) {
pLink->Remove();
m_lnFreeListHead.Insert(pLink);
}
CLink<T>* Next(CLink<T>* pCurrent) {
CLinkSA<T>* Next(CLinkSA<T>* pCurrent) {
if(pCurrent == 0) {
pCurrent = &m_lnListHead;
}
@ -119,15 +119,15 @@ public:
}
}
CLink<T> m_lnListHead; // 0-12
CLinkSA<T> m_lnListHead; // 0-12
//head of the list of active links
CLink<T> m_lnListTail; // 12-24
CLinkSA<T> m_lnListTail; // 12-24
//tail of the list of active links
CLink<T> m_lnFreeListHead; // 24-36
CLinkSA<T> m_lnFreeListHead; // 24-36
//head of the list of free links
CLink<T> m_lnFreeListTail; // 36-48
CLinkSA<T> m_lnFreeListTail; // 36-48
//tail of the list of free links
CLink<T>* m_plnLinks; // 48-52
CLinkSA<T>* m_plnLinks; // 48-52
//pointer to actual array of links
};

View file

@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "StdAfxSA.h"
#include "ModelInfoSA.h"
WRAPPER void CBaseModelInfo::Shutdown() { EAXJMP(0x4C4D50); }

View file

@ -1,7 +1,7 @@
#ifndef __MODELINFO
#define __MODELINFO
#include "General.h"
#include "GeneralSA.h"
// TODO: Move to a separate file?
typedef struct

View file

@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "StdAfxSA.h"
#include "PNGFile.h"
RwTexture* CPNGFile::ReadFromFile(const char* pFileName)

View file

@ -38,10 +38,10 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetExt>.dll</TargetExt>
<TargetExt>.asi</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetExt>.dll</TargetExt>
<TargetExt>.asi</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -49,8 +49,9 @@
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>SILENTPATCH_SA_VER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;C:\Program Files\Microsoft DirectX SDK (June 2010)\Include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;C:\Program Files\Microsoft DirectX SDK (June 2010)\Include;..\SilentPatch</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfxSA.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -74,8 +75,9 @@
<PreprocessorDefinitions>SILENTPATCH_SA_VER;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;..\SilentPatch</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfxSA.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -90,18 +92,18 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\dllmain.cpp" />
<ClCompile Include="..\SilentPatch\AudioHardware.cpp" />
<ClCompile Include="..\SilentPatch\General.cpp" />
<ClCompile Include="..\SilentPatch\ModelInfoSA.cpp" />
<ClCompile Include="..\SilentPatch\PNGFile.cpp" />
<ClCompile Include="..\SilentPatch\Script.cpp" />
<ClCompile Include="..\SilentPatch\StdAfx.cpp">
<ClCompile Include="AudioHardwareSA.cpp" />
<ClCompile Include="GeneralSA.cpp" />
<ClCompile Include="ModelInfoSA.cpp" />
<ClCompile Include="PNGFile.cpp" />
<ClCompile Include="ScriptSA.cpp" />
<ClCompile Include="SilentPatchSA.cpp" />
<ClCompile Include="StdAfxSA.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Timer.cpp" />
<ClCompile Include="..\SilentPatch\Vehicle.cpp" />
<ClCompile Include="TimerSA.cpp" />
<ClCompile Include="VehicleSA.cpp" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\SilentPatch\nvc.fx">
@ -116,23 +118,24 @@
<None Include="..\SilentPatch\win2000.asm" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\AudioHardware.h" />
<ClInclude Include="..\SilentPatch\FLAC\callback.h" />
<ClInclude Include="..\SilentPatch\FLAC\export.h" />
<ClInclude Include="..\SilentPatch\FLAC\format.h" />
<ClInclude Include="..\SilentPatch\FLAC\metadata.h" />
<ClInclude Include="..\SilentPatch\FLAC\ordinals.h" />
<ClInclude Include="..\SilentPatch\FLAC\stream_decoder.h" />
<ClInclude Include="..\SilentPatch\General.h" />
<ClInclude Include="..\SilentPatch\LinkList.h" />
<ClInclude Include="..\SilentPatch\Maths.h" />
<ClInclude Include="..\SilentPatch\MemoryMgr.h" />
<ClInclude Include="..\SilentPatch\ModelInfoSA.h" />
<ClInclude Include="..\SilentPatch\PNGFile.h" />
<ClInclude Include="..\SilentPatch\Script.h" />
<ClInclude Include="..\SilentPatch\StdAfx.h" />
<ClInclude Include="..\SilentPatch\Timer.h" />
<ClInclude Include="..\SilentPatch\Vehicle.h" />
<ClInclude Include="AudioHardwareSA.h" />
<ClInclude Include="GeneralSA.h" />
<ClInclude Include="LinkListSA.h" />
<ClInclude Include="Maths.h" />
<ClInclude Include="ModelInfoSA.h" />
<ClInclude Include="PNGFile.h" />
<ClInclude Include="ScriptSA.h" />
<ClInclude Include="StdAfxSA.h" />
<ClInclude Include="TimerSA.h" />
<ClInclude Include="VehicleSA.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -21,31 +21,31 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\dllmain.cpp">
<ClCompile Include="SilentPatchSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\General.cpp">
<ClCompile Include="StdAfxSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Vehicle.cpp">
<ClCompile Include="ScriptSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\StdAfx.cpp">
<ClCompile Include="TimerSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Timer.cpp">
<ClCompile Include="VehicleSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\ModelInfoSA.cpp">
<ClCompile Include="GeneralSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\PNGFile.cpp">
<ClCompile Include="ModelInfoSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\AudioHardware.cpp">
<ClCompile Include="AudioHardwareSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Script.cpp">
<ClCompile Include="PNGFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@ -58,30 +58,9 @@
<ClInclude Include="..\SilentPatch\MemoryMgr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\General.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Vehicle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\LinkList.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Maths.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\StdAfx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Timer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\ModelInfoSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\PNGFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\FLAC\callback.h">
<Filter>Header Files\FLAC</Filter>
</ClInclude>
@ -100,10 +79,34 @@
<ClInclude Include="..\SilentPatch\FLAC\stream_decoder.h">
<Filter>Header Files\FLAC</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\AudioHardware.h">
<ClInclude Include="StdAfxSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Script.h">
<ClInclude Include="ScriptSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimerSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="VehicleSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GeneralSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ModelInfoSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AudioHardwareSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LinkListSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Maths.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PNGFile.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

View file

@ -1,7 +1,7 @@
#include "StdAfx.h"
#include "Script.h"
#include "StdAfxSA.h"
#include "ScriptSA.h"
static int* StatTypesInt = *(int**)0x55C0D8;
static int* StatTypesInt = *AddressByVersion<int**>(0x55C0D8, 0, 0);
std::pair<int,int>* CRunningScript::GetDay_GymGlitch()
{

1393
SAFix/SilentPatchSA.cpp Normal file

File diff suppressed because it is too large Load diff

1
SAFix/StdAfxSA.cpp Normal file
View file

@ -0,0 +1 @@
#include "StdAfxSA.h"

View file

@ -11,12 +11,18 @@
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <utility>
#include <cassert>
#include <tuple>
#include <shlwapi.h>
/*#include <windows.h>
#include <limits>
#include <utility>
#include <mmsystem.h>
#include <Shlwapi.h>
#include <tuple>
#include <cassert>
#include <cassert>*/
#define RwEngineInstance (*rwengine)
#define RWFRAMESTATICPLUGINSSIZE 24
@ -25,11 +31,23 @@
#include <rpworld.h>
#include <rtpng.h>
#include <d3d9.h>
#include "MemoryMgr.h"
#include "Maths.h"
struct AlphaObjectInfo
{
RpAtomic* pAtomic;
RpAtomic* (*callback)(RpAtomic*, float);
float fCompareValue;
friend bool operator < (const AlphaObjectInfo &a, const AlphaObjectInfo &b)
{ return a.fCompareValue < b.fCompareValue; }
};
// SA operator delete
void GTAdelete(void* data);
extern void (*GTAdelete)(void* data);
extern unsigned char& nGameClockDays;
extern unsigned char& nGameClockMonths;

4
SAFix/TimerSA.cpp Normal file
View file

@ -0,0 +1,4 @@
#include "StdAfxSA.h"
#include "TimerSA.h"
int& CTimer::m_snTimeInMilliseconds = **AddressByVersion<int**>(0x4242D1, 0, 0);

10
SAFix/TimerSA.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef __TIMERSA
#define __TIMERSA
class CTimer
{
public:
static int& m_snTimeInMilliseconds;
};
#endif

View file

@ -1,7 +1,7 @@
#include "StdAfx.h"
#include "StdAfxSA.h"
#include "Vehicle.h"
#include "Timer.h"
#include "VehicleSA.h"
#include "TimerSA.h"
WRAPPER void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha) { WRAPARG(pAtomic); WRAPARG(nAlpha); EAXJMP(0x6D2960); }
WRAPPER void CVehicle::Render() { EAXJMP(0x6D0E60); }
@ -98,7 +98,7 @@ void CHeli::Render()
bool bHasMovingRotor = m_pCarNode[12] != nullptr;
bool bHasMovingRotor2 = m_pCarNode[14] != nullptr;
m_nTimeTillWeNeedThisCar = *CTimer::m_snTimeInMilliseconds + 3000;
m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000;
if ( m_fRotorSpeed > 0.0 )
dRotorsSpeed = min(1.7 * (1.0/0.22) * m_fRotorSpeed, 1.5);
@ -153,7 +153,7 @@ void CPlane::Render()
bool bHasMovingProp = m_pCarNode[12] != nullptr;
bool bHasMovingProp2 = m_pCarNode[14] != nullptr;
m_nTimeTillWeNeedThisCar = *CTimer::m_snTimeInMilliseconds + 3000;
m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000;
if ( m_fPropellerSpeed > 0.0 )
dRotorsSpeed = min(1.7 * (1.0/0.31) * m_fPropellerSpeed, 1.5);

View file

@ -1,7 +1,7 @@
#ifndef __VEHICLE
#define __VEHICLE
#include "General.h"
#include "GeneralSA.h"
#include "ModelInfoSA.h"
struct CVehicleFlags
@ -133,6 +133,9 @@ public:
class NOVMT CHeli : public CAutomobile
{
public:
inline void Render_Stub()
{ CHeli::Render(); }
virtual void Render() override;
};
@ -143,6 +146,9 @@ public:
float m_fPropellerSpeed;
public:
inline void Render_Stub()
{ CPlane::Render(); }
virtual void Render() override;
};

View file

@ -2,18 +2,14 @@
#define __MEMORYMGR
#define WRAPPER __declspec(naked)
#define DEPRECATED __declspec(deprecated)
#define EAXJMP(a) { _asm mov eax, a _asm jmp eax }
#define VARJMP(a) { _asm jmp a }
#define WRAPARG(a) UNREFERENCED_PARAMETER(a)
#define NOVMT __declspec(novtable)
#define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a
// A macro used to inject method pointers
#define InjectMethod(address, hook, nType) { void* __funcPtr; { _asm mov eax, offset hook _asm mov __funcPtr, eax } \
Memory::InjectHook(address, __funcPtr, nType); }
#define InjectMethodVP(address, hook, nType) { void* __funcPtr; { _asm mov eax, offset hook _asm mov __funcPtr, eax } \
MemoryVP::InjectHook(address, __funcPtr, nType); }
enum
{
PATCH_CALL,
@ -21,11 +17,88 @@ enum
PATCH_NOTHING,
};
inline signed char* GetVer()
{
static signed char bVer = -1;
return &bVer;
}
inline bool* GetEuropean()
{
static bool bEuropean;
return &bEuropean;
}
// This function initially detects SA version then chooses the address basing on game version
template<typename T>
inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
{
signed char* bVer = GetVer();
bool* bEuropean = GetEuropean();
if ( *bVer == -1 )
{
if ( *(DWORD*)0x82457C == 0x94BF )
{
*bVer = 0;
*bEuropean = false;
}
else if ( *(DWORD*)0x8245BC == 0x94BF )
{
*bVer = 0;
*bEuropean = true;
}
else if ( *(DWORD*)0x8252FC == 0x94BF )
{
*bVer = 1;
*bEuropean = false;
}
else if ( *(DWORD*)0x82533C == 0x94BF )
{
*bVer = 1;
*bEuropean = true;
}
else if (*(DWORD*)0x85EC4A == 0x94BF )
{
*bVer = 2;
*bEuropean = false;
}
}
switch ( *bVer )
{
case 1:
assert(address11);
// Adjust to EU if needed
if ( *bEuropean && address11 > 0x746FA0 )
{
if ( address11 < 0x7BB240 )
address11 += 0x50;
else
address11 += 0x40;
}
return (T)address11;
case 2:
assert(addressSteam);
return (T)addressSteam;
default:
assert(address10);
// Adjust to EU if needed
if ( *bEuropean && address10 > 0x7466D0 )
{
if ( address10 < 0x7BA940 )
address10 += 0x50;
else
address10 += 0x40;
}
return (T)address10;
}
}
namespace Memory
{
template<typename T, typename AT>
inline void Patch(AT address, T value)
{ *(T*)address = value; }
{*(T*)address = value; }
template<typename AT>
inline void Nop(AT address, unsigned int nCount)
@ -35,6 +108,13 @@ namespace Memory
template<typename AT, typename HT>
inline void InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING)
{
DWORD dwHook;
_asm
{
mov eax, hook
mov dwHook, eax
}
switch ( nType )
{
case PATCH_JUMP:
@ -44,7 +124,8 @@ namespace Memory
*(BYTE*)address = 0xE8;
break;
}
*(DWORD*)((DWORD)address + 1) = (DWORD)hook - (DWORD)address - 5;
*(DWORD*)((DWORD)address + 1) = dwHook - (DWORD)address - 5;
}
};
@ -87,7 +168,14 @@ namespace MemoryVP
VirtualProtect((void*)((DWORD)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]);
break;
}
*(DWORD*)((DWORD)address + 1) = (DWORD)hook - (DWORD)address - 5;
DWORD dwHook;
_asm
{
mov eax, hook
mov dwHook, eax
}
*(DWORD*)((DWORD)address + 1) = (DWORD)dwHook - (DWORD)address - 5;
if ( nType == PATCH_NOTHING )
VirtualProtect((void*)((DWORD)address + 1), 4, dwProtect[0], &dwProtect[1]);
else
@ -95,24 +183,4 @@ namespace MemoryVP
}
};
// Old code, remove asap
#define patch(a, v, s) _patch((void*)(a), (DWORD)(v), (s))
#define patchf(a, v) _patch((void*)(a), (float)(v))
#define nop(a, v) _nop((void*)(a), (v))
#define call(a, v, bAddCall) _call((void*)(a), (DWORD)(v), (bAddCall))
#define charptr(a, v) _charptr((void*)(a), (const char*)(v))
__declspec(deprecated) inline void _patch(void* pAddress, DWORD data, DWORD iSize)
{
switch(iSize)
{
case 1: *(BYTE*)pAddress = (BYTE)data;
break;
case 2: *(WORD*)pAddress = (WORD)data;
break;
case 4: *(DWORD*)pAddress = (DWORD)data;
break;
}
}
#endif

View file

@ -1 +0,0 @@
#include "StdAfx.h"

View file

@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "StdAfxSA.h"
#include "Timer.h"

View file

@ -1,6 +1,6 @@
#include "StdAfx.h"
#include "StdAfxSA.h"
#include "Timer.h"
//#include "Timer.h"
#include "General.h"
#include "Vehicle.h"
#include "LinkList.h"
@ -39,23 +39,6 @@ struct ClumpVisibilityPlugin
unsigned int alpha;
};
// RW wrappers
// TODO: Multiple EXEs
WRAPPER RwFrame* RwFrameForAllObjects(RwFrame* frame, RwObjectCallBack callBack, void* data) { WRAPARG(frame); WRAPARG(callBack); WRAPARG(data); EAXJMP(0x7F1200); }
WRAPPER RpClump* RpClumpForAllAtomics(RpClump* clump, RpAtomicCallBack callback, void* pData) { WRAPARG(clump); WRAPARG(callback); WRAPARG(pData); EAXJMP(0x749B70); }
WRAPPER RpGeometry* RpGeometryForAllMaterials(RpGeometry* geometry, RpMaterialCallBack fpCallBack, void* pData) { WRAPARG(geometry); WRAPARG(fpCallBack); WRAPARG(pData); EAXJMP(0x74C790); }
WRAPPER RpAtomic* AtomicDefaultRenderCallBack(RpAtomic* atomic) { WRAPARG(atomic); EAXJMP(0x7491C0); }
WRAPPER RwImage* RtPNGImageRead(const RwChar* imageName) { WRAPARG(imageName); EAXJMP(0x7CF9B0); }
WRAPPER RwTexture* RwTextureCreate(RwRaster* raster) { WRAPARG(raster); EAXJMP(0x7F37C0); }
WRAPPER RwRaster* RwRasterCreate(RwInt32 width, RwInt32 height, RwInt32 depth, RwInt32 flags) { WRAPARG(width); WRAPARG(height); WRAPARG(depth); WRAPARG(flags); EAXJMP(0x7FB230); }
WRAPPER RwRaster* RwRasterSetFromImage(RwRaster* raster, RwImage* image) { WRAPARG(raster); WRAPARG(image); EAXJMP(0x804290); }
WRAPPER RwBool RwImageDestroy(RwImage* image) { WRAPARG(image); EAXJMP(0x802740); }
WRAPPER RwImage* RwImageFindRasterFormat(RwImage* ipImage, RwInt32 nRasterType, RwInt32* npWidth, RwInt32* npHeight, RwInt32* npDepth, RwInt32* npFormat) { WRAPARG(ipImage); WRAPARG(nRasterType); WRAPARG(npWidth); WRAPARG(npHeight); WRAPARG(npDepth); WRAPARG(npFormat); EAXJMP(0x8042C0); }
WRAPPER RpMaterial *RpMaterialSetTexture(RpMaterial *material, RwTexture *texture) { EAXJMP(0x74DBC0); }
WRAPPER RwBool RwTextureDestroy(RwTexture* texture) { EAXJMP(0x7F3820); }
WRAPPER bool CanSeeOutSideFromCurrArea() { EAXJMP(0x53C4A0); }
#ifndef SA_STEAM_TEST
WRAPPER void RwD3D9SetRenderState(RwUInt32 state, RwUInt32 value) { WRAPARG(state); WRAPARG(value); EAXJMP(0x7FC2D0); }
@ -194,18 +177,16 @@ void __stdcall Recalculate(float& fX, float& fY, signed int nShadow)
#elif defined SILENTPATCH_SA_VER
static CLinkList<AlphaObjectInfo>& m_alphaList = **(CLinkList<AlphaObjectInfo>**)0x733A4D;
static CLinkList<CEntity*>& ms_weaponPedsForPC = **(CLinkList<CEntity*>**)0x53EACA;
static unsigned char* ZonesVisited = *(unsigned char**)0x57216A - 9;
static const float fRefZVal = 1.0f;
static const float* const pRefFal = &fRefZVal;
static RwInt32& clumpPluginOffset = **(RwInt32**)0x732202;
static bool& CCutsceneMgr__ms_running = **(bool**)0x53F92D;
#ifndef SA_STEAM_TEST
void** rwengine = *(void***)0x58FFC0;
#else
void** rwengine = (void**)0xD22E34;
#endif
@ -385,13 +366,19 @@ void RenderWeapon(CEntity* pEntity)
RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTIONREF, &nPushedAlpha);
RwRenderStateGet(rwRENDERSTATEALPHATESTFUNCTION, &nAlphaFunction);
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(255));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONEQUAL));
if ( nPushedAlpha != 255 )
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(255));
if ( nAlphaFunction != rwALPHATESTFUNCTIONEQUAL )
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(rwALPHATESTFUNCTIONEQUAL));
((void(*)(CEntity*))0x732F95)(pEntity);
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(nPushedAlpha));
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(nAlphaFunction));
if ( nPushedAlpha != 255 )
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, reinterpret_cast<void*>(nPushedAlpha));
if ( nAlphaFunction != rwALPHATESTFUNCTIONEQUAL )
RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTION, reinterpret_cast<void*>(nAlphaFunction));
ms_weaponPedsForPC.Insert(pEntity);
}
@ -1098,8 +1085,6 @@ static const BYTE gMoonMaskPNG[] = {
// TODO: EXEs
#ifndef SA_STEAM_TEST
unsigned char& nGameClockDays = **(unsigned char**)0x4E841D;
unsigned char& nGameClockMonths = **(unsigned char**)0x4E842D;
static float& fFarClipZ = **(float**)0x70D21F;
static RwTexture** const gpCoronaTexture = *(RwTexture***)0x6FAA8C;
static int& MoonSize = **(int**)0x713B0C;
@ -1163,28 +1148,28 @@ void DrawMoonWithPhases(int moonColor, float* screenPos, float sizeX, float size
//D3DPERF_EndEvent();
}
static void* HandleMoonStuffStub_JumpBack = AddressByVersion<void*>(0x713D24, 0, 0);
void __declspec(naked) HandleMoonStuffStub()
{
__asm
{
mov eax, [esp + 78h - 64h] // screen x size
mov ecx, [esp + 78h - 68h] // screen y size
mov eax, [esp + 78h - 64h] // screen x size
mov ecx, [esp + 78h - 68h] // screen y size
push ecx
push eax
push ecx
push eax
lea ecx, [esp + 80h - 54h] // screen coord vector
lea ecx, [esp + 80h - 54h] // screen coord vector
push ecx
push ecx
push esi
push esi
call DrawMoonWithPhases
call DrawMoonWithPhases
add esp, 10h
add esp, 10h
push 713D24h // TODO: EXEs
retn
jmp HandleMoonStuffStub_JumpBack
}
}
@ -1215,22 +1200,20 @@ void __declspec(naked) HandleMoonStuffStub_Steam()
static unsigned int nCachedCRC;
static void* RenderVehicleHiDetailCB = AddressByVersion<void*>(0x733240, 0, 0);
void __declspec(naked) HunterTest()
{
static const char aDoorDummy[] = "door_lf_ok";
static const char aStaticRotor[] = "static_rotor";
static const char aStaticRotor2[] = "static_rotor2";
static const char aWidescreen[] = "widescreen";
//static bool bToPleaseFuckingCargobob;
static const char aWindscreen[] = "windscreen";
_asm
{
//setnz di
setnz al
movzx di, al
//mov bToPleaseFuckingCargobob, al
push 10
push offset aWidescreen
push offset aWindscreen
push ebp
call strncmp
add esp, 0Ch
@ -1254,11 +1237,9 @@ void __declspec(naked) HunterTest()
jz HunterTest_StaticRotorAlphaSet
test di, di
//mov al, bToPleaseFuckingCargobob
//test al, al
jnz HunterTest_DoorTest
push 733240h
push [RenderVehicleHiDetailCB]
mov eax, 4C7914h
jmp eax
@ -1304,45 +1285,6 @@ void __declspec(naked) CacheCRC32()
}
}
void __declspec(naked) PlaneAtomicRendererSetup()
{
static const char aStaticProp[] = "static_prop";
static const char aMovingProp[] = "moving_prop";
_asm
{
mov eax, [esi+4]
push eax
call GetFrameNodeName
//push eax
mov [esp+8+8], eax
push 11
push offset aStaticProp
push eax
call strncmp
add esp, 10h
test eax, eax
jz PlaneAtomicRendererSetup_Alpha
push 11
push offset aMovingProp
push [esp+12+8]
call strncmp
add esp, 0Ch
test eax, eax
jnz PlaneAtomicRendererSetup_NoAlpha
PlaneAtomicRendererSetup_Alpha:
push 734370h
jmp PlaneAtomicRendererSetup_Return
PlaneAtomicRendererSetup_NoAlpha:
push 733420h
PlaneAtomicRendererSetup_Return:
mov eax, 4C7986h
jmp eax
}
}
// 1.0 only
static bool bDarkVehicleThing;
static RpLight*& pDirect = **(RpLight***)0x5BA573;
@ -1686,8 +1628,6 @@ void __declspec(naked) DumpIPLStub()
#endif
#include <d3d9.h>
#include "nvc.h"
static IDirect3DVertexShader9* pNVCShader = nullptr;
@ -1715,55 +1655,6 @@ static BOOL (*IsAlreadyRunning)();
static void (*TheScriptsLoad)();
static bool (*InitialiseRenderWare)();
bool ShaderAttach()
{
// CGame::InitialiseRenderWare
if ( InitialiseRenderWare() )
{
RwD3D9CreateVertexShader(reinterpret_cast<const RwUInt32*>(g_vs20_NVC_vertex_shader), reinterpret_cast<void**>(&pNVCShader));
return true;
}
return false;
}
void ShaderDetach()
{
if ( pNVCShader )
RwD3D9DeleteVertexShader(pNVCShader);
// PluginDetach?
// TODO: EXEs
((void(*)())0x53BB80)();
}
void SetShader(RxD3D9InstanceData* pInstData)
{
if ( bRenderNVC )
{
// TODO: Daynight balance var
D3DMATRIX outMat;
float fEnvVars[2] = { *(float*)0x8D12C0, RpMaterialGetColor(pInstData->material)->alpha * (1.0f/255.0f) };
RwRGBAReal* AmbientLight = RpLightGetColor(*(RpLight**)0xC886E8);
// Normalise the balance
if ( fEnvVars[0] < 0.0f )
fEnvVars[0] = 0.0f;
else if ( fEnvVars[0] > 1.0f )
fEnvVars[0] = 1.0f;
RwD3D9SetVertexShader(pNVCShader);
_rwD3D9VSSetActiveWorldMatrix(RwFrameGetLTM(RpAtomicGetFrame(pRenderedAtomic)));
_rwD3D9VSGetComposedTransformMatrix(&outMat);
RwD3D9SetVertexShaderConstant(0, &outMat, 4);
RwD3D9SetVertexShaderConstant(4, fEnvVars, 1);
RwD3D9SetVertexShaderConstant(5, AmbientLight, 1);
}
else
RwD3D9SetVertexShader(pInstData->vertexShader);
}
void __declspec(naked) SetShader2()
{
_asm
@ -1781,28 +1672,7 @@ void __declspec(naked) SetShader2()
}
}
void __declspec(naked) HijackAtomic()
{
_asm
{
mov eax, [esp+8]
mov pRenderedAtomic, eax
mov eax, 5D6480h
jmp eax
}
}
void __declspec(naked) UsageIndex1()
{
_asm
{
mov byte ptr [esp+eax*8+27h], 1
inc eax
push 5D611Bh
retn
}
}
static void* pJackedEsi;
@ -1883,20 +1753,6 @@ PassDayColoursToShader_Iterate:
}
}
void __declspec(naked) UserTracksFix()
{
_asm
{
push [esp+4]
mov eax, 4D7C60h
call eax
mov ecx, 0B6B970h
mov eax, 4F35B0h
call eax
retn 4
}
}
static CAEFLACDecoder* __stdcall DecoderCtor(CAEDataStream* pData)
{
return new CAEFLACDecoder(pData);
@ -1959,16 +1815,6 @@ LoadFLAC_Return_NoDelete:
}
}
static struct
{
char Extension[8];
unsigned int Codec;
} UserTrackExtensions[] = { { ".ogg", DECODER_VORBIS }, { ".mp3", DECODER_QUICKTIME },
{ ".wav", DECODER_WAVE }, { ".wma", DECODER_WINDOWSMEDIA },
{ ".wmv", DECODER_WINDOWSMEDIA }, { ".aac", DECODER_QUICKTIME },
{ ".m4a", DECODER_QUICKTIME }, { ".mov", DECODER_QUICKTIME },
{ ".fla", DECODER_FLAC }, { ".flac", DECODER_FLAC } };
void __declspec(naked) FLACInit()
{
_asm
@ -1984,88 +1830,6 @@ FLACInit_DontFallBack:
}
}
void __declspec(naked) LightMaterialsFix()
{
_asm
{
mov [esi], edi
mov ebx, [ecx]
lea esi, [edx+4]
mov [ebx+4], esi
mov edi, [esi]
mov [ebx+8], edi
add esi, 4
mov [ebx+12], esi
mov edi, [esi]
mov [ebx+16], edi
add ebx, 20
mov [ecx], ebx
retn
}
}
static unsigned char* ScriptSpace = *(unsigned char**)0x5D5380;
static int* ScriptParams = *(int**)0x48995B;
static CZoneInfo*& pCurrZoneInfo = **(CZoneInfo***)0x58ADB1;
static CRGBA* HudColour = *(CRGBA**)0x58ADF6;
static void BasketballFix(unsigned char* pBuf, int nSize)
{
for ( int i = 0, hits = 0; i < nSize && hits < 7; i++, pBuf++ )
{
// Pattern check for save pickup XYZ
if ( *(unsigned int*)pBuf == 0x449DE19A ) // Save pickup X
{
hits++;
*(float*)pBuf = 1291.8f;
}
else if ( *(unsigned int*)pBuf == 0xC4416AE1 ) // Save pickup Y
{
hits++;
*(float*)pBuf = -797.8284f;
}
else if ( *(unsigned int*)pBuf == 0x44886C7B ) // Save pickup Z
{
hits++;
*(float*)pBuf = 1089.5f;
}
else if ( *(unsigned int*)pBuf == 0x449DF852 ) // Save point X
{
hits++;
*(float*)pBuf = 1286.8f;
}
else if ( *(unsigned int*)pBuf == 0xC44225C3 ) // Save point Y
{
hits++;
*(float*)pBuf = -797.69f;
}
else if ( *(unsigned int*)pBuf == 0x44885C7B ) // Save point Z
{
hits++;
*(float*)pBuf = 1089.1f;
}
else if ( *(unsigned int*)pBuf == 0x43373AE1 ) // Save point A
{
hits++;
*(float*)pBuf = 90.0f;
}
}
}
void TheScriptsLoad_BasketballFix()
{
TheScriptsLoad();
BasketballFix(ScriptSpace+8, *(int*)(ScriptSpace+3));
}
void StartNewMission_BasketballFix()
{
if ( ScriptParams[0] == 0 )
BasketballFix(ScriptSpace+200000, 69000);
}
CRGBA* CRGBA::BlendGangColour(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
*this = Blend(CRGBA(r, g, b), pCurrZoneInfo->ZoneColour.a, HudColour[3], static_cast<BYTE>(255-pCurrZoneInfo->ZoneColour.a));
@ -2237,194 +2001,6 @@ BOOL InjectDelayedPatches_10()
return TRUE;
}
__forceinline void Patch_SA_10()
{
using namespace MemoryVP;
// IsAlreadyRunning needs to be read relatively late - the later, the better
IsAlreadyRunning = (BOOL(*)())(*(int*)0x74872E + 0x74872D + 5);
InjectHook(0x74872D, InjectDelayedPatches_10);
//Patch<BYTE>(0x5D7265, 0xEB);
// Temp
CTimer::m_snTimeInMilliseconds = *(int**)0x4242D1;
// Heli rotors
InjectMethodVP(0x6CAB70, CPlane::Render, PATCH_JUMP);
InjectMethodVP(0x6C4400, CHeli::Render, PATCH_JUMP);
//InjectHook(0x553318, RenderAlphaAtomics);
Patch<const void*>(0x7341D9, TwoPassAlphaRender);
Patch<const void*>(0x734127, TwoPassAlphaRender);
Patch<const void*>(0x73445E, RenderBigVehicleActomic);
//Patch<const void*>(0x73406E, TwoPassAlphaRender);
// Boats
/*Patch<BYTE>(0x4C79DF, 0x19);
Patch<DWORD>(0x733A87, EXPAND_BOAT_ALPHA_ATOMIC_LISTS * sizeof(AlphaObjectInfo));
Patch<DWORD>(0x733AD7, EXPAND_BOAT_ALPHA_ATOMIC_LISTS * sizeof(AlphaObjectInfo));*/
// Fixed strafing? Hopefully
/*static const float fStrafeCheck = 0.1f;
Patch<const void*>(0x61E0C2, &fStrafeCheck);
Nop(0x61E0CA, 6);*/
// RefFix
Patch<const void*>(0x6FB97A, &pRefFal);
Patch<BYTE>(0x6FB9A0, 0);
// Plane rotors
InjectHook(0x4C7981, PlaneAtomicRendererSetup, PATCH_JUMP);
// DOUBLE_RWHEELS
Patch<WORD>(0x4C9290, 0xE281);
Patch<int>(0x4C9292, ~(rwMATRIXTYPEMASK|rwMATRIXINTERNALIDENTITY));
// No framedelay
Patch<DWORD>(0x53E923, 0x42EB56);
// Disable re-initialization of DirectInput mouse device by the game
Patch<BYTE>(0x576CCC, 0xEB);
Patch<BYTE>(0x576EBA, 0xEB);
Patch<BYTE>(0x576F8A, 0xEB);
// Make sure DirectInput mouse device is set non-exclusive (may not be needed?)
Patch<DWORD>(0x7469A0, 0x909000B0);
// Weapons rendering
InjectHook(0x5E7859, RenderWeapon);
InjectHook(0x732F30, RenderWeaponsList, PATCH_JUMP);
//Patch<WORD>(0x53EAC4, 0x0DEB);
//Patch<WORD>(0x705322, 0x0DEB);
//Patch<WORD>(0x7271E3, 0x0DEB);
//Patch<BYTE>(0x73314E, 0xC3);
Patch<DWORD>(0x732F95, 0x560CEC83);
Patch<DWORD>(0x732FA2, 0x20245C8B);
Patch<WORD>(0x733128, 0x20EB);
Patch<WORD>(0x733135, 0x13EB);
Nop(0x732FBC, 5);
//Nop(0x732F93, 6);
//Nop(0x733144, 6);
Nop(0x732FA6, 6);
//Nop(0x5E46DA, 2);
// Hunter interior & static_rotor for helis
InjectHook(0x4C78F2, HunterTest, PATCH_JUMP);
InjectHook(0x4C9618, CacheCRC32);
// Fixed blown up car rendering
// ONLY 1.0
InjectHook(0x5D993F, DarkVehiclesFix1);
InjectHook(0x5D9A74, DarkVehiclesFix2, PATCH_JUMP);
InjectHook(0x5D9B44, DarkVehiclesFix3, PATCH_JUMP);
InjectHook(0x5D9CB2, DarkVehiclesFix4, PATCH_JUMP);
// Bindable NUM5
// Only 1.0 and Steam
Nop(0x57DC55, 2);
// Moonphases
InjectHook(0x713ACB, HandleMoonStuffStub, PATCH_JUMP);
// TEMP
//Patch<DWORD>(0x733B05, 40);
//Patch<DWORD>(0x733B55, 40);
//Patch<BYTE>(0x5B3ADD, 4);
// Twopass rendering (experimental)
/*Patch<WORD>(0x4C441E, 0x47C7);
Patch<BYTE>(0x4C4420, 0x48);
Patch<const void*>(0x4C4421, TwoPassAlphaRender);
Patch<DWORD>(0x4C4425, 0x04C25E5F);
Patch<BYTE>(0x4C4429, 0x00);*/
Patch<BYTE>(0x4C441E, 0x57);
InjectHook(0x4C441F, SetRendererForAtomic, PATCH_CALL);
Patch<DWORD>(0x4C4424, 0x5F04C483);
Patch<DWORD>(0x4C4428, 0x0004C25E);
// Lightbeam fix
Patch<WORD>(0x6A2E88, 0x0EEB);
Nop(0x6A2E9C, 3);
Patch<WORD>(0x6E0F63, 0x0AEB);
Patch<WORD>(0x6E0F7C, 0x0BEB);
Patch<WORD>(0x6E0F95, 0x0BEB);
Patch<WORD>(0x6E0FAF, 0x1AEB);
Patch<WORD>(0x6E13D5, 0x09EB);
Patch<WORD>(0x6E13ED, 0x17EB);
Patch<WORD>(0x6E141F, 0x0AEB);
Patch<BYTE>(0x6E0FE0, 0x28);
Patch<BYTE>(0x6E142D, 0x18);
Patch<BYTE>(0x6E0FDB, 0xC8-0x7C);
//InjectHook(0x6A2EDA, CullTest);
InjectHook(0x6A2EF7, ResetAlphaFuncRefAfterRender, PATCH_JUMP);
// PS2 SUN!!!!!!!!!!!!!!!!!
static const float fSunMult = (1050.0f * 0.95f) / 1500.0f;
Nop(0x6FB17C, 3);
Patch<const void*>(0x6FC5B0, &fSunMult);
//Patch<WORD>(0x6FB172, 0x0BEB);
//Patch<BYTE>(0x6FB1A7, 8);
#if defined EXPAND_ALPHA_ENTITY_LISTS
// Bigger alpha entity lists
Patch<DWORD>(0x733B05, EXPAND_ALPHA_ENTITY_LISTS * 20);
Patch<DWORD>(0x733B55, EXPAND_ALPHA_ENTITY_LISTS * 20);
#endif
// Unlocked widescreen resolutions
Patch<DWORD>(0x745B71, 0x9090687D);
Patch<DWORD>(0x74596C, 0x9090127D);
Nop(0x745970, 2);
Nop(0x745B75, 2);
Nop(0x7459E1, 2);
// Heap corruption fix
Nop(0x5C25D3, 5);
// User Tracks fix
InjectHook(0x4D9B66, UserTracksFix);
InjectHook(0x4D9BB5, 0x4F2FD0);
//Nop(0x4D9BB5, 5);
// FLAC support
InjectHook(0x4F373D, LoadFLAC, PATCH_JUMP);
InjectHook(0x4F35E0, FLACInit, PATCH_JUMP);
InjectHook(0x4F3787, CAEWaveDecoderInit);
Patch<WORD>(0x4F376A, 0x18EB);
//Patch<BYTE>(0x4F378F, sizeof(CAEWaveDecoder));
Patch<const void*>(0x4F3210, UserTrackExtensions);
Patch<const void*>(0x4F3241, &UserTrackExtensions->Codec);
//Patch<const void*>(0x4F35E7, &UserTrackExtensions[1].Codec);
Patch<BYTE>(0x4F322D, sizeof(UserTrackExtensions));
// Impound garages working correctly
InjectHook(0x425179, 0x448990);
InjectHook(0x425369, 0x448990);
InjectHook(0x425411, 0x448990);
// Impounding after busted works
Nop(0x443292, 5);
// Zones fix
InjectHook(0x572130, GetCurrentZoneLockedOrUnlocked, PATCH_JUMP);
// Fixed police scanner names
char* pScannerNames = *(char**)0x4E72D4;
strncpy(pScannerNames + (8*113), "WESTP", 8);
strncpy(pScannerNames + (8*134), "????", 8);
// TEMP - dumping IPL data
#ifdef DO_MAP_DUMP
InjectHook(0x538090, DumpIPLStub, PATCH_JUMP);
InjectHook(0x5B92C7, DumpIPLName);
#endif
}
__forceinline void Patch_SA_Steam()
{
using namespace MemoryVP;
@ -2462,6 +2038,4 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
RwD3D9DeleteVertexShader(pNVCShader);
}*/
return TRUE;
}
WRAPPER void GTAdelete(void* data) { EAXJMP(0x82413F); }
}