Only hook DOUBLE_RHWEELS exception list if there are any entries listed in INI

This commit is contained in:
Silent 2017-09-12 16:14:07 +02:00
parent 7413bab68c
commit e4a3d81e81
2 changed files with 22 additions and 15 deletions

View file

@ -1074,9 +1074,11 @@ void DrawScriptSpritesAndRectangles( uint8_t arg )
} }
std::vector< std::pair<int32_t, bool> > doubleRearWheelsList; std::vector< std::pair<int32_t, bool> > doubleRearWheelsList;
void ReadDoubleRearWheels(const wchar_t* pPath) bool ReadDoubleRearWheels(const wchar_t* pPath)
{ {
const size_t SCRATCH_PAD_SIZE = 32767; bool listedAny = false;
constexpr size_t SCRATCH_PAD_SIZE = 32767;
WideDelimStringReader reader( SCRATCH_PAD_SIZE ); WideDelimStringReader reader( SCRATCH_PAD_SIZE );
GetPrivateProfileSectionW( L"DoubleRearWheels", reader.GetBuffer(), reader.GetSize(), pPath ); GetPrivateProfileSectionW( L"DoubleRearWheels", reader.GetBuffer(), reader.GetSize(), pPath );
@ -1100,8 +1102,10 @@ void ReadDoubleRearWheels(const wchar_t* pPath)
if ( begin != end ) if ( begin != end )
{ {
doubleRearWheelsList.emplace_back( toList, value ); doubleRearWheelsList.emplace_back( toList, value );
listedAny = true;
} }
} }
return listedAny;
} }
bool __stdcall CheckDoubleRWheelsList( void* modelInfo, uint8_t* handlingData ) bool __stdcall CheckDoubleRWheelsList( void* modelInfo, uint8_t* handlingData )
@ -2294,7 +2298,7 @@ BOOL InjectDelayedPatches_10()
bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr; bool bSARender = GetASIModuleHandleW(L"SARender") != nullptr;
ReadRotorFixExceptions(wcModulePath); ReadRotorFixExceptions(wcModulePath);
ReadDoubleRearWheels(wcModulePath); bool bHookDoubleRwheels = ReadDoubleRearWheels(wcModulePath);
if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == TRUE ) if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == TRUE )
{ {
@ -2492,6 +2496,20 @@ BOOL InjectDelayedPatches_10()
// to work fine with Deji's Custom Plate Format // to work fine with Deji's Custom Plate Format
ReadCall( 0x4C9484, CCustomCarPlateMgr::GeneratePlateText ); ReadCall( 0x4C9484, CCustomCarPlateMgr::GeneratePlateText );
if ( bHookDoubleRwheels )
{
// 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 );
}
// Adblocker // Adblocker
#if DISABLE_FLA_DONATION_WINDOW #if DISABLE_FLA_DONATION_WINDOW
if ( GetASIModuleHandleW(L"$fastman92limitAdjuster") != nullptr ) if ( GetASIModuleHandleW(L"$fastman92limitAdjuster") != nullptr )
@ -3431,17 +3449,6 @@ void Patch_SA_10()
InjectHook( 0x58C092, DrawScriptSpritesAndRectangles ); 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 );
// Properly initialize all CVehicleModelInfo fields // Properly initialize all CVehicleModelInfo fields
ReadCall( 0x4C75E4, orgVehicleModelInfoCtor ); ReadCall( 0x4C75E4, orgVehicleModelInfoCtor );
InjectHook( 0x4C75E4, VehicleModelInfoCtor ); InjectHook( 0x4C75E4, VehicleModelInfoCtor );

View file

@ -84,7 +84,7 @@ static RwFrame* GetFrameFromName( RwFrame* topFrame, const char* name )
void ReadRotorFixExceptions(const wchar_t* pPath) void ReadRotorFixExceptions(const wchar_t* pPath)
{ {
const size_t SCRATCH_PAD_SIZE = 32767; constexpr size_t SCRATCH_PAD_SIZE = 32767;
WideDelimStringReader reader( SCRATCH_PAD_SIZE ); WideDelimStringReader reader( SCRATCH_PAD_SIZE );
GetPrivateProfileSectionW( L"RotorFixExceptions", reader.GetBuffer(), reader.GetSize(), pPath ); GetPrivateProfileSectionW( L"RotorFixExceptions", reader.GetBuffer(), reader.GetSize(), pPath );