Bomb ownership bug fix in III/VC + small corrections

Project fixes
This commit is contained in:
Silent 2017-09-27 23:12:05 +02:00
parent a545d5f28f
commit 32fa0c9e51
23 changed files with 515 additions and 269 deletions

View File

@ -59,7 +59,15 @@
<Import Project="versionmeta.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>ddraw</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">
<TargetName>ddraw</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>ddraw</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
@ -150,7 +158,7 @@ copy /y "$(TargetPath)" "D:\Steam\steamapps\common\Grand Theft Auto Vice City\dd
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\Common.cpp" />
<ClCompile Include="..\SilentPatch\Common_ddraw.cpp" />
<ClCompile Include="..\SilentPatch\Patterns.cpp" />
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
@ -158,7 +166,7 @@ copy /y "$(TargetPath)" "D:\Steam\steamapps\common\Grand Theft Auto Vice City\dd
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\Common.h" />
<ClInclude Include="..\SilentPatch\Common_ddraw.h" />
<ClInclude Include="..\SilentPatch\MemoryMgr.h" />
<ClInclude Include="..\SilentPatch\Patterns.h" />
</ItemGroup>

View File

@ -21,7 +21,7 @@
<ClCompile Include="..\SilentPatch\Patterns.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Common.cpp">
<ClCompile Include="..\SilentPatch\Common_ddraw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@ -32,7 +32,7 @@
<ClInclude Include="..\SilentPatch\Patterns.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Common.h">
<ClInclude Include="..\SilentPatch\Common_ddraw.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

View File

@ -9,7 +9,7 @@
#include "MemoryMgr.h"
#include "Patterns.h"
#include "Common.h"
#include "Common_ddraw.h"
#pragma comment(lib, "shlwapi.lib")

View File

