Rotor fix exceptions

This commit is contained in:
Silent 2015-05-05 23:29:15 +02:00
parent fbc617697c
commit 46969bf88f
3 changed files with 55 additions and 13 deletions

View file

@ -1693,6 +1693,8 @@ BOOL InjectDelayedPatches_10()
bool bSAMP = GetModuleHandle("samp") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr;
bool bSARender = GetModuleHandle("SARender.asi") != nullptr; bool bSARender = GetModuleHandle("SARender.asi") != nullptr;
ReadRotorFixExceptions(wcModulePath);
// PS2 sun - more // PS2 sun - more
if ( !bSAMP ) if ( !bSAMP )
{ {
@ -1899,6 +1901,8 @@ BOOL InjectDelayedPatches_11()
bool bSAMP = GetModuleHandle("samp") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr;
bool bSARender = GetModuleHandle("SARender.asi") != nullptr; bool bSARender = GetModuleHandle("SARender.asi") != nullptr;
ReadRotorFixExceptions(wcModulePath);
// PS2 sun - more // PS2 sun - more
if ( !bSAMP ) if ( !bSAMP )
{ {
@ -2114,6 +2118,8 @@ BOOL InjectDelayedPatches_Steam()
bool bSAMP = GetModuleHandle("samp") != nullptr; bool bSAMP = GetModuleHandle("samp") != nullptr;
bool bSARender = GetModuleHandle("SARender.asi") != nullptr; bool bSARender = GetModuleHandle("SARender.asi") != nullptr;
ReadRotorFixExceptions(wcModulePath);
// PS2 sun - more // PS2 sun - more
if ( !bSAMP ) if ( !bSAMP )
{ {

View file

@ -1,8 +1,11 @@
#include "StdAfxSA.h" #include "StdAfxSA.h"
#include <set>
#include "VehicleSA.h" #include "VehicleSA.h"
#include "TimerSA.h" #include "TimerSA.h"
std::set<unsigned int> vecRotorExceptions;
static void* varVehicleRender = AddressByVersion<void*>(0x6D0E60, 0x6D1680, 0x70C0B0); static void* varVehicleRender = AddressByVersion<void*>(0x6D0E60, 0x6D1680, 0x70C0B0);
WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); } WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); }
static void* varIsLawEnforcementVehicle = AddressByVersion<void*>(0x6D2370, 0x6D2BA0, 0x70D8C0); static void* varIsLawEnforcementVehicle = AddressByVersion<void*>(0x6D2370, 0x6D2BA0, 0x70D8C0);
@ -22,7 +25,7 @@ static RwFrame* GetFrameFromNameCB(RwFrame* pFrame, void* pData)
{ {
// Is this a frame we want? // Is this a frame we want?
std::pair<const char*,RwFrame*>* pFindData = static_cast<std::pair<const char*,RwFrame*>*>(pData); std::pair<const char*,RwFrame*>* pFindData = static_cast<std::pair<const char*,RwFrame*>*>(pData);
if ( !strncmp(pFindData->first, GetFrameNodeName(pFrame), 24) ) if ( !strcmp(pFindData->first, GetFrameNodeName(pFrame)) )
{ {
pFindData->second = pFrame; pFindData->second = pFrame;
return nullptr; return nullptr;
@ -39,6 +42,37 @@ static RpMaterial* SetCompAlphaCB(RpMaterial* pMaterial, void* data)
return pMaterial; return pMaterial;
} }
void ReadRotorFixExceptions(const wchar_t* pPath)
{
if ( FILE* hFile = _wfopen(pPath, L"r") )
{
char buf[1024];
bool bBeganParsing = false;
while ( fgets(buf, _countof(buf), hFile) )
{
if ( bBeganParsing )
{
if ( buf[0] != ';' )
{
unsigned int nToList = atoi(buf);
if ( nToList != 0 )
vecRotorExceptions.insert(nToList);
}
}
else
{
if ( strstr(buf, "[RotorFixExceptions]") != nullptr )
bBeganParsing = true;
}
}
fclose(hFile);
}
}
void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha) void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha)
{ {
RpGeometry* pGeometry = RpAtomicGetGeometry(pAtomic); RpGeometry* pGeometry = RpAtomicGetGeometry(pAtomic);
@ -125,8 +159,8 @@ void CVehicle::CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo
void CHeli::Render() void CHeli::Render()
{ {
double dRotorsSpeed, dMovingRotorSpeed; double dRotorsSpeed, dMovingRotorSpeed;
bool bHasMovingRotor = m_pCarNode[13] != nullptr; bool bHasMovingRotor = m_pCarNode[13] != nullptr && vecRotorExceptions.count(m_nModelIndex) == 0;
bool bHasMovingRotor2 = m_pCarNode[15] != nullptr; bool bHasMovingRotor2 = m_pCarNode[15] != nullptr && vecRotorExceptions.count(m_nModelIndex) == 0;;
m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000; m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000;
@ -158,20 +192,20 @@ void CHeli::Render()
SetComponentAtomicAlpha(pOutAtomic, bHasMovingRotor2 ? nStaticRotorAlpha : 255); SetComponentAtomicAlpha(pOutAtomic, bHasMovingRotor2 ? nStaticRotorAlpha : 255);
} }
if ( bHasMovingRotor ) if ( m_pCarNode[13] )
{ {
RpAtomic* pOutAtomic = nullptr; RpAtomic* pOutAtomic = nullptr;
RwFrameForAllObjects(m_pCarNode[13], GetCurrentAtomicObjectCB, &pOutAtomic); RwFrameForAllObjects(m_pCarNode[13], GetCurrentAtomicObjectCB, &pOutAtomic);
if ( pOutAtomic ) if ( pOutAtomic )
SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha); SetComponentAtomicAlpha(pOutAtomic, bHasMovingRotor ? nMovingRotorAlpha : 0);
} }
if ( bHasMovingRotor2 ) if ( m_pCarNode[15] )
{ {
RpAtomic* pOutAtomic = nullptr; RpAtomic* pOutAtomic = nullptr;
RwFrameForAllObjects(m_pCarNode[15], GetCurrentAtomicObjectCB, &pOutAtomic); RwFrameForAllObjects(m_pCarNode[15], GetCurrentAtomicObjectCB, &pOutAtomic);
if ( pOutAtomic ) if ( pOutAtomic )
SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha); SetComponentAtomicAlpha(pOutAtomic, bHasMovingRotor2 ? nMovingRotorAlpha : 0);
} }
CEntity::Render(); CEntity::Render();
@ -180,8 +214,8 @@ void CHeli::Render()
void CPlane::Render() void CPlane::Render()
{ {
double dRotorsSpeed, dMovingRotorSpeed; double dRotorsSpeed, dMovingRotorSpeed;
bool bHasMovingProp = m_pCarNode[13] != nullptr; bool bHasMovingProp = m_pCarNode[13] != nullptr && vecRotorExceptions.count(m_nModelIndex) == 0;
bool bHasMovingProp2 = m_pCarNode[15] != nullptr; bool bHasMovingProp2 = m_pCarNode[15] != nullptr && vecRotorExceptions.count(m_nModelIndex) == 0;
m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000; m_nTimeTillWeNeedThisCar = CTimer::m_snTimeInMilliseconds + 3000;
@ -213,20 +247,20 @@ void CPlane::Render()
SetComponentAtomicAlpha(pOutAtomic, bHasMovingProp2 ? nStaticRotorAlpha : 255); SetComponentAtomicAlpha(pOutAtomic, bHasMovingProp2 ? nStaticRotorAlpha : 255);
} }
if ( bHasMovingProp ) if ( m_pCarNode[13] )
{ {
RpAtomic* pOutAtomic = nullptr; RpAtomic* pOutAtomic = nullptr;
RwFrameForAllObjects(m_pCarNode[13], GetCurrentAtomicObjectCB, &pOutAtomic); RwFrameForAllObjects(m_pCarNode[13], GetCurrentAtomicObjectCB, &pOutAtomic);
if ( pOutAtomic ) if ( pOutAtomic )
SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha); SetComponentAtomicAlpha(pOutAtomic, bHasMovingProp ? nMovingRotorAlpha : 0);
} }
if ( bHasMovingProp2 ) if ( m_pCarNode[15] )
{ {
RpAtomic* pOutAtomic = nullptr; RpAtomic* pOutAtomic = nullptr;
RwFrameForAllObjects(m_pCarNode[15], GetCurrentAtomicObjectCB, &pOutAtomic); RwFrameForAllObjects(m_pCarNode[15], GetCurrentAtomicObjectCB, &pOutAtomic);
if ( pOutAtomic ) if ( pOutAtomic )
SetComponentAtomicAlpha(pOutAtomic, nMovingRotorAlpha); SetComponentAtomicAlpha(pOutAtomic, bHasMovingProp2 ? nMovingRotorAlpha : 0);
} }
CVehicle::Render(); CVehicle::Render();

View file

@ -184,6 +184,8 @@ public:
void Fix_SilentPatch(); void Fix_SilentPatch();
}; };
void ReadRotorFixExceptions(const wchar_t* pPath);
static_assert(sizeof(CBouncingPanel) == 0x20, "Wrong size: CBouncingPanel"); static_assert(sizeof(CBouncingPanel) == 0x20, "Wrong size: CBouncingPanel");
static_assert(sizeof(CVehicle) == 0x5A0, "Wrong size: CVehicle"); static_assert(sizeof(CVehicle) == 0x5A0, "Wrong size: CVehicle");
static_assert(sizeof(CAutomobile) == 0x988, "Wrong size: CAutomobile"); static_assert(sizeof(CAutomobile) == 0x988, "Wrong size: CAutomobile");