mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
Double rear wheels whitelist
This commit is contained in:
parent
b2c9b188b3
commit
9304b6a060
3 changed files with 63 additions and 0 deletions
|
@ -10,6 +10,7 @@ signed char (*CCustomCarPlateMgr::GetMapRegionPlateDesign)() = AddressByVersion<
|
|||
void (*CCustomCarPlateMgr::SetupMaterialPlatebackTexture)(RpMaterial* pMaterial, signed char nDesign) = AddressByVersion<void(*)(RpMaterial*,signed char)>(0x6FDE50, 0x6FE680, 0x736A80);
|
||||
|
||||
CBaseModelInfo** const ms_modelInfoPtrs = *AddressByVersion<CBaseModelInfo***>(0x509CB1, 0x4C0C96, 0x403DB7);
|
||||
const uint32_t m_numModelInfoPtrs = *AddressByVersion<uint16_t*>(0x4C5956+2, 0, 0);
|
||||
|
||||
void CVehicleModelInfo::Shutdown()
|
||||
{
|
||||
|
|
|
@ -298,6 +298,7 @@ public:
|
|||
};
|
||||
|
||||
extern CBaseModelInfo** const ms_modelInfoPtrs;
|
||||
extern const uint32_t m_numModelInfoPtrs;
|
||||
|
||||
#define NUM_MAX_PLATES 12
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "FLACDecoderSA.h"
|
||||
|
||||
#include "Patterns.h"
|
||||
#include "DelimStringReader.h"
|
||||
|
||||
// RW wrappers
|
||||
static void* varAtomicDefaultRenderCallBack = AddressByVersion<void*>(0x7491C0, 0x749AD0, 0x783180);
|
||||
|
@ -1030,6 +1031,55 @@ void DrawScriptSpritesAndRectangles( uint8_t arg )
|
|||
orgDrawScriptSpritesAndRectangles( arg );
|
||||
}
|
||||
|
||||
std::vector< std::pair<int32_t, bool> > doubleRearWheelsList;
|
||||
void ReadDoubleRearWheels(const wchar_t* pPath)
|
||||
{
|
||||
const size_t SCRATCH_PAD_SIZE = 32767;
|
||||
WideDelimStringReader reader( SCRATCH_PAD_SIZE );
|
||||
|
||||
GetPrivateProfileSectionW( L"DoubleRearWheels", reader.GetBuffer(), reader.GetSize(), pPath );
|
||||
while ( const wchar_t* str = reader.GetString() )
|
||||
{
|
||||
wchar_t textLine[32];
|
||||
wchar_t* context = nullptr;
|
||||
wchar_t* token;
|
||||
|
||||
wcscpy_s( textLine, str );
|
||||
token = wcstok_s( textLine, L"=", &context );
|
||||
|
||||
int toList = _wtoi( token );
|
||||
if ( toList != 0 )
|
||||
{
|
||||
bool value = _wtoi( wcstok_s( nullptr, L"=", &context ) ) != 0;
|
||||
doubleRearWheelsList.emplace_back( toList, value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool __stdcall CheckDoubleRWheelsList( void* modelInfo, uint8_t* handlingData )
|
||||
{
|
||||
static void* lastModelInfo = nullptr;
|
||||
static bool lastResult = false;
|
||||
|
||||
if ( modelInfo == lastModelInfo ) return lastResult;
|
||||
lastModelInfo = modelInfo;
|
||||
|
||||
ptrdiff_t modelID = std::distance( ms_modelInfoPtrs, std::find( ms_modelInfoPtrs, ms_modelInfoPtrs+m_numModelInfoPtrs, modelInfo ) );
|
||||
|
||||
auto it = std::find_if( doubleRearWheelsList.begin(), doubleRearWheelsList.end(), [modelID]( const auto& item ) {
|
||||
return item.first == modelID;
|
||||
} );
|
||||
if ( it == doubleRearWheelsList.end() )
|
||||
{
|
||||
uint32_t flags = *(uint32_t*)(handlingData+0xCC);
|
||||
lastResult = (flags & 0x20000000) != 0;
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
lastResult = it->second;
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
|
||||
#include <xnamath.h>
|
||||
|
||||
|
@ -2060,6 +2110,7 @@ BOOL InjectDelayedPatches_10()
|
|||
bool bSARender = GetModuleHandle("SARender.asi") != nullptr;
|
||||
|
||||
ReadRotorFixExceptions(wcModulePath);
|
||||
ReadDoubleRearWheels(wcModulePath);
|
||||
|
||||
if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", FALSE, wcModulePath) != FALSE )
|
||||
{
|
||||
|
@ -3150,6 +3201,16 @@ void Patch_SA_10()
|
|||
ReadCall( 0x58C092, orgDrawScriptSpritesAndRectangles );
|
||||
InjectHook( 0x58C092, DrawScriptSpritesAndRectangles );
|
||||
|
||||
|
||||
// Double rwheels whitelist
|
||||
// push ecx
|
||||
// push edi
|
||||
// call CheckDoubleRWheelsWhitelist
|
||||
// test al, al
|
||||
Patch<uint16_t>( 0x4C9239, 0x5751 );
|
||||
InjectHook( 0x4C9239+2, CheckDoubleRWheelsList, PATCH_CALL );
|
||||
Patch<uint16_t>( 0x4C9239+7, 0xC084 );
|
||||
Nop( 0x4C9239+9, 1 );
|
||||
}
|
||||
|
||||
void Patch_SA_11()
|
||||
|
|
Loading…
Reference in a new issue