@ -1,200 +1,24 @@
#include "Common.h"
#include <Shlwapi.h>
#include <ShlObj.h>
#include "MemoryMgr.h"
#include "Patterns.h"
#pragma comment(lib, "shlwapi.lib")
extern char** ppUserFilesDir;
#include "StoredCar.h"
namespace Common {
char* GetMyDocumentsPath()
{
static char cUserFilesPath[MAX_PATH];
if ( cUserFilesPath[0] == '\0' )
{
SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath);
PathAppendA(cUserFilesPath, *ppUserFilesDir);
CreateDirectoryA(cUserFilesPath, nullptr);
}
return cUserFilesPath;
}
namespace Patches {
bool FixRwcseg_Patterns()
{
using namespace hook;
auto begin = pattern( "55 8B EC 50 53 51 52 8B 5D 14 8B 4D 10 8B 45 0C 8B 55 08" );
auto end = pattern( "9B D9 3D ? ? ? ? 81 25 ? ? ? ? FF FC FF FF 83 0D ? ? ? ? 3F" );
if ( begin.count_hint(1).size() == 1 && end.count_hint(1).size() == 1 )
{
const ptrdiff_t size = (intptr_t)end.get_first( 24 ) - (intptr_t)begin.get_first();
if ( size > 0 )
{
DWORD dwProtect;
VirtualProtect( begin.get_first(), size, PAGE_EXECUTE_READ, &dwProtect );
return true;
}
}
return false;
}
// ================= III =================
void DDraw_III_10( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580BB0, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x581E5E, desktop.right);
Patch<DWORD>(0x581E68, desktop.bottom);
Patch<BYTE>(0x581E72, 32);
Patch<const char*>(0x581EA8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581411, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x5812D6, 0xB8);
Patch<DWORD>(0x5812D7, 0x900);
}
void DDraw_III_11( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580F00, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x58219E, desktop.right);
Patch<DWORD>(0x5821A8, desktop.bottom);
Patch<BYTE>(0x5821B2, 32);
Patch<const char*>(0x5821E8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581753, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x581620, 0xB8);
Patch<DWORD>(0x581621, 0x900);
}
void DDraw_III_Steam( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580E00, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x58208E, desktop.right);
Patch<DWORD>(0x582098, desktop.bottom);
Patch<BYTE>(0x5820A2, 32);
Patch<const char*>(0x5820D8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581653, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x581520, 0xB8);
Patch<DWORD>(0x581521, 0x900);
}
// ================= VC =================
void DDraw_VC_10( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x602240, GetMyDocumentsPath, PATCH_JUMP);
InjectHook(0x601A40, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x601A45, 0x601B2F, PATCH_JUMP);
Patch<DWORD>(0x600E7E, desktop.right);
Patch<DWORD>(0x600E88, desktop.bottom);
Patch<BYTE>(0x600E92, 32);
Patch<const char*>(0x600EC8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601E26, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x601CA0, 0xB8);
Patch<DWORD>(0x601CA1, 0x900);
}
void DDraw_VC_11( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x602220, GetMyDocumentsPath, PATCH_JUMP);
InjectHook(0x601A70, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x601A75, 0x601B5F, PATCH_JUMP);
Patch<DWORD>(0x600E9E, desktop.right);
Patch<DWORD>(0x600EA8, desktop.bottom);
Patch<BYTE>(0x600EB2, 32);
Patch<const char*>(0x600EE8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601E56, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x601CD0, 0xB8);
Patch<DWORD>(0x601CD1, 0x900);
}
void DDraw_VC_Steam( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x601E60, GetMyDocumentsPath, PATCH_JUMP);
InjectHook(0x6016B0, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x6016B5, 0x60179F, PATCH_JUMP);
Patch<DWORD>(0x600ADE, desktop.right);
Patch<DWORD>(0x600AE8, desktop.bottom);
Patch<BYTE>(0x600AF2, 32);
Patch<const char*>(0x600B28, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601A96, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x601910, 0xB8);
Patch<DWORD>(0x601911, 0x900);
}
// ================= COMMON =================
void DDraw_Common()
void III_VC_Common()
{
using namespace Memory;
using namespace hook;
// Remove FILE_FLAG_NO_BUFFERING from CdStreams
// Fixed bomb ownership/bombs saving for bikes
{
auto mem = pattern( "81 7C 24 04 00 08 00 00" ).count_hint(1);
if ( mem.size() == 1 )
{
Patch<uint8_t>( mem.get_first( 0x12 ), 0xEB );
}
}
// No censorships
{
auto addr = pattern( "83 FB 07 74 0A 83 FD 07 74 05 83 FE 07 75 15" ).count_hint(1);
if ( addr.size() == 1 )
{
Patch( addr.get_first(), { 0xEB, 0x5E } );
}
auto addr = get_pattern( "83 3C 33 00 74 19 89 F9 E8", 8 );
void* pRestoreCar;
ReadCall( addr, pRestoreCar );
CStoredCar::orgRestoreCar = *(decltype(CStoredCar::orgRestoreCar)*)&pRestoreCar;
InjectHook( addr, &CStoredCar::RestoreCar_SilentPatch );
}
}
}

View File

@ -1,27 +1,9 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#define NOMINMAX
#include <windows.h>
namespace Common
{
namespace Patches
{
bool FixRwcseg_Patterns();
void DDraw_III_10( const RECT& desktop, const char* desktopText );
void DDraw_III_11( const RECT& desktop, const char* desktopText );
void DDraw_III_Steam( const RECT& desktop, const char* desktopText );
void DDraw_VC_10( const RECT& desktop, const char* desktopText );
void DDraw_VC_11( const RECT& desktop, const char* desktopText );
void DDraw_VC_Steam( const RECT& desktop, const char* desktopText );
void DDraw_Common();
void III_VC_Common();
}
};

View File

@ -0,0 +1,201 @@
#include "Common_ddraw.h"
#include <Shlwapi.h>
#include <ShlObj.h>
#include "MemoryMgr.h"
#include "Patterns.h"
#pragma comment(lib, "shlwapi.lib")
extern char** ppUserFilesDir;
namespace Common {
char* GetMyDocumentsPath()
{
static char cUserFilesPath[MAX_PATH];
if ( cUserFilesPath[0] == '\0' )
{
SHGetFolderPathA(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, cUserFilesPath);
PathAppendA(cUserFilesPath, *ppUserFilesDir);
CreateDirectoryA(cUserFilesPath, nullptr);
}
return cUserFilesPath;
}
namespace Patches {
bool FixRwcseg_Patterns()
{
using namespace hook;
auto begin = pattern( "55 8B EC 50 53 51 52 8B 5D 14 8B 4D 10 8B 45 0C 8B 55 08" );
auto end = pattern( "9B D9 3D ? ? ? ? 81 25 ? ? ? ? FF FC FF FF 83 0D ? ? ? ? 3F" );
if ( begin.count_hint(1).size() == 1 && end.count_hint(1).size() == 1 )
{
const ptrdiff_t size = (intptr_t)end.get_first( 24 ) - (intptr_t)begin.get_first();
if ( size > 0 )
{
DWORD dwProtect;
VirtualProtect( begin.get_first(), size, PAGE_EXECUTE_READ, &dwProtect );
return true;
}
}
return false;
}
// ================= III =================
void DDraw_III_10( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580BB0, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x581E5E, desktop.right);
Patch<DWORD>(0x581E68, desktop.bottom);
Patch<BYTE>(0x581E72, 32);
Patch<const char*>(0x581EA8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581411, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x5812D6, 0xB8);
Patch<DWORD>(0x5812D7, 0x900);
}
void DDraw_III_11( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580F00, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x58219E, desktop.right);
Patch<DWORD>(0x5821A8, desktop.bottom);
Patch<BYTE>(0x5821B2, 32);
Patch<const char*>(0x5821E8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581753, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x581620, 0xB8);
Patch<DWORD>(0x581621, 0x900);
}
void DDraw_III_Steam( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580E00, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x58208E, desktop.right);
Patch<DWORD>(0x582098, desktop.bottom);
Patch<BYTE>(0x5820A2, 32);
Patch<const char*>(0x5820D8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581653, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x581520, 0xB8);
Patch<DWORD>(0x581521, 0x900);
}
// ================= VC =================
void DDraw_VC_10( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x602240, GetMyDocumentsPath, PATCH_JUMP);
InjectHook(0x601A40, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x601A45, 0x601B2F, PATCH_JUMP);
Patch<DWORD>(0x600E7E, desktop.right);
Patch<DWORD>(0x600E88, desktop.bottom);
Patch<BYTE>(0x600E92, 32);
Patch<const char*>(0x600EC8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601E26, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x601CA0, 0xB8);
Patch<DWORD>(0x601CA1, 0x900);
}
void DDraw_VC_11( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x602220, GetMyDocumentsPath, PATCH_JUMP);
InjectHook(0x601A70, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x601A75, 0x601B5F, PATCH_JUMP);
Patch<DWORD>(0x600E9E, desktop.right);
Patch<DWORD>(0x600EA8, desktop.bottom);
Patch<BYTE>(0x600EB2, 32);
Patch<const char*>(0x600EE8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601E56, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x601CD0, 0xB8);
Patch<DWORD>(0x601CD1, 0x900);
}
void DDraw_VC_Steam( const RECT& desktop, const char* desktopText )
{
using namespace Memory;
InjectHook(0x601E60, GetMyDocumentsPath, PATCH_JUMP);
InjectHook(0x6016B0, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x6016B5, 0x60179F, PATCH_JUMP);
Patch<DWORD>(0x600ADE, desktop.right);
Patch<DWORD>(0x600AE8, desktop.bottom);
Patch<BYTE>(0x600AF2, 32);
Patch<const char*>(0x600B28, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601A96, 0xEB);
// No DirectPlay dependency
Patch<BYTE>(0x601910, 0xB8);
Patch<DWORD>(0x601911, 0x900);
}
// ================= COMMON =================
void DDraw_Common()
{
using namespace Memory;
using namespace hook;
// Remove FILE_FLAG_NO_BUFFERING from CdStreams
{
auto mem = pattern( "81 7C 24 04 00 08 00 00" ).count_hint(1);
if ( mem.size() == 1 )
{
Patch<uint8_t>( mem.get_first( 0x12 ), 0xEB );
}
}
// No censorships
{
auto addr = pattern( "83 FB 07 74 0A 83 FD 07 74 05 83 FE 07 75 15" ).count_hint(1);
if ( addr.size() == 1 )
{
Patch( addr.get_first(), { 0xEB, 0x5E } );
}
}
}
}
}

View File

@ -0,0 +1,27 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#define NOMINMAX
#include <windows.h>
namespace Common
{
namespace Patches
{
bool FixRwcseg_Patterns();
void DDraw_III_10( const RECT& desktop, const char* desktopText );
void DDraw_III_11( const RECT& desktop, const char* desktopText );
void DDraw_III_Steam( const RECT& desktop, const char* desktopText );
void DDraw_VC_10( const RECT& desktop, const char* desktopText );
void DDraw_VC_11( const RECT& desktop, const char* desktopText );
void DDraw_VC_Steam( const RECT& desktop, const char* desktopText );
void DDraw_Common();
}
};

View File

@ -34,4 +34,48 @@ public:
{}
};
class CVector
{
public:
float x, y, z;
CVector()
{}
constexpr CVector(float fX, float fY, float fZ=0.0f)
: x(fX), y(fY), z(fZ)
{}
CVector& operator+=(const CVector& vec)
{ x += vec.x; y += vec.y; z += vec.z;
return *this; }
CVector& operator-=(const CVector& vec)
{ x -= vec.x; y -= vec.y; z -= vec.z;
return *this; }
inline float Magnitude() const
{ return sqrt(x * x + y * y + z * z); }
inline constexpr float MagnitudeSqr() const
{ return x * x + y * y + z * z; }
inline CVector& Normalize()
{ float fInvLen = 1.0f / Magnitude(); x *= fInvLen; y *= fInvLen; z *= fInvLen; return *this; }
friend inline float DotProduct(const CVector& vec1, const CVector& vec2)
{ return vec1.x * vec2.x + vec1.x * vec2.y + vec1.z * vec2.z; }
friend inline CVector CrossProduct(const CVector& vec1, const CVector& vec2)
{ return CVector( vec1.y * vec2.z - vec1.z * vec2.y,
vec1.z * vec2.x - vec1.x * vec2.z,
vec1.x * vec2.y - vec1.y * vec2.x); }
friend inline CVector operator*(const CVector& in, float fMul)
{ return CVector(in.x * fMul, in.y * fMul, in.z * fMul); }
friend inline CVector operator+(const CVector& vec1, const CVector& vec2)
{ return CVector(vec1.x + vec2.x, vec1.y + vec2.y, vec1.z + vec2.z); }
friend inline CVector operator-(const CVector& vec1, const CVector& vec2)
{ return CVector(vec1.x - vec2.x, vec1.y - vec2.y, vec1.z - vec2.z); }
friend inline CVector operator-(const CVector& vec)
{ return CVector(-vec.x, -vec.y, -vec.z); }
};
#endif

View File

@ -10,47 +10,4 @@
#include "MemoryMgr.h"
class CVector
{
public:
float x, y, z;
CVector()
{}
constexpr CVector(float fX, float fY, float fZ=0.0f)
: x(fX), y(fY), z(fZ)
{}
CVector& operator+=(const CVector& vec)
{ x += vec.x; y += vec.y; z += vec.z;
return *this; }
CVector& operator-=(const CVector& vec)
{ x -= vec.x; y -= vec.y; z -= vec.z;
return *this; }
inline float Magnitude() const
{ return sqrt(x * x + y * y + z * z); }
inline constexpr float MagnitudeSqr() const
{ return x * x + y * y + z * z; }
inline CVector& Normalize()
{ float fInvLen = 1.0f / Magnitude(); x *= fInvLen; y *= fInvLen; z *= fInvLen; return *this; }
friend inline float DotProduct(const CVector& vec1, const CVector& vec2)
{ return vec1.x * vec2.x + vec1.x * vec2.y + vec1.z * vec2.z; }
friend inline CVector CrossProduct(const CVector& vec1, const CVector& vec2)
{ return CVector( vec1.y * vec2.z - vec1.z * vec2.y,
vec1.z * vec2.x - vec1.x * vec2.z,
vec1.x * vec2.y - vec1.y * vec2.x); }
friend inline CVector operator*(const CVector& in, float fMul)
{ return CVector(in.x * fMul, in.y * fMul, in.z * fMul); }
friend inline CVector operator+(const CVector& vec1, const CVector& vec2)
{ return CVector(vec1.x + vec2.x, vec1.y + vec2.y, vec1.z + vec2.z); }
friend inline CVector operator-(const CVector& vec1, const CVector& vec2)
{ return CVector(vec1.x - vec2.x, vec1.y - vec2.y, vec1.z - vec2.z); }
friend inline CVector operator-(const CVector& vec)
{ return CVector(-vec.x, -vec.y, -vec.z); }
};
#define DISABLE_FLA_DONATION_WINDOW 0

33
SilentPatch/StoredCar.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "StdAfx.h"
#include "StoredCar.h"
#include "Patterns.h"
#if _GTA_III
static auto FindPlayerPed = hook::get_pattern<class CEntity*()>( "6B C0 4F 8B 04 85 ? ? ? ? C3", -7 );
#elif _GTA_VC
static auto FindPlayerPed = hook::get_pattern<class CEntity*()>( "6B C0 2E 8B 04 C5 ? ? ? ? C3", -7 );
#endif
CVehicle* (CStoredCar::*CStoredCar::orgRestoreCar)();
CVehicle* CStoredCar::RestoreCar_SilentPatch()
{
CVehicle* vehicle = (this->*(orgRestoreCar))();
if ( vehicle == nullptr ) return nullptr;
if ( m_bombType != 0 )
{
// Fixup bomb stuff
#if _GTA_VC
if ( vehicle->GetClass() == VEHICLE_AUTOMOBILE || vehicle->GetClass() == VEHICLE_BIKE )
{
vehicle->SetBombOnBoard( m_bombType );
vehicle->SetBombOwner( FindPlayerPed() );
}
#elif _GTA_III
static_cast<CAutomobile*>(vehicle)->SetBombOwner( FindPlayerPed() );
#endif
}
return vehicle;
}

30
SilentPatch/StoredCar.h Normal file
View File

@ -0,0 +1,30 @@
#pragma once
#include "General.h"
#if _GTA_III
#include "../SilentPatchIII/VehicleIII.h"
#elif _GTA_VC
#include "../SilentPatchVC/VehicleVC.h"
#endif
class CStoredCar
{
private:
int32_t m_modelIndex;
CVector m_position;
CVector m_angle;
uint32_t m_handlingFlags;
uint8_t m_nPrimaryColor;
uint8_t m_nSecondaryColor;
int8_t m_nRadioStation;
int8_t m_anCompsToUse[2];
uint8_t m_bombType;
public:
static CVehicle* (CStoredCar::*orgRestoreCar)();
CVehicle* RestoreCar_SilentPatch();
};
static_assert(sizeof(CStoredCar) == 0x28, "Wrong size: CStoredCar");

View File

@ -4,6 +4,7 @@
#include "Timer.h"
#include "Patterns.h"
#include "Common.h"
#include "Common_ddraw.h"
#include <memory>
@ -813,7 +814,7 @@ void Patch_III_Common()
// For NICK007J
// Uncomment this to get rid of "treadable hack" in CCarCtrl::PickNextNodeToChaseCar (to mirror VC behaviour)
//InjectHook( funcAddr + 0x2A, funcAddr + 0x182, PATCH_JUMP );
InjectHook( funcAddr + 0x2A, funcAddr + 0x182, PATCH_JUMP );
}
@ -844,6 +845,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
else if (*(DWORD*)0x5C6FD5 == 0xB85548EC) Patch_III_Steam(desktop);
Patch_III_Common();
Common::Patches::III_VC_Common();
Common::Patches::DDraw_Common();
}

View File

@ -20,11 +20,17 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Common_ddraw.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Patterns.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\StoredCar.cpp" />
<ClCompile Include="..\SilentPatch\Timer.cpp" />
<ClCompile Include="SilentPatchIII.cpp" />
<ClCompile Include="StdAfxIII.cpp">
@ -34,11 +40,15 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\Common.h" />
<ClInclude Include="..\SilentPatch\Common_ddraw.h" />
<ClInclude Include="..\SilentPatch\General.h" />
<ClInclude Include="..\SilentPatch\MemoryMgr.h" />
<ClInclude Include="..\SilentPatch\Patterns.h" />
<ClInclude Include="..\SilentPatch\StdAfx.h" />
<ClInclude Include="..\SilentPatch\StoredCar.h" />
<ClInclude Include="..\SilentPatch\Timer.h" />
<ClInclude Include="VehicleIII.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc" />
@ -105,7 +115,7 @@
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;PATTERNS_USE_HINTS=1;_GTA_III;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\SilentPatch</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\SilentPatch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
@ -140,7 +150,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;PATTERNS_USE_HINTS=1;_GTA_III;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\SilentPatch</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\SilentPatch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
@ -177,7 +187,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;PATTERNS_USE_HINTS=1;_GTA_III;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\SilentPatch</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\SilentPatch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>

View File

@ -30,6 +30,12 @@
<ClCompile Include="..\SilentPatch\Common.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Common_ddraw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\StoredCar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\MemoryMgr.h">
@ -47,6 +53,18 @@
<ClInclude Include="..\SilentPatch\Patterns.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="VehicleIII.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Common_ddraw.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\StoredCar.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

View File

@ -0,0 +1,44 @@
#pragma once
#include <cstdint>
enum eVehicleType
{
VEHICLE_AUTOMOBILE,
VEHICLE_BOAT,
VEHICLE_TRAIN,
VEHICLE_HELI,
VEHICLE_PLANE
};
class CVehicle
{
private:
uint8_t __pad1[644];
uint32_t m_dwVehicleClass;
public:
uint32_t GetClass() const
{ return m_dwVehicleClass; }
};
class CAutomobile : public CVehicle
{
private:
uint8_t __pad2[593];
uint8_t m_BombOnBoard : 3;
class CEntity* m_pBombOwner;
uint8_t __pad33[200];
public:
void SetBombOnBoard( uint32_t bombOnBoard )
{ m_BombOnBoard = bombOnBoard; }
void SetBombOwner( class CEntity* owner )
{ m_pBombOwner = owner; }
};
static_assert(sizeof(CVehicle) == 0x288, "Wrong size: CVehicle");
static_assert(sizeof(CAutomobile) == 0x5A8, "Wrong size: CAutomobile");

View File

@ -88,7 +88,6 @@ public:
};
// Type definitions for specific pool types
#include "General.h"
typedef CPool<class CObject, uint8_t[0x19C]> CObjectPool;

View File

@ -76,7 +76,7 @@
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;_GTA_SA;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;..\SilentPatch;$(DXSDK_DIR)\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;..\SilentPatch;$(DXSDK_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfxSA.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
@ -114,7 +114,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;_GTA_SA;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;..\SilentPatch;$(DXSDK_DIR)\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;..\SilentPatch;$(DXSDK_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfxSA.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
@ -154,7 +154,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;_GTA_SA;NDEBUG;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;..\SilentPatch;$(DXSDK_DIR)\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>D:\RWSDK\Graphics\rwsdk\include\d3d9;..\SilentPatch;$(DXSDK_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfxSA.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>

View File

@ -466,12 +466,16 @@ void CAutomobile::ProcessNewsvan()
CVehicle* CStoredCar::RestoreCar_SilentPatch()
{
CVehicle* vehicle = (this->*(orgRestoreCar))();
if ( vehicle == nullptr ) return nullptr;
// Fixup bomb stuff
if ( vehicle->GetClass() == VEHICLE_AUTOMOBILE || vehicle->GetClass() == VEHICLE_BIKE )
if ( m_bombType != 0 )
{
vehicle->SetBombOnBoard( m_bombType );
vehicle->SetBombOwner( FindPlayerPed(-1) );
// Fixup bomb stuff
if ( vehicle->GetClass() == VEHICLE_AUTOMOBILE || vehicle->GetClass() == VEHICLE_BIKE )
{
vehicle->SetBombOnBoard( m_bombType );
vehicle->SetBombOwner( FindPlayerPed(-1) );
}
}
return vehicle;

View File

@ -128,8 +128,8 @@ protected:
float m_fGasPedal;
float m_fBrakePedal;
uint8_t m_VehicleCreatedBy;
uint32_t m_BombOnBoard : 3;
BYTE __pad6[32];
uint8_t m_BombOnBoard : 3;
BYTE __pad6[35];
CEntity* m_pBombOwner;
signed int m_nTimeTillWeNeedThisCar;
BYTE __pad4[56];

View File

@ -3,6 +3,8 @@
#include "Timer.h"
#include "Patterns.h"
#include "Common.h"
#include "Common_ddraw.h"
#include "General.h"
#include <memory>
@ -659,6 +661,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
else if (*(DWORD*)0x601048 == 0x5E5F5D60) Patch_VC_JP();
Patch_VC_Common();
Common::Patches::III_VC_Common();
Common::Patches::DDraw_Common();
}

View File

@ -76,7 +76,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;PATTERNS_USE_HINTS=1;_GTA_VC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>..\SilentPatch</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\SilentPatch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
@ -109,7 +109,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\SilentPatch</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\SilentPatch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
@ -144,7 +144,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\SilentPatch</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\SilentPatch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
@ -168,11 +168,14 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\Common_ddraw.h" />
<ClInclude Include="..\SilentPatch\General.h" />
<ClInclude Include="..\SilentPatch\MemoryMgr.h" />
<ClInclude Include="..\SilentPatch\Patterns.h" />
<ClInclude Include="..\SilentPatch\StdAfx.h" />
<ClInclude Include="..\SilentPatch\StoredCar.h" />
<ClInclude Include="..\SilentPatch\Timer.h" />
<ClInclude Include="VehicleVC.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\Common.cpp">
@ -180,11 +183,17 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Common_ddraw.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Patterns.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\StoredCar.cpp" />
<ClCompile Include="..\SilentPatch\Timer.cpp" />
<ClCompile Include="SilentPatchVC.cpp" />
<ClCompile Include="StdAfxVC.cpp">

View File

@ -30,6 +30,15 @@
<ClInclude Include="..\SilentPatch\Patterns.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\StoredCar.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="VehicleVC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Common_ddraw.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\Timer.cpp">
@ -47,6 +56,12 @@
<ClCompile Include="..\SilentPatch\Common.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\StoredCar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Common_ddraw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

36
SilentPatchVC/VehicleVC.h Normal file
View File

@ -0,0 +1,36 @@
#pragma once
#include <cstdint>
enum eVehicleType
{
VEHICLE_AUTOMOBILE,
VEHICLE_BOAT,
VEHICLE_TRAIN,
VEHICLE_HELI,
VEHICLE_PLANE,
VEHICLE_BIKE
};
class CVehicle
{
private:
uint8_t __pad1[510];
uint8_t m_BombOnBoard : 3;
uint8_t __pad2[17];
class CEntity* m_pBombOwner;
uint8_t __pad3[136];
uint32_t m_dwVehicleClass;
public:
uint32_t GetClass() const
{ return m_dwVehicleClass; }
void SetBombOnBoard( uint32_t bombOnBoard )
{ m_BombOnBoard = bombOnBoard; }
void SetBombOwner( class CEntity* owner )
{ m_pBombOwner = owner; }
};
static_assert(sizeof(CVehicle) == 0x2A0, "Wrong size: CVehicle");