diff --git a/SilentPatch/TheFLAUtils.cpp b/SilentPatch/TheFLAUtils.cpp new file mode 100644 index 0000000..4a5e9d2 --- /dev/null +++ b/SilentPatch/TheFLAUtils.cpp @@ -0,0 +1,15 @@ +#include "TheFLAUtils.h" + +#define WIN32_LEAN_AND_MEAN +#include + +int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = nullptr; + +void FLAUtils::Init() +{ + HMODULE hFLA = GetModuleHandle("$fastman92limitAdjuster.asi"); + if ( hFLA != nullptr ) + { + GetExtendedIDFunc = reinterpret_cast(GetProcAddress( hFLA, "GetExtendedIDfrom16bitBefore" )); + } +} \ No newline at end of file diff --git a/SilentPatch/TheFLAUtils.h b/SilentPatch/TheFLAUtils.h new file mode 100644 index 0000000..e41de87 --- /dev/null +++ b/SilentPatch/TheFLAUtils.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +class FLAUtils +{ +public: + static int32_t GetExtendedID(const void* ptr) + { + if ( GetExtendedIDFunc != nullptr ) + return GetExtendedIDFunc(ptr); + + uint16_t uID = *static_cast(ptr); + return uID > MAX_UINT16_ID ? *static_cast(ptr) : uID; + } + + static void Init(); + +private: + static const int32_t MAX_UINT16_ID = 0xFFFD; + + static int32_t (*GetExtendedIDFunc)(const void* ptr); +}; \ No newline at end of file diff --git a/SilentPatchSA/GeneralSA.cpp b/SilentPatchSA/GeneralSA.cpp index 93a686f..e352518 100644 --- a/SilentPatchSA/GeneralSA.cpp +++ b/SilentPatchSA/GeneralSA.cpp @@ -60,7 +60,7 @@ void CObject::Render() bool bCallRestore; std::pair materialRestoreData[16]; - if ( m_wCarPartModelIndex != -1 && m_nObjectType == 3 && bObjectFlag7 && RwObjectGetType(m_pRwObject) == rpATOMIC ) + if ( FLAUtils::GetExtendedID( &m_wCarPartModelIndex ) != -1 && m_nObjectType == 3 && bObjectFlag7 && RwObjectGetType(m_pRwObject) == rpATOMIC ) { auto* pData = materialRestoreData; diff --git a/SilentPatchSA/ModelInfoSA.cpp b/SilentPatchSA/ModelInfoSA.cpp index 97e7ff7..b76c17b 100644 --- a/SilentPatchSA/ModelInfoSA.cpp +++ b/SilentPatchSA/ModelInfoSA.cpp @@ -13,7 +13,7 @@ void (*CCustomCarPlateMgr::SetupMaterialPlatebackTexture)(RpMaterial* pMaterial, bool (*CCustomCarPlateMgr::GeneratePlateText)(char* pBuf, int nLen); // Read from InjectDelayedPatches CBaseModelInfo** const ms_modelInfoPtrs = *AddressByVersion(0x509CB1, 0x4C0C96, 0x403DB7); -const uint32_t m_numModelInfoPtrs = *AddressByVersion(0x4C5956+2, 0, 0); +const uint32_t m_numModelInfoPtrs = *AddressByVersion(0x4C5956+2, 0, 0); static RwTexture** const ms_aDirtTextures = *AddressByVersion( 0x5D5DCC + 3, 0, 0x5F259C + 3 ); diff --git a/SilentPatchSA/SilentPatchSA.vcxproj b/SilentPatchSA/SilentPatchSA.vcxproj index 26c0cfb..28cf04b 100644 --- a/SilentPatchSA/SilentPatchSA.vcxproj +++ b/SilentPatchSA/SilentPatchSA.vcxproj @@ -120,6 +120,10 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio NotUsing NotUsing + + NotUsing + NotUsing + @@ -164,6 +168,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio + diff --git a/SilentPatchSA/SilentPatchSA.vcxproj.filters b/SilentPatchSA/SilentPatchSA.vcxproj.filters index a44590d..7bee1c6 100644 --- a/SilentPatchSA/SilentPatchSA.vcxproj.filters +++ b/SilentPatchSA/SilentPatchSA.vcxproj.filters @@ -63,6 +63,9 @@ Source Files + + Source Files + @@ -140,6 +143,9 @@ Header Files + + Header Files + diff --git a/SilentPatchSA/StdAfxSA.h b/SilentPatchSA/StdAfxSA.h index b0d9ecd..debf404 100644 --- a/SilentPatchSA/StdAfxSA.h +++ b/SilentPatchSA/StdAfxSA.h @@ -23,6 +23,8 @@ #include "Maths.h" #include "rwpred.hpp" +#include "TheFLAUtils.h" + // SA operator delete extern void (*GTAdelete)(void* data); extern const char* (*GetFrameNodeName)(RwFrame*);