From 22c484a9f91eedddf4ff211fc62b6699a5f683c1 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 20 Jun 2017 18:33:31 +0200 Subject: [PATCH] Merge fixes --- SilentPatch/TheFLAUtils.cpp | 2 +- SilentPatchSA/SilentPatchSA.cpp | 8 ++++---- SilentPatchSA/VehicleSA.cpp | 20 +++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/SilentPatch/TheFLAUtils.cpp b/SilentPatch/TheFLAUtils.cpp index 4a5e9d2..08fecda 100644 --- a/SilentPatch/TheFLAUtils.cpp +++ b/SilentPatch/TheFLAUtils.cpp @@ -7,7 +7,7 @@ int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = nullptr; void FLAUtils::Init() { - HMODULE hFLA = GetModuleHandle("$fastman92limitAdjuster.asi"); + HMODULE hFLA = GetModuleHandle(TEXT("$fastman92limitAdjuster.asi")); if ( hFLA != nullptr ) { GetExtendedIDFunc = reinterpret_cast(GetProcAddress( hFLA, "GetExtendedIDfrom16bitBefore" )); diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 39b1108..514bc23 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -1067,7 +1067,7 @@ void DrawScriptSpritesAndRectangles( uint8_t arg ) orgDrawScriptSpritesAndRectangles( arg ); } -std::vector< std::pair > doubleRearWheelsList; +std::vector< std::pair > doubleRearWheelsList; void ReadDoubleRearWheels(const wchar_t* pPath) { const size_t SCRATCH_PAD_SIZE = 32767; @@ -1083,8 +1083,8 @@ void ReadDoubleRearWheels(const wchar_t* pPath) wcscpy_s( textLine, str ); token = wcstok_s( textLine, L"=", &context ); - uint32_t toList = wcstoul( token, nullptr, 0 ); - if ( toList == 0 ) continue; + int32_t toList = wcstol( token, nullptr, 0 ); + if ( toList <= 0 ) continue; wchar_t* begin = wcstok_s( nullptr, L"=", &context ); if ( begin == nullptr ) continue; @@ -1106,7 +1106,7 @@ bool __stdcall CheckDoubleRWheelsList( void* modelInfo, uint8_t* handlingData ) if ( modelInfo == lastModelInfo ) return lastResult; lastModelInfo = modelInfo; - uint32_t modelID = std::distance( ms_modelInfoPtrs, std::find( ms_modelInfoPtrs, ms_modelInfoPtrs+m_numModelInfoPtrs, modelInfo ) ); + int32_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; diff --git a/SilentPatchSA/VehicleSA.cpp b/SilentPatchSA/VehicleSA.cpp index 5d33431..93bb54f 100644 --- a/SilentPatchSA/VehicleSA.cpp +++ b/SilentPatchSA/VehicleSA.cpp @@ -7,9 +7,9 @@ #include "TimerSA.h" #include "DelimStringReader.h" -std::vector vecRotorExceptions; +std::vector vecRotorExceptions; -static bool ShouldIgnoreRotor( uint32_t id ) +static bool ShouldIgnoreRotor( int32_t id ) { return std::find( vecRotorExceptions.begin(), vecRotorExceptions.end(), id ) != vecRotorExceptions.end(); } @@ -78,8 +78,8 @@ void ReadRotorFixExceptions(const wchar_t* pPath) GetPrivateProfileSectionW( L"RotorFixExceptions", reader.GetBuffer(), reader.GetSize(), pPath ); while ( const wchar_t* str = reader.GetString() ) { - uint32_t toList = wcstoul( str, nullptr, 0 ); - if ( toList != 0 ) + int32_t toList = wcstol( str, nullptr, 0 ); + if ( toList > 0 ) vecRotorExceptions.push_back( toList ); } } @@ -138,7 +138,7 @@ void CVehicle::CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo void CHeli::Render() { double dRotorsSpeed, dMovingRotorSpeed; - bool bDisplayRotors = !ShouldIgnoreRotor( m_nModelIndex ); + bool bDisplayRotors = !ShouldIgnoreRotor( FLAUtils::GetExtendedID( &m_nModelIndex ) ); bool bHasMovingRotor = m_pCarNode[13] != nullptr && bDisplayRotors; bool bHasMovingRotor2 = m_pCarNode[15] != nullptr && bDisplayRotors; @@ -190,7 +190,7 @@ void CHeli::Render() void CPlane::Render() { double dRotorsSpeed, dMovingRotorSpeed; - bool bDisplayRotors = !ShouldIgnoreRotor( m_nModelIndex ); + bool bDisplayRotors = !ShouldIgnoreRotor( FLAUtils::GetExtendedID( &m_nModelIndex ) ); bool bHasMovingProp = m_pCarNode[13] != nullptr && bDisplayRotors; bool bHasMovingProp2 = m_pCarNode[15] != nullptr && bDisplayRotors; @@ -243,7 +243,8 @@ void CPlane::Fix_SilentPatch() { // Reset bouncing panels // No reset on Vortex - for ( ptrdiff_t i = m_nModelIndex == 539 ? 1 : 0; i < 3; i++ ) + const int32_t extID = FLAUtils::GetExtendedID( &m_nModelIndex ); + for ( ptrdiff_t i = extID == 539 ? 1 : 0; i < 3; i++ ) { m_aBouncingPanel[i].m_nNodeIndex = -1; } @@ -254,7 +255,8 @@ void CAutomobile::Fix_SilentPatch() ResetFrames(); // Reset bouncing panels - for ( ptrdiff_t i = (m_nModelIndex == 525 && m_pCarNode[21]) || (m_nModelIndex == 531 && m_pCarNode[17]) ? 1 : 0; i < 3; i++ ) + const int32_t extID = FLAUtils::GetExtendedID( &m_nModelIndex ); + for ( ptrdiff_t i = (extID == 525 && m_pCarNode[21]) || (extID == 531 && m_pCarNode[17]) ? 1 : 0; i < 3; i++ ) { // Towtruck/Tractor fix m_aBouncingPanel[i].m_nNodeIndex = -1; @@ -263,7 +265,7 @@ void CAutomobile::Fix_SilentPatch() void CAutomobile::ResetFrames() { - RpClump* pOrigClump = reinterpret_cast(ms_modelInfoPtrs[m_nModelIndex]->pRwObject); + RpClump* pOrigClump = reinterpret_cast(ms_modelInfoPtrs[ FLAUtils::GetExtendedID( &m_nModelIndex ) ]->pRwObject); if ( pOrigClump != nullptr ) { // Instead of setting frame rotation to (0,0,0) like R* did, obtain the original frame matrix from CBaseNodelInfo clump