mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-11-22 13:32:36 +01:00
FLA 32-bit model IDs compatibility
This commit is contained in:
parent
1e69da6ce5
commit
3cde64abbc
15
SilentPatch/TheFLAUtils.cpp
Normal file
15
SilentPatch/TheFLAUtils.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "TheFLAUtils.h"
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = nullptr;
|
||||||
|
|
||||||
|
void FLAUtils::Init()
|
||||||
|
{
|
||||||
|
HMODULE hFLA = GetModuleHandle("$fastman92limitAdjuster.asi");
|
||||||
|
if ( hFLA != nullptr )
|
||||||
|
{
|
||||||
|
GetExtendedIDFunc = reinterpret_cast<decltype(GetExtendedIDFunc)>(GetProcAddress( hFLA, "GetExtendedIDfrom16bitBefore" ));
|
||||||
|
}
|
||||||
|
}
|
23
SilentPatch/TheFLAUtils.h
Normal file
23
SilentPatch/TheFLAUtils.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
class FLAUtils
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static int32_t GetExtendedID(const void* ptr)
|
||||||
|
{
|
||||||
|
if ( GetExtendedIDFunc != nullptr )
|
||||||
|
return GetExtendedIDFunc(ptr);
|
||||||
|
|
||||||
|
uint16_t uID = *static_cast<const uint16_t*>(ptr);
|
||||||
|
return uID > MAX_UINT16_ID ? *static_cast<const int16_t*>(ptr) : uID;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Init();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const int32_t MAX_UINT16_ID = 0xFFFD;
|
||||||
|
|
||||||
|
static int32_t (*GetExtendedIDFunc)(const void* ptr);
|
||||||
|
};
|
@ -62,7 +62,7 @@ void CObject::Render()
|
|||||||
bool bCallRestore;
|
bool bCallRestore;
|
||||||
std::pair<void*,int> materialRestoreData[16];
|
std::pair<void*,int> 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;
|
auto* pData = materialRestoreData;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ signed char (*CCustomCarPlateMgr::GetMapRegionPlateDesign)() = AddressByVersion<
|
|||||||
void (*CCustomCarPlateMgr::SetupMaterialPlatebackTexture)(RpMaterial* pMaterial, signed char nDesign) = AddressByVersion<void(*)(RpMaterial*,signed char)>(0x6FDE50, 0x6FE680, 0x736A80);
|
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);
|
CBaseModelInfo** const ms_modelInfoPtrs = *AddressByVersion<CBaseModelInfo***>(0x509CB1, 0x4C0C96, 0x403DB7);
|
||||||
const uint32_t m_numModelInfoPtrs = *AddressByVersion<uint16_t*>(0x4C5956+2, 0, 0);
|
const uint32_t m_numModelInfoPtrs = *AddressByVersion<uint32_t*>(0x4C5956+2, 0, 0);
|
||||||
|
|
||||||
void CVehicleModelInfo::Shutdown()
|
void CVehicleModelInfo::Shutdown()
|
||||||
{
|
{
|
||||||
|
@ -2310,6 +2310,7 @@ BOOL InjectDelayedPatches_10()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
FLAUtils::Init();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2529,6 +2530,7 @@ BOOL InjectDelayedPatches_11()
|
|||||||
Patch<DWORD>(0x5B9690, 15000);
|
Patch<DWORD>(0x5B9690, 15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLAUtils::Init();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2735,6 +2737,7 @@ BOOL InjectDelayedPatches_Steam()
|
|||||||
Patch<DWORD>(0x5D5780, 15000);
|
Patch<DWORD>(0x5D5780, 15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLAUtils::Init();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -120,6 +120,10 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\SilentPatch\TheFLAUtils.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="AudioHardwareSA.cpp" />
|
<ClCompile Include="AudioHardwareSA.cpp" />
|
||||||
<ClCompile Include="FLACDecoderSA.cpp" />
|
<ClCompile Include="FLACDecoderSA.cpp" />
|
||||||
<ClCompile Include="GeneralSA.cpp" />
|
<ClCompile Include="GeneralSA.cpp" />
|
||||||
@ -164,6 +168,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
|
|||||||
<ClInclude Include="..\SilentPatch\MemoryMgr.h" />
|
<ClInclude Include="..\SilentPatch\MemoryMgr.h" />
|
||||||
<ClInclude Include="..\SilentPatch\Patterns.h" />
|
<ClInclude Include="..\SilentPatch\Patterns.h" />
|
||||||
<ClInclude Include="..\SilentPatch\resource1.h" />
|
<ClInclude Include="..\SilentPatch\resource1.h" />
|
||||||
|
<ClInclude Include="..\SilentPatch\TheFLAUtils.h" />
|
||||||
<ClInclude Include="..\SilentPatch\Timer.h" />
|
<ClInclude Include="..\SilentPatch\Timer.h" />
|
||||||
<ClInclude Include="AudioHardwareSA.h" />
|
<ClInclude Include="AudioHardwareSA.h" />
|
||||||
<ClInclude Include="FLACDecoderSA.h" />
|
<ClInclude Include="FLACDecoderSA.h" />
|
||||||
|
@ -63,6 +63,9 @@
|
|||||||
<ClCompile Include="..\SilentPatch\Patterns.cpp">
|
<ClCompile Include="..\SilentPatch\Patterns.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\SilentPatch\TheFLAUtils.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\SilentPatch\MemoryMgr.h">
|
<ClInclude Include="..\SilentPatch\MemoryMgr.h">
|
||||||
@ -140,6 +143,9 @@
|
|||||||
<ClInclude Include="..\SilentPatch\DelimStringReader.h">
|
<ClInclude Include="..\SilentPatch\DelimStringReader.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\SilentPatch\TheFLAUtils.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="Shaders.rc">
|
<ResourceCompile Include="Shaders.rc">
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "MemoryMgr.h"
|
#include "MemoryMgr.h"
|
||||||
#include "Maths.h"
|
#include "Maths.h"
|
||||||
|
|
||||||
|
#include "TheFLAUtils.h"
|
||||||
|
|
||||||
// SA operator delete
|
// SA operator delete
|
||||||
extern void (*GTAdelete)(void* data);
|
extern void (*GTAdelete)(void* data);
|
||||||
extern const char* (*GetFrameNodeName)(RwFrame*);
|
extern const char* (*GetFrameNodeName)(RwFrame*);
|
||||||
|
@ -154,7 +154,7 @@ void CVehicle::CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo
|
|||||||
void CHeli::Render()
|
void CHeli::Render()
|
||||||
{
|
{
|
||||||
double dRotorsSpeed, dMovingRotorSpeed;
|
double dRotorsSpeed, dMovingRotorSpeed;
|
||||||
bool bDisplayRotors = !ShouldIgnoreRotor( m_nModelIndex );
|
bool bDisplayRotors = !ShouldIgnoreRotor( FLAUtils::GetExtendedID( &m_nModelIndex ) );
|
||||||
bool bHasMovingRotor = m_pCarNode[13] != nullptr && bDisplayRotors;
|
bool bHasMovingRotor = m_pCarNode[13] != nullptr && bDisplayRotors;
|
||||||
bool bHasMovingRotor2 = m_pCarNode[15] != nullptr && bDisplayRotors;
|
bool bHasMovingRotor2 = m_pCarNode[15] != nullptr && bDisplayRotors;
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ void CHeli::Render()
|
|||||||
void CPlane::Render()
|
void CPlane::Render()
|
||||||
{
|
{
|
||||||
double dRotorsSpeed, dMovingRotorSpeed;
|
double dRotorsSpeed, dMovingRotorSpeed;
|
||||||
bool bDisplayRotors = !ShouldIgnoreRotor( m_nModelIndex );
|
bool bDisplayRotors = !ShouldIgnoreRotor( FLAUtils::GetExtendedID( &m_nModelIndex ) );
|
||||||
bool bHasMovingProp = m_pCarNode[13] != nullptr && bDisplayRotors;
|
bool bHasMovingProp = m_pCarNode[13] != nullptr && bDisplayRotors;
|
||||||
bool bHasMovingProp2 = m_pCarNode[15] != nullptr && bDisplayRotors;
|
bool bHasMovingProp2 = m_pCarNode[15] != nullptr && bDisplayRotors;
|
||||||
|
|
||||||
@ -267,7 +267,8 @@ void CPlane::Fix_SilentPatch()
|
|||||||
{
|
{
|
||||||
// Reset bouncing panels
|
// Reset bouncing panels
|
||||||
// No reset on Vortex
|
// 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;
|
m_aBouncingPanel[i].m_nNodeIndex = -1;
|
||||||
}
|
}
|
||||||
@ -278,7 +279,8 @@ void CAutomobile::Fix_SilentPatch()
|
|||||||
ResetFrames();
|
ResetFrames();
|
||||||
|
|
||||||
// Reset bouncing panels
|
// 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
|
// Towtruck/Tractor fix
|
||||||
m_aBouncingPanel[i].m_nNodeIndex = -1;
|
m_aBouncingPanel[i].m_nNodeIndex = -1;
|
||||||
@ -287,7 +289,7 @@ void CAutomobile::Fix_SilentPatch()
|
|||||||
|
|
||||||
void CAutomobile::ResetFrames()
|
void CAutomobile::ResetFrames()
|
||||||
{
|
{
|
||||||
RpClump* pOrigClump = reinterpret_cast<RpClump*>(ms_modelInfoPtrs[m_nModelIndex]->pRwObject);
|
RpClump* pOrigClump = reinterpret_cast<RpClump*>(ms_modelInfoPtrs[ FLAUtils::GetExtendedID( &m_nModelIndex ) ]->pRwObject);
|
||||||
if ( pOrigClump )
|
if ( pOrigClump )
|
||||||
{
|
{
|
||||||
// Instead of setting frame rotation to (0,0,0) like R* did, obtain the original frame matrix from CBaseNodelInfo clump
|
// Instead of setting frame rotation to (0,0,0) like R* did, obtain the original frame matrix from CBaseNodelInfo clump
|
||||||
|
Loading…
Reference in New Issue
Block a user