mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
A fix for numplates with tuningparts
This commit is contained in:
parent
b5e5d140f7
commit
d28ad95d5c
4 changed files with 91 additions and 10 deletions
|
@ -66,31 +66,57 @@ RpMaterial* CVehicleModelInfo::GetEditableMaterialListCB(RpMaterial* pMaterial,
|
||||||
return pMaterial;
|
return pMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: FIX IT
|
||||||
static RpMaterial* PollPlateData(RpMaterial* pMaterial, void* pData)
|
static RpMaterial* PollPlateData(RpMaterial* pMaterial, void* pData)
|
||||||
{
|
{
|
||||||
if ( RwTexture* pTexture = RpMaterialGetTexture(pMaterial) )
|
if ( RwTexture* pTexture = RpMaterialGetTexture(pMaterial) )
|
||||||
{
|
{
|
||||||
if ( RwTextureGetName(pTexture) )
|
const char* pTexName = RwTextureGetName(pTexture);
|
||||||
|
if ( pTexName )
|
||||||
{
|
{
|
||||||
if ( !_strnicmp(RwTextureGetName(pTexture), "carplate", 8) )
|
if ( !_strnicmp(pTexName, "carplate", 8) )
|
||||||
{
|
{
|
||||||
auto& pCallbackData = *static_cast<std::tuple<RpMaterial**,RpMaterial**,unsigned char,unsigned char>*>(pData);
|
auto& pCallbackData = *static_cast<std::tuple<RpMaterial**,RpMaterial**,unsigned char,unsigned char>*>(pData);
|
||||||
|
|
||||||
assert(std::get<2>(pCallbackData) < NUM_MAX_PLATES);
|
assert(std::get<2>(pCallbackData) < NUM_MAX_PLATES);
|
||||||
if ( std::get<2>(pCallbackData)++ < NUM_MAX_PLATES )
|
if ( std::get<2>(pCallbackData) < NUM_MAX_PLATES )
|
||||||
*(std::get<0>(pCallbackData)++) = pMaterial;
|
{
|
||||||
|
// Append data
|
||||||
|
for ( auto ptr = std::get<0>(pCallbackData); *ptr; ptr++ )
|
||||||
|
{
|
||||||
|
if ( *ptr == pMaterial )
|
||||||
|
return pMaterial;
|
||||||
}
|
}
|
||||||
else if ( !_strnicmp(RwTextureGetName(pTexture), "carpback", 8) )
|
|
||||||
|
while ( std::get<0>(pCallbackData)[std::get<2>(pCallbackData)] )
|
||||||
|
std::get<2>(pCallbackData)++;
|
||||||
|
|
||||||
|
std::get<0>(pCallbackData)[std::get<2>(pCallbackData)++] = pMaterial;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( !_strnicmp(pTexName, "carpback", 8) )
|
||||||
{
|
{
|
||||||
auto& pCallbackData = *static_cast<std::tuple<RpMaterial**,RpMaterial**,unsigned char,unsigned char>*>(pData);
|
auto& pCallbackData = *static_cast<std::tuple<RpMaterial**,RpMaterial**,unsigned char,unsigned char>*>(pData);
|
||||||
|
|
||||||
assert(std::get<3>(pCallbackData) < NUM_MAX_PLATES);
|
assert(std::get<3>(pCallbackData) < NUM_MAX_PLATES);
|
||||||
if ( std::get<3>(pCallbackData)++ < NUM_MAX_PLATES )
|
if ( std::get<3>(pCallbackData) < NUM_MAX_PLATES )
|
||||||
*(std::get<1>(pCallbackData)++) = pMaterial;
|
{
|
||||||
}
|
// Append data
|
||||||
}
|
for ( auto ptr = std::get<0>(pCallbackData); *ptr; ptr++ )
|
||||||
|
{
|
||||||
|
if ( *ptr == pMaterial )
|
||||||
|
return pMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while ( std::get<1>(pCallbackData)[std::get<3>(pCallbackData)] )
|
||||||
|
std::get<3>(pCallbackData)++;
|
||||||
|
|
||||||
|
std::get<1>(pCallbackData)[std::get<3>(pCallbackData)] = pMaterial;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return pMaterial;
|
return pMaterial;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +127,37 @@ static RpAtomic* PollPlateData(RpAtomic* pAtomic, void* pData)
|
||||||
return pAtomic;
|
return pAtomic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RpMaterial* SetPlateData(RpMaterial* pMaterial, void* pData)
|
||||||
|
{
|
||||||
|
if ( RwTexture* pTexture = RpMaterialGetTexture(pMaterial) )
|
||||||
|
{
|
||||||
|
if ( RwTextureGetName(pTexture) )
|
||||||
|
{
|
||||||
|
if ( !_strnicmp(RwTextureGetName(pTexture), "carplate", 8) )
|
||||||
|
{
|
||||||
|
auto& pCallbackData = *static_cast<std::pair<RwTexture*,signed char>*>(pData);
|
||||||
|
|
||||||
|
RpMaterialSetTexture(pMaterial, pCallbackData.first);
|
||||||
|
}
|
||||||
|
else if ( !_strnicmp(RwTextureGetName(pTexture), "carpback", 8) )
|
||||||
|
{
|
||||||
|
auto& pCallbackData = *static_cast<std::pair<RwTexture*,signed char>*>(pData);
|
||||||
|
|
||||||
|
CCustomCarPlateMgr::SetupMaterialPlatebackTexture(pMaterial, pCallbackData.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return pMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
static RpAtomic* SetPlateData(RpAtomic* pAtomic, void* pData)
|
||||||
|
{
|
||||||
|
RpGeometryForAllMaterials(RpAtomicGetGeometry(pAtomic), SetPlateData, pData);
|
||||||
|
return pAtomic;
|
||||||
|
}
|
||||||
|
|
||||||
void CCustomCarPlateMgr::SetupClump(RpClump* pClump, RpMaterial** pMatsArray)
|
void CCustomCarPlateMgr::SetupClump(RpClump* pClump, RpMaterial** pMatsArray)
|
||||||
{
|
{
|
||||||
// Split pMatsArray
|
// Split pMatsArray
|
||||||
|
@ -108,3 +165,22 @@ void CCustomCarPlateMgr::SetupClump(RpClump* pClump, RpMaterial** pMatsArray)
|
||||||
|
|
||||||
RpClumpForAllAtomics(pClump, PollPlateData, &CallbackData);
|
RpClumpForAllAtomics(pClump, PollPlateData, &CallbackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCustomCarPlateMgr::SetupClumpAfterVehicleUpgrade(RpClump* pClump, RpMaterial** pMatsArray, signed char nDesign)
|
||||||
|
{
|
||||||
|
UNREFERENCED_PARAMETER(nDesign);
|
||||||
|
if ( pMatsArray )
|
||||||
|
{
|
||||||
|
// Split pMatsArray
|
||||||
|
std::tuple<RpMaterial**,RpMaterial**,unsigned char,unsigned char> CallbackData = std::make_tuple(pMatsArray, pMatsArray+NUM_MAX_PLATES, 0, 0);
|
||||||
|
|
||||||
|
RpClumpForAllAtomics(pClump, PollPlateData, &CallbackData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCustomCarPlateMgr::SetupPlates(RpClump* pClump, RwTexture* pTexture, signed char nDesign)
|
||||||
|
{
|
||||||
|
std::pair<RwTexture*,signed char> CallbackData = std::make_pair(pTexture, nDesign);
|
||||||
|
|
||||||
|
RpClumpForAllAtomics(pClump, SetPlateData, &CallbackData);
|
||||||
|
}
|
|
@ -281,7 +281,7 @@ public:
|
||||||
static RpMaterial* GetEditableMaterialListCB(RpMaterial* pMaterial, void* pData);
|
static RpMaterial* GetEditableMaterialListCB(RpMaterial* pMaterial, void* pData);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_MAX_PLATES 6
|
#define NUM_MAX_PLATES 12
|
||||||
|
|
||||||
class CCustomCarPlateMgr
|
class CCustomCarPlateMgr
|
||||||
{
|
{
|
||||||
|
@ -298,6 +298,9 @@ public:
|
||||||
static void SetupMaterialPlatebackTexture(RpMaterial* pMaterial, signed char nDesign);
|
static void SetupMaterialPlatebackTexture(RpMaterial* pMaterial, signed char nDesign);
|
||||||
|
|
||||||
static void SetupClump(RpClump* pClump, RpMaterial** pMatsArray);
|
static void SetupClump(RpClump* pClump, RpMaterial** pMatsArray);
|
||||||
|
static void SetupClumpAfterVehicleUpgrade(RpClump* pClump, RpMaterial** pMatsArray, signed char nDesign);
|
||||||
|
|
||||||
|
static void SetupPlates(RpClump* pClump, RwTexture* pTexture, signed char nDesign);
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(CBaseModelInfo) == 0x20, "Wrong size: CBaseModelInfo");
|
static_assert(sizeof(CBaseModelInfo) == 0x20, "Wrong size: CBaseModelInfo");
|
||||||
|
|
|
@ -48,6 +48,7 @@ bool CVehicle::CustomCarPlate_TextureCreate(CVehicleModelInfo* pModelInfo)
|
||||||
|
|
||||||
void CVehicle::CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo)
|
void CVehicle::CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo)
|
||||||
{
|
{
|
||||||
|
//CCustomCarPlateMgr::SetupPlates(reinterpret_cast<RpClump*>(pModelInfo->pRwObject), PlateTexture, PlateDesign);
|
||||||
for ( int i = 0; i < NUM_MAX_PLATES; i++ )
|
for ( int i = 0; i < NUM_MAX_PLATES; i++ )
|
||||||
{
|
{
|
||||||
if ( pModelInfo->m_apPlateMaterials[i] )
|
if ( pModelInfo->m_apPlateMaterials[i] )
|
||||||
|
|
|
@ -2392,6 +2392,7 @@ __forceinline void Patch_SA_10()
|
||||||
InjectMethodVP(0x4C9660, CVehicleModelInfo::SetCarCustomPlate, PATCH_NOTHING);
|
InjectMethodVP(0x4C9660, CVehicleModelInfo::SetCarCustomPlate, PATCH_NOTHING);
|
||||||
InjectMethodVP(0x6D6A58, CVehicle::CustomCarPlate_TextureCreate, PATCH_NOTHING);
|
InjectMethodVP(0x6D6A58, CVehicle::CustomCarPlate_TextureCreate, PATCH_NOTHING);
|
||||||
InjectMethodVP(0x6D651C, CVehicle::CustomCarPlate_BeforeRenderingStart, PATCH_NOTHING);
|
InjectMethodVP(0x6D651C, CVehicle::CustomCarPlate_BeforeRenderingStart, PATCH_NOTHING);
|
||||||
|
InjectHook(0x6FDFE0, CCustomCarPlateMgr::SetupClumpAfterVehicleUpgrade, PATCH_JUMP);
|
||||||
//InjectMethodVP(0x6D0E53, CVehicle::CustomCarPlate_AfterRenderingStop, PATCH_NOTHING);
|
//InjectMethodVP(0x6D0E53, CVehicle::CustomCarPlate_AfterRenderingStop, PATCH_NOTHING);
|
||||||
Nop(0x6D6517, 2);
|
Nop(0x6D6517, 2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue