2014-08-03 15:38:53 +02:00
|
|
|
#include "StdAfxSA.h"
|
2014-05-30 20:14:47 +02:00
|
|
|
|
2014-08-03 15:38:53 +02:00
|
|
|
#include "VehicleSA.h"
|
|
|
|
#include "TimerSA.h"
|
2014-05-30 20:14:47 +02:00
|
|
|
|
2014-08-04 14:30:16 +02:00
|
|
|
void (*CVehicle::SetComponentAtomicAlpha)(RpAtomic* pAtomic, int nAlpha) = AddressByVersion<void(*)(RpAtomic*,int)>(0x6D2960, 0, 0);
|
|
|
|
|
|
|
|
static void* varVehicleRender = AddressByVersion<void*>(0x6D0E60, 0, 0);
|
|
|
|
WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); }
|
|
|
|
static void* varIsLawEnforcementVehicle = AddressByVersion<void*>(0x6D2370, 0, 0);
|
|
|
|
WRAPPER bool CVehicle::IsLawEnforcementVehicle() { VARJMP(varIsLawEnforcementVehicle); }
|
2014-05-30 20:14:47 +02:00
|
|
|
|
|
|
|
static RwObject* GetCurrentAtomicObjectCB(RwObject* pObject, void* data)
|
|
|
|
{
|
|
|
|
if ( RpAtomicGetFlags(pObject) & rpATOMICRENDER )
|
2014-06-03 02:10:03 +02:00
|
|
|
{
|
2014-05-30 20:14:47 +02:00
|
|
|
*static_cast<RwObject**>(data) = pObject;
|
2014-06-03 02:10:03 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2014-05-30 20:14:47 +02:00
|
|
|
return pObject;
|
|
|
|
}
|
|
|
|
|
2014-06-23 02:37:03 +02:00
|
|
|
bool CVehicle::CustomCarPlate_TextureCreate(CVehicleModelInfo* pModelInfo)
|
|
|
|
{
|
|
|
|
char PlateText[8];
|
|
|
|
const char* pOverrideText = pModelInfo->GetCustomCarPlateText();
|
|
|
|
|
|
|
|
if ( pOverrideText )
|
|
|
|
strncpy(PlateText, pOverrideText, 8);
|
|
|
|
else
|
|
|
|
CCustomCarPlateMgr::GeneratePlateText(PlateText, 8);
|
|
|
|
|
|
|
|
PlateTexture = CCustomCarPlateMgr::CreatePlateTexture(PlateText, pModelInfo->m_nPlateType);
|
2014-06-23 14:54:36 +02:00
|
|
|
//PlateDesign = pModelInfo->m_nPlateType != -1 ? pModelInfo->m_nPlateType : CCustomCarPlateMgr::GetMapRegionPlateDesign();
|
|
|
|
if ( pModelInfo->m_nPlateType != -1 )
|
|
|
|
PlateDesign = pModelInfo->m_nPlateType;
|
|
|
|
else if ( IsLawEnforcementVehicle() )
|
|
|
|
PlateDesign = CCustomCarPlateMgr::GetMapRegionPlateDesign();
|
|
|
|
else
|
|
|
|
PlateDesign = random(0, 20) == 0 ? random<signed char>(0, 3) : CCustomCarPlateMgr::GetMapRegionPlateDesign();
|
2014-06-23 02:37:03 +02:00
|
|
|
|
|
|
|
assert(PlateDesign >= 0 && PlateDesign < 3);
|
|
|
|
|
|
|
|
pModelInfo->m_plateText[0] = '\0';
|
|
|
|
pModelInfo->m_nPlateType = -1;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-23 15:08:48 +02:00
|
|
|
//static RwTexture* pPushedTextures[NUM_MAX_PLATES];
|
2014-06-23 02:37:03 +02:00
|
|
|
|
|
|
|
void CVehicle::CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo)
|
|
|
|
{
|
2014-06-29 22:21:18 +02:00
|
|
|
//CCustomCarPlateMgr::SetupPlates(reinterpret_cast<RpClump*>(pModelInfo->pRwObject), PlateTexture, PlateDesign);
|
2014-06-23 02:37:03 +02:00
|
|
|
for ( int i = 0; i < NUM_MAX_PLATES; i++ )
|
|
|
|
{
|
|
|
|
if ( pModelInfo->m_apPlateMaterials[i] )
|
|
|
|
{
|
2014-06-23 15:08:48 +02:00
|
|
|
//RwTexture* pPlateTex = RpMaterialGetTexture(pModelInfo->m_apPlateMaterials[i]);
|
2014-06-23 02:37:03 +02:00
|
|
|
|
2014-06-23 15:08:48 +02:00
|
|
|
//RwTextureAddRef(pPlateTex);
|
|
|
|
//pPushedTextures[i] = pPlateTex;
|
2014-06-23 02:37:03 +02:00
|
|
|
|
|
|
|
RpMaterialSetTexture(pModelInfo->m_apPlateMaterials[i], PlateTexture);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pModelInfo->m_apPlateMaterials[NUM_MAX_PLATES+i] )
|
|
|
|
CCustomCarPlateMgr::SetupMaterialPlatebackTexture(pModelInfo->m_apPlateMaterials[NUM_MAX_PLATES+i], PlateDesign);
|
|
|
|
//RwTexture* pPlatebackTex = RpMaterialGetTexture(pModelInfo->m_apPlateMaterials[4+i]);
|
|
|
|
|
|
|
|
//RwTextureAddRef(pPlatebackTex);
|
|
|
|
//pPushedTextures[4+i] = pPlateTex;
|
|
|
|
|
|
|
|
//RpMaterialSetTexture(pModelInfo->m_apPlateMaterials[i], PlateTexture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-23 15:08:48 +02:00
|
|
|
// This is not needed
|
|
|
|
/*void CVehicle::CustomCarPlate_AfterRenderingStop(CVehicleModelInfo* pModelInfo)
|
2014-06-23 02:37:03 +02:00
|
|
|
{
|
|
|
|
for ( int i = 0; i < NUM_MAX_PLATES; i++ )
|
|
|
|
{
|
|
|
|
if ( pModelInfo->m_apPlateMaterials[i] )
|
|
|
|
{
|
|
|
|
//RwTexture* pPlateTex = RpMaterialGetTexture(pModelInfo->m_apPlateMaterials[i]);
|
|
|
|
|
|
|
|
//RwTextureAddRef(pPlateTex);
|
|
|
|
//pPushedTextures[i] = pPlateTex;
|
|
|
|
|
2014-06-23 15:08:48 +02:00
|
|
|
//RpMaterialSetTexture(pModelInfo->m_apPlateMaterials[i], pPushedTextures[i]);
|
|
|
|
//RwTextureDestroy(pPushedTextures[i]);
|
|
|
|
//pPushedTextures[i] = nullptr;
|
2014-06-23 02:37:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-23 15:08:48 +02:00
|
|
|
}*/
|
2014-06-23 02:37:03 +02:00
|
|
|
|
2014-05-30 20:14:47 +02:00
|
|
|
void CHeli::Render()
|
|
|
|
{
|
|
|
|
double dRotorsSpeed, dMovingRotorSpeed;
|
2014-06-03 02:10:03 +02:00
|
|
|
bool bHasMovingRotor = m_pCarNode[12] != nullptr;
|
|
|
|
bool bHasMovingRotor2 = m_pCarNode[14] != nullptr;
|
2014-05-30 20:14:47 +02:00
|
|
|
|
2014-08-03 15:38:53 +02:00
|
|
|
m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000;
|
2014-05-30 20:14:47 +02:00
|
|
|
|
|
|
|
if ( m_fRotorSpeed > 0.0 )
|
|
|
|
dRotorsSpeed = min(1.7 * (1.0/0.22) * m_fRotorSpeed, 1.5);
|
|
|
|
else
|
|
|
|
dRotorsSpeed = 0.0;
|
|
|
|
|
|
|
|
dMovingRotorSpeed = dRotorsSpeed - 0.4;
|
|
|
|
if ( dMovingRotorSpeed < 0.0 )
|
|
|
|
dMovingRotorSpeed = 0.0;
|
|
|
|
|
|
|
|
int nStaticRotorAlpha = static_cast<int>(min((1.5-dRotorsSpeed) * 255.0, 255));
|
|
|
|
int nMovingRotorAlpha = static_cast<int>(min(dMovingRotorSpeed * 175.0, 175));
|
|
|
|
|
|
|
|
if ( m_pCarNode[11] )
|
|
|
|
{
|
|
|
|
RpAtomic* pOutAtomic = nullptr;
|
|
|
|
RwFrameForAllObjects(m_pCarNode[11], GetCurrentAtomicObjectCB, &pOutAtomic);
|
|
|
|
if ( pOutAtomic )
|
2014-06-03 02:10:03 +02:00
|
|
|
SetComponentAtomicAlpha(pOutAtomic, bHasMovingRotor ? nStaticRotorAlpha : 255);
|
2014-05-30 20:14:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_pCarNode[13] )
|
|
|
|
{
|
|
|
|
RpAtomic* pOutAtomic = nullptr;
|
|
|
|
RwFrameForAllObjects(m_pCarNode[13], GetCurrentAtomicObjectCB, &pOutAtomic);
|
|
|
|
if ( pOutAtomic )
|
2014-06-03 02:10:03 +02:00
|
|
|
SetComponentAtomicAlpha(pOutAtomic, bHasMovingRotor2 ? nStaticRotorAlpha : 255);
|
2014-05-30 20:14:47 +02:00
|
|
|
}
|
|
|
|
|
2014-06-03 02:10:03 +02:00
|
|
|
if ( bHasMovingRotor )
|
2014-05-30 20:14:47 +02:00
|
|
|
{
|
|
|
|
RpAtomic* pOutAtomic = nullptr;
|
|
|
|
RwFrameForAllObjects(m_pCarNode[12], GetCurrentAtomicObjectCB, &pOutAtomic);
|
|
|
|
if ( pOutAtomic )
|
|
|
|
SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha);
|
|
|
|
}
|
|
|
|
|
2014-06-03 02:10:03 +02:00
|
|
|
if ( bHasMovingRotor2 )
|
2014-05-30 20:14:47 +02:00
|
|
|
{
|
|
|
|
RpAtomic* pOutAtomic = nullptr;
|
|
|
|
RwFrameForAllObjects(m_pCarNode[14], GetCurrentAtomicObjectCB, &pOutAtomic);
|
|
|
|
if ( pOutAtomic )
|
|
|
|
SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
CEntity::Render();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlane::Render()
|
|
|
|
{
|
|
|
|
double dRotorsSpeed, dMovingRotorSpeed;
|
2014-06-04 16:12:53 +02:00
|
|
|
bool bHasMovingProp = m_pCarNode[12] != nullptr;
|
|
|
|
bool bHasMovingProp2 = m_pCarNode[14] != nullptr;
|
2014-05-30 20:14:47 +02:00
|
|
|
|
2014-08-03 15:38:53 +02:00
|
|
|
m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000;
|
2014-05-30 20:14:47 +02:00
|
|
|
|
|
|
|
if ( m_fPropellerSpeed > 0.0 )
|
|
|
|
dRotorsSpeed = min(1.7 * (1.0/0.31) * m_fPropellerSpeed, 1.5);
|
|
|
|
else
|
|
|
|
dRotorsSpeed = 0.0;
|
|
|
|
|
|
|
|
dMovingRotorSpeed = dRotorsSpeed - 0.4;
|
|
|
|
if ( dMovingRotorSpeed < 0.0 )
|
|
|
|
dMovingRotorSpeed = 0.0;
|
|
|
|
|
|
|
|
int nStaticRotorAlpha = static_cast<int>(min((1.5-dRotorsSpeed) * 255.0, 255));
|
|
|
|
int nMovingRotorAlpha = static_cast<int>(min(dMovingRotorSpeed * 175.0, 175));
|
|
|
|
|
|
|
|
if ( m_pCarNode[11] )
|
|
|
|
{
|
|
|
|
RpAtomic* pOutAtomic = nullptr;
|
|
|
|
RwFrameForAllObjects(m_pCarNode[11], GetCurrentAtomicObjectCB, &pOutAtomic);
|
|
|
|
if ( pOutAtomic )
|
2014-06-04 16:12:53 +02:00
|
|
|
SetComponentAtomicAlpha(pOutAtomic, bHasMovingProp ? nStaticRotorAlpha : 255);
|
2014-05-30 20:14:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_pCarNode[13] )
|
|
|
|
{
|
|
|
|
RpAtomic* pOutAtomic = nullptr;
|
|
|
|
RwFrameForAllObjects(m_pCarNode[13], GetCurrentAtomicObjectCB, &pOutAtomic);
|
|
|
|
if ( pOutAtomic )
|
2014-06-04 16:12:53 +02:00
|
|
|
SetComponentAtomicAlpha(pOutAtomic, bHasMovingProp2 ? nStaticRotorAlpha : 255);
|
2014-05-30 20:14:47 +02:00
|
|
|
}
|
|
|
|
|
2014-06-04 16:12:53 +02:00
|
|
|
if ( bHasMovingProp )
|
2014-05-30 20:14:47 +02:00
|
|
|
{
|
|
|
|
RpAtomic* pOutAtomic = nullptr;
|
|
|
|
RwFrameForAllObjects(m_pCarNode[12], GetCurrentAtomicObjectCB, &pOutAtomic);
|
|
|
|
if ( pOutAtomic )
|
|
|
|
SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha);
|
|
|
|
}
|
|
|
|
|
2014-06-04 16:12:53 +02:00
|
|
|
if ( bHasMovingProp2 )
|
2014-05-30 20:14:47 +02:00
|
|
|
{
|
|
|
|
RpAtomic* pOutAtomic = nullptr;
|
|
|
|
RwFrameForAllObjects(m_pCarNode[14], GetCurrentAtomicObjectCB, &pOutAtomic);
|
|
|
|
if ( pOutAtomic )
|
|
|
|
SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
CVehicle::Render();
|
|
|
|
}
|