2014-08-03 19:38:53 +06:00
|
|
|
#include "StdAfxSA.h"
|
2014-05-31 00:14:47 +06:00
|
|
|
#include "ModelInfoSA.h"
|
|
|
|
|
2014-08-22 04:10:23 +06:00
|
|
|
static void* BaseModelInfoShutdown = AddressByVersion<void*>(0x4C4D50, 0x4C4DD0, 0x4CF590);
|
2014-08-04 18:30:16 +06:00
|
|
|
WRAPPER void CBaseModelInfo::Shutdown() { VARJMP(BaseModelInfoShutdown); }
|
2014-06-23 06:37:03 +06:00
|
|
|
|
2018-02-11 00:04:12 +05:00
|
|
|
static void* varSetVehicleColour = AddressByVersion<void*>( 0x4C84B0, 0x4C86B0, 0x4D2DB0 );
|
2017-09-08 00:27:47 +05:00
|
|
|
WRAPPER void CVehicleModelInfo::SetVehicleColour( int32_t color1, int32_t color2, int32_t color3, int32_t color4 ) { VARJMP(varSetVehicleColour); }
|
|
|
|
|
2014-08-22 04:10:23 +06:00
|
|
|
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);
|
2014-06-23 06:37:03 +06:00
|
|
|
|
2017-04-27 19:17:38 +05:00
|
|
|
bool (*CCustomCarPlateMgr::GeneratePlateText)(char* pBuf, int nLen); // Read from InjectDelayedPatches
|
|
|
|
|
2014-08-22 04:10:23 +06:00
|
|
|
CBaseModelInfo** const ms_modelInfoPtrs = *AddressByVersion<CBaseModelInfo***>(0x509CB1, 0x4C0C96, 0x403DB7);
|
2014-08-13 02:30:37 +06:00
|
|
|
|
2019-12-28 04:13:27 +05:00
|
|
|
int8_t* CVehicleModelInfo::ms_compsUsed = *AddressByVersion<int8_t**>( 0x4C973B + 2, Memory::PatternAndOffset("8B CE A2 ? ? ? ? E8", 2 + 1) );
|
|
|
|
int8_t* CVehicleModelInfo::ms_compsToUse = *AddressByVersion<int8_t**>( 0x4C8057 + 2, Memory::PatternAndOffset("0F BE C0 C6 05 ? ? ? ? FE 5E", 3 + 2) );
|
2019-12-24 16:36:03 +05:00
|
|
|
|
2017-04-10 16:02:50 +05:00
|
|
|
|
2017-04-10 16:23:39 +05:00
|
|
|
static RwTexture** const ms_aDirtTextures = *AddressByVersion<RwTexture***>( 0x5D5DCC + 3, 0, 0x5F259C + 3 );
|
2017-04-10 16:02:50 +05:00
|
|
|
void RemapDirt( CVehicleModelInfo* modelInfo, uint32_t dirtID )
|
|
|
|
{
|
|
|
|
RpMaterial** materials = modelInfo->m_numDirtMaterials > CVehicleModelInfo::IN_PLACE_BUFFER_DIRT_SIZE ? modelInfo->m_dirtMaterials : modelInfo->m_staticDirtMaterials;
|
|
|
|
|
|
|
|
for ( size_t i = 0; i < modelInfo->m_numDirtMaterials; i++ )
|
|
|
|
{
|
|
|
|
RpMaterialSetTexture( materials[i], ms_aDirtTextures[dirtID] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-24 16:14:32 +05:00
|
|
|
uint32_t CVehicleModelInfo::GetNumRemaps() const
|
|
|
|
{
|
|
|
|
uint32_t count = 0;
|
|
|
|
while ( m_awRemapTxds[count].Get() != -1 && count < _countof(m_awRemapTxds) )
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2014-06-23 06:37:03 +06:00
|
|
|
void CVehicleModelInfo::Shutdown()
|
|
|
|
{
|
|
|
|
CBaseModelInfo::Shutdown();
|
|
|
|
|
2018-10-19 21:56:37 +05:00
|
|
|
delete[] m_dirtMaterials;
|
2017-04-10 16:02:50 +05:00
|
|
|
m_dirtMaterials = nullptr;
|
2014-06-23 06:37:03 +06:00
|
|
|
}
|
|
|
|
|
2014-05-31 00:14:47 +06:00
|
|
|
void CVehicleModelInfo::FindEditableMaterialList()
|
|
|
|
{
|
2017-04-10 16:02:50 +05:00
|
|
|
std::vector<RpMaterial*> editableMaterials;
|
2014-05-31 00:14:47 +06:00
|
|
|
|
2017-03-28 00:17:43 +05:00
|
|
|
auto GetEditableMaterialListCB = [&]( RpAtomic* atomic ) -> RpAtomic* {
|
|
|
|
RpGeometryForAllMaterials( RpAtomicGetGeometry(atomic), [&]( RpMaterial* material ) -> RpMaterial* {
|
|
|
|
if ( RwTexture* texture = RpMaterialGetTexture(material) )
|
|
|
|
{
|
|
|
|
if ( const char* texName = RwTextureGetName(texture) )
|
|
|
|
{
|
2018-12-04 02:09:14 +05:00
|
|
|
if ( strcmp(texName, "vehiclegrunge256") == 0 )
|
2017-03-28 00:17:43 +05:00
|
|
|
{
|
2017-04-10 16:02:50 +05:00
|
|
|
editableMaterials.push_back( material );
|
2017-03-28 00:17:43 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return material;
|
|
|
|
} );
|
|
|
|
return atomic;
|
|
|
|
};
|
|
|
|
|
|
|
|
RpClumpForAllAtomics(reinterpret_cast<RpClump*>(pRwObject), GetEditableMaterialListCB);
|
2014-05-31 00:14:47 +06:00
|
|
|
|
2017-04-10 02:17:31 +05:00
|
|
|
for ( uint32_t i = 0; i < m_pVehicleStruct->m_nNumExtras; i++ )
|
|
|
|
GetEditableMaterialListCB(m_pVehicleStruct->m_apExtras[i]);
|
2014-05-31 00:14:47 +06:00
|
|
|
|
2017-04-10 16:02:50 +05:00
|
|
|
m_numDirtMaterials = editableMaterials.size();
|
|
|
|
if ( m_numDirtMaterials > IN_PLACE_BUFFER_DIRT_SIZE )
|
|
|
|
{
|
|
|
|
m_dirtMaterials = new RpMaterial* [m_numDirtMaterials];
|
2024-01-29 00:50:58 +05:00
|
|
|
std::copy( editableMaterials.begin(), editableMaterials.end(), m_dirtMaterials );
|
2017-04-10 16:02:50 +05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_dirtMaterials = nullptr;
|
|
|
|
|
|
|
|
// Use existing space instead of allocating new space
|
|
|
|
std::copy( editableMaterials.begin(), editableMaterials.end(), m_staticDirtMaterials );
|
|
|
|
}
|
|
|
|
|
2014-05-31 00:14:47 +06:00
|
|
|
m_nPrimaryColor = -1;
|
|
|
|
m_nSecondaryColor = -1;
|
|
|
|
m_nTertiaryColor = -1;
|
|
|
|
m_nQuaternaryColor = -1;
|
|
|
|
}
|
|
|
|
|
2014-06-23 06:37:03 +06:00
|
|
|
void CVehicleModelInfo::SetCarCustomPlate()
|
|
|
|
{
|
|
|
|
m_plateText[0] = '\0';
|
|
|
|
m_nPlateType = -1;
|
|
|
|
}
|
|
|
|
|
2019-12-24 16:36:03 +05:00
|
|
|
void CVehicleModelInfo::ResetCompsForNoExtras()
|
|
|
|
{
|
|
|
|
ms_compsUsed[0] = ms_compsUsed[1] = -1;
|
|
|
|
ms_compsToUse[0] = ms_compsToUse[1] = -2;
|
|
|
|
}
|
|
|
|
|
2024-01-29 00:49:52 +05:00
|
|
|
void CCustomCarPlateMgr::SetupClumpAfterVehicleUpgrade(RpClump* pClump, void* /*unused*/, signed char nDesign)
|
2014-06-30 02:21:18 +06:00
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(nDesign);
|
2014-05-31 00:14:47 +06:00
|
|
|
}
|