mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
Merge branch 'fla-r28'
# Conflicts: # SilentPatch/TheFLAUtils.cpp # SilentPatch/TheFLAUtils.h # SilentPatchSA/ModelInfoSA.h
This commit is contained in:
commit
30190e74ef
6 changed files with 68 additions and 36 deletions
|
@ -3,17 +3,24 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = FLAUtils::GetExtendedID_Stock;
|
||||
int32_t (*FLAUtils::GetExtendedID8Func)(const void* ptr) = FLAUtils::GetExtendedID8_Stock;
|
||||
int32_t (*FLAUtils::GetExtendedID16Func)(const void* ptr) = FLAUtils::GetExtendedID16_Stock;
|
||||
|
||||
void FLAUtils::Init()
|
||||
{
|
||||
HMODULE hFLA = GetModuleHandle(TEXT("$fastman92limitAdjuster.asi"));
|
||||
HMODULE hFLA = GetModuleHandle("$fastman92limitAdjuster.asi");
|
||||
if ( hFLA != nullptr )
|
||||
{
|
||||
auto function = reinterpret_cast<decltype(GetExtendedIDFunc)>(GetProcAddress( hFLA, "GetExtendedIDfrom16bitBefore" ));
|
||||
if ( function != nullptr )
|
||||
auto function8 = reinterpret_cast<decltype(GetExtendedID8Func)>(GetProcAddress( hFLA, "GetExtendedIDfrom8bitBefore" ));
|
||||
if ( function8 != nullptr )
|
||||
{
|
||||
GetExtendedIDFunc = function;
|
||||
GetExtendedID8Func = function8;
|
||||
}
|
||||
|
||||
auto function16 = reinterpret_cast<decltype(GetExtendedID16Func)>(GetProcAddress( hFLA, "GetExtendedIDfrom16bitBefore" ));
|
||||
if ( function16 != nullptr )
|
||||
{
|
||||
GetExtendedID16Func = function16;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,21 +5,55 @@
|
|||
class FLAUtils
|
||||
{
|
||||
public:
|
||||
static int32_t GetExtendedID(const void* ptr)
|
||||
class int8
|
||||
{
|
||||
return GetExtendedIDFunc(ptr);
|
||||
private:
|
||||
int8() = delete;
|
||||
int8& operator =( const int8& ) = delete;
|
||||
|
||||
uint8_t value;
|
||||
};
|
||||
|
||||
class int16
|
||||
{
|
||||
private:
|
||||
int16() = delete;
|
||||
int16& operator =( const int16& ) = delete;
|
||||
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
static_assert( sizeof(int8) == sizeof(uint8_t) );
|
||||
static_assert( sizeof(int16) == sizeof(uint16_t) );
|
||||
|
||||
static int32_t GetExtendedID(const int8* ptr)
|
||||
{
|
||||
return GetExtendedID8Func(ptr);
|
||||
}
|
||||
|
||||
static int32_t GetExtendedID(const int16* ptr)
|
||||
{
|
||||
return GetExtendedID16Func(ptr);
|
||||
}
|
||||
|
||||
static void Init();
|
||||
|
||||
private:
|
||||
static const int32_t MAX_UINT16_ID = 0xFFFD;
|
||||
static constexpr int32_t MAX_UINT8_ID = 0xFF;
|
||||
static constexpr int32_t MAX_UINT16_ID = 0xFFFD;
|
||||
|
||||
static int32_t GetExtendedID_Stock(const void* ptr)
|
||||
static int32_t GetExtendedID8_Stock(const void* ptr)
|
||||
{
|
||||
uint8_t uID = *static_cast<const uint8_t*>(ptr);
|
||||
return uID == MAX_UINT8_ID ? -1 : uID;
|
||||
}
|
||||
|
||||
static int32_t GetExtendedID16_Stock(const void* ptr)
|
||||
{
|
||||
uint16_t uID = *static_cast<const uint16_t*>(ptr);
|
||||
return uID > MAX_UINT16_ID ? *static_cast<const int16_t*>(ptr) : uID;
|
||||
}
|
||||
|
||||
static int32_t (*GetExtendedIDFunc)(const void* ptr);
|
||||
static int32_t (*GetExtendedID8Func)(const void* ptr);
|
||||
static int32_t (*GetExtendedID16Func)(const void* ptr);
|
||||
};
|
|
@ -2,6 +2,7 @@
|
|||
#include "GeneralSA.h"
|
||||
|
||||
#include "PedSA.h"
|
||||
#include "ModelInfoSA.h"
|
||||
|
||||
// Wrappers
|
||||
static void* EntityRender = AddressByVersion<void*>(0x534310, 0x5347B0, 0x545B30);
|
||||
|
@ -12,19 +13,10 @@ WRAPPER void CShadowCamera::InvertRaster() { VARJMP(varInvertRaster); }
|
|||
|
||||
CWeaponInfo* (*CWeaponInfo::GetWeaponInfo)(eWeaponType, signed char) = AddressByVersion<CWeaponInfo*(*)(eWeaponType, signed char)>(0x743C60, 0x744490, 0x77D940);
|
||||
|
||||
static RwTexture*& ms_pRemapTexture = **AddressByVersion<RwTexture***>(0x59F1BD, 0x6D6E53, 0x5B811D);
|
||||
static unsigned char* ms_currentCol = *AddressByVersion<unsigned char**>(0x4C84C8, 0x4C86C8, 0x4D2DC8);
|
||||
static RwTexture*& ms_pRemapTexture = **AddressByVersion<RwTexture***>(0x59F1BD, 0x6D6E53, 0x5B811D);
|
||||
|
||||
auto SetEditableMaterialsCB = AddressByVersion<RpAtomic*(*)(RpAtomic*,void*)>(0x4C83E0, 0x4C8460, 0x4D2CE0);
|
||||
|
||||
static void SetVehicleColour(unsigned char primaryColour, unsigned char secondaryColour, unsigned char tertiaryColour, unsigned char quaternaryColour)
|
||||
{
|
||||
ms_currentCol[0] = primaryColour;
|
||||
ms_currentCol[1] = secondaryColour;
|
||||
ms_currentCol[2] = tertiaryColour;
|
||||
ms_currentCol[3] = quaternaryColour;
|
||||
}
|
||||
|
||||
static void ResetEditableMaterials(std::pair<void*,int>* pData)
|
||||
{
|
||||
for ( auto* i = pData; i->first != nullptr; i++ )
|
||||
|
@ -60,12 +52,15 @@ void CObject::Render()
|
|||
bool bCallRestore;
|
||||
std::pair<void*,int> materialRestoreData[16];
|
||||
|
||||
if ( FLAUtils::GetExtendedID( &m_wCarPartModelIndex ) != -1 && m_nObjectType == 3 && bObjectFlag7 && RwObjectGetType(m_pRwObject) == rpATOMIC )
|
||||
const int32_t carPartModelIndex = FLAUtils::GetExtendedID( &m_wCarPartModelIndex );
|
||||
if ( carPartModelIndex != -1 && m_nObjectType == 3 && bObjectFlag7 && RwObjectGetType(m_pRwObject) == rpATOMIC )
|
||||
{
|
||||
auto* pData = materialRestoreData;
|
||||
|
||||
ms_pRemapTexture = m_pPaintjobTex;
|
||||
SetVehicleColour(m_nCarColor[0], m_nCarColor[1], m_nCarColor[2], m_nCarColor[3]);
|
||||
|
||||
static_cast<CVehicleModelInfo*>(ms_modelInfoPtrs[ carPartModelIndex ])->SetVehicleColour( FLAUtils::GetExtendedID( &m_nCarColor[0] ),
|
||||
FLAUtils::GetExtendedID( &m_nCarColor[1] ), FLAUtils::GetExtendedID( &m_nCarColor[2] ), FLAUtils::GetExtendedID( &m_nCarColor[3] ) );
|
||||
|
||||
SetEditableMaterialsCB(reinterpret_cast<RpAtomic*>(m_pRwObject), &pData);
|
||||
pData->first = nullptr;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __GENERAL
|
||||
|
||||
#include <stdint.h>
|
||||
#include "TheFLAUtils.h"
|
||||
|
||||
class CSimpleTransform
|
||||
{
|
||||
|
@ -163,7 +164,7 @@ public:
|
|||
/********** END CFLAGS **************/
|
||||
|
||||
WORD RandomSeed; // 0x20
|
||||
unsigned short m_nModelIndex; // 0x22
|
||||
FLAUtils::int16 m_nModelIndex; // 0x22
|
||||
void* pReferences; // 0x24
|
||||
void* m_pLastRenderedLink; // 0x28
|
||||
WORD m_nScanCode; // 0x2C
|
||||
|
@ -179,12 +180,6 @@ public:
|
|||
//********* END CEntityInfo ************//
|
||||
|
||||
public:
|
||||
explicit inline CEntity(int dummy)
|
||||
: CPlaceable(dummy)
|
||||
{
|
||||
// Dummy ctor
|
||||
}
|
||||
|
||||
void UpdateRW();
|
||||
void RegisterReference(CEntity** pAddress);
|
||||
void CleanUpOldReference(CEntity** pAddress);
|
||||
|
@ -266,11 +261,6 @@ private:
|
|||
float fLighting; // 0x12C col lighting? CPhysical::GetLightingFromCol
|
||||
float fLighting_2; // 0x130 added to col lighting in CPhysical::GetTotalLighting
|
||||
BYTE pad3a[4]; // 0x134
|
||||
|
||||
public:
|
||||
// Temp
|
||||
CPhysical()
|
||||
: CEntity(0) {}
|
||||
};
|
||||
|
||||
class NOVMT CObject : public CPhysical
|
||||
|
@ -318,9 +308,9 @@ public:
|
|||
__int8 field_147;
|
||||
unsigned char m_nLastWeaponDamage;
|
||||
unsigned char m_nColBrightness;
|
||||
__int16 m_wCarPartModelIndex;
|
||||
FLAUtils::int16 m_wCarPartModelIndex;
|
||||
// this is used for detached car parts
|
||||
unsigned __int8 m_nCarColor[4];
|
||||
FLAUtils::int8 m_nCarColor[4];
|
||||
// time when this object must be deleted
|
||||
unsigned __int32 m_dwRemovalTime;
|
||||
float m_fHealth;
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
static void* BaseModelInfoShutdown = AddressByVersion<void*>(0x4C4D50, 0x4C4DD0, 0x4CF590);
|
||||
WRAPPER void CBaseModelInfo::Shutdown() { VARJMP(BaseModelInfoShutdown); }
|
||||
|
||||
// static unsigned char* ms_currentCol = *AddressByVersion<unsigned char**>(0x4C84C8, 0x4C86C8, 0x4D2DC8);
|
||||
static void* varSetVehicleColour = AddressByVersion<void*>( 0x4C84B0, 0, 0 ); // TODO: DO
|
||||
WRAPPER void CVehicleModelInfo::SetVehicleColour( int32_t color1, int32_t color2, int32_t color3, int32_t color4 ) { VARJMP(varSetVehicleColour); }
|
||||
|
||||
RwTexture* (*CCustomCarPlateMgr::CreatePlateTexture)(const char* pText, signed char nDesign) = AddressByVersion<RwTexture*(*)(const char*,signed char)>(0x6FDEA0, 0x6FE6D0, 0x736AC0);
|
||||
signed char (*CCustomCarPlateMgr::GetMapRegionPlateDesign)() = AddressByVersion<signed char(*)()>(0x6FD7A0, 0x6FDFD0, 0x7363E0);
|
||||
void (*CCustomCarPlateMgr::SetupMaterialPlatebackTexture)(RpMaterial* pMaterial, signed char nDesign) = AddressByVersion<void(*)(RpMaterial*,signed char)>(0x6FDE50, 0x6FE680, 0x736A80);
|
||||
|
|
|
@ -318,6 +318,8 @@ public:
|
|||
|
||||
void FindEditableMaterialList();
|
||||
void SetCarCustomPlate();
|
||||
void SetVehicleColour( int32_t color1, int32_t color2, int32_t color3, int32_t color4 );
|
||||
|
||||
};
|
||||
|
||||
extern CBaseModelInfo** const ms_modelInfoPtrs;
|
||||
|
|
Loading…
Reference in a new issue