Allow for several hierarchy typos (DFT-30, Sweeper, boats)

This retires BOAT_MOVING_PROP feature and Sweeper workaround
This commit is contained in:
Silent 2018-06-05 20:01:45 +02:00
parent 77f78fedca
commit 03482f0779
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
3 changed files with 29 additions and 41 deletions

View file

@ -1488,6 +1488,27 @@ TestFirelaAndFlags_UpdateMovingCollision:
} }
} }
namespace HierarchyTypoFix
{
// Allow wheel_lm vs wheel_lm_dummy and miscX vs misc_X typos
constexpr std::pair<const char*, const char*> typosAndFixes[] = {
{ "wheel_lm_dummy", "wheel_lm" },
{ "misc_a", "misca" },
{ "misc_b", "miscb" },
{ "boat_moving_hi", "boat_moving" },
};
int strcasecmp( const char* dataName, const char* nodeName )
{
for ( const auto& typo : typosAndFixes )
{
if ( _stricmp( dataName, typo.first ) == 0 && _stricmp( nodeName, typo.second ) == 0 ) return 0;
}
return _stricmp( dataName, nodeName );
}
}
#ifndef NDEBUG #ifndef NDEBUG
@ -3564,7 +3585,7 @@ void Patch_SA_10()
// Animated Phoenix hood scoop // Animated Phoenix hood scoop
auto* automobilePreRender = &(*(decltype(CAutomobile::orgAutomobilePreRender)**)(0x6B0AD2 + 2))[17]; auto* automobilePreRender = (*(decltype(CAutomobile::orgAutomobilePreRender)**)(0x6B0AD2 + 2)) + 17;
CAutomobile::orgAutomobilePreRender = *automobilePreRender; CAutomobile::orgAutomobilePreRender = *automobilePreRender;
Patch(automobilePreRender, &CAutomobile::PreRender_Stub); Patch(automobilePreRender, &CAutomobile::PreRender_Stub);
@ -3574,16 +3595,11 @@ void Patch_SA_10()
// Extra animations for planes // Extra animations for planes
auto* planePreRender = &(*(decltype(CPlane::orgPlanePreRender)**)(0x6C8E5A + 2))[17]; auto* planePreRender = (*(decltype(CPlane::orgPlanePreRender)**)(0x6C8E5A + 2)) + 17;
CPlane::orgPlanePreRender = *planePreRender; CPlane::orgPlanePreRender = *planePreRender;
Patch(planePreRender, &CPlane::PreRender_Stub); Patch(planePreRender, &CPlane::PreRender_Stub);
// Fixed animations for boats
ReadCall( 0x6F119E, CVehicle::orgVehiclePreRender );
InjectHook( 0x6F119E, &CBoat::PreRender_SilentPatch );
// Stop BF Injection/Bandito/Hotknife rotating engine components when engine is off // Stop BF Injection/Bandito/Hotknife rotating engine components when engine is off
Patch<const void*>(0x6AC2BE + 2, &CAutomobile::ms_engineCompSpeed); Patch<const void*>(0x6AC2BE + 2, &CAutomobile::ms_engineCompSpeed);
Patch<const void*>(0x6ACB91 + 2, &CAutomobile::ms_engineCompSpeed); Patch<const void*>(0x6ACB91 + 2, &CAutomobile::ms_engineCompSpeed);
@ -3733,6 +3749,10 @@ void Patch_SA_10()
CTrailer::orgGetTowBarPos = *trailerTowBarPos; CTrailer::orgGetTowBarPos = *trailerTowBarPos;
Patch(trailerTowBarPos, &CTrailer::GetTowBarPos_Stub); Patch(trailerTowBarPos, &CTrailer::GetTowBarPos_Stub);
} }
// DFT-30 wheel, Sweeper brushes and other typos in hierarchy
InjectHook( 0x4C5311, HierarchyTypoFix::strcasecmp );
} }
void Patch_SA_11() void Patch_SA_11()

View file

@ -27,7 +27,6 @@ namespace SVF {
PHOENIX_FLUTTER, PHOENIX_FLUTTER,
SWEEPER_BRUSHES, SWEEPER_BRUSHES,
NEWSVAN_DISH, NEWSVAN_DISH,
BOAT_MOVING_PROP,
EXTRA_AILERONS1, // Like on Beagle EXTRA_AILERONS1, // Like on Beagle
EXTRA_AILERONS2, // Like on Stuntplane EXTRA_AILERONS2, // Like on Stuntplane
DOUBLE_TRAILER, // Like on artict3 DOUBLE_TRAILER, // Like on artict3
@ -50,7 +49,6 @@ namespace SVF {
{ "PHOENIX_FLUTTER", Feature::PHOENIX_FLUTTER }, { "PHOENIX_FLUTTER", Feature::PHOENIX_FLUTTER },
{ "SWEEPER_BRUSHES", Feature::SWEEPER_BRUSHES }, { "SWEEPER_BRUSHES", Feature::SWEEPER_BRUSHES },
{ "NEWSVAN_DISH", Feature::NEWSVAN_DISH }, { "NEWSVAN_DISH", Feature::NEWSVAN_DISH },
{ "BOAT_MOVING_PROP", Feature::BOAT_MOVING_PROP },
{ "EXTRA_AILERONS1", Feature::EXTRA_AILERONS1 }, { "EXTRA_AILERONS1", Feature::EXTRA_AILERONS1 },
{ "EXTRA_AILERONS2", Feature::EXTRA_AILERONS2 }, { "EXTRA_AILERONS2", Feature::EXTRA_AILERONS2 },
{ "DOUBLE_TRAILER", Feature::DOUBLE_TRAILER }, { "DOUBLE_TRAILER", Feature::DOUBLE_TRAILER },
@ -87,10 +85,7 @@ namespace SVF {
} }
static std::multimap<int32_t, std::tuple<Feature, int32_t> > specialVehFeatures = { static std::multimap<int32_t, std::tuple<Feature, int32_t> > specialVehFeatures = {
_registerFeatureInternal( 430, Feature::BOAT_MOVING_PROP ),
_registerFeatureInternal( 432, Feature::RHINO_WHEELS ), _registerFeatureInternal( 432, Feature::RHINO_WHEELS ),
_registerFeatureInternal( 453, Feature::BOAT_MOVING_PROP ),
_registerFeatureInternal( 454, Feature::BOAT_MOVING_PROP ),
_registerFeatureInternal( 511, Feature::EXTRA_AILERONS1 ), _registerFeatureInternal( 511, Feature::EXTRA_AILERONS1 ),
_registerFeatureInternal( 513, Feature::EXTRA_AILERONS2 ), _registerFeatureInternal( 513, Feature::EXTRA_AILERONS2 ),
_registerFeatureInternal( 525, Feature::TOWTRUCK_HOOK ), _registerFeatureInternal( 525, Feature::TOWTRUCK_HOOK ),
@ -163,7 +158,6 @@ WRAPPER bool CVehicle::IsLawEnforcementVehicle() { VARJMP(varIsLawEnforcementVeh
auto GetFrameHierarchyId = AddressByVersion<int32_t(*)(RwFrame*)>(0x732A20, 0x733250, 0x76CC30); auto GetFrameHierarchyId = AddressByVersion<int32_t(*)(RwFrame*)>(0x732A20, 0x733250, 0x76CC30);
void (CVehicle::*CVehicle::orgVehiclePreRender)();
void (CAutomobile::*CAutomobile::orgAutomobilePreRender)(); void (CAutomobile::*CAutomobile::orgAutomobilePreRender)();
void (CPlane::*CPlane::orgPlanePreRender)(); void (CPlane::*CPlane::orgPlanePreRender)();
CVehicle* (CStoredCar::*CStoredCar::orgRestoreCar)(); CVehicle* (CStoredCar::*CStoredCar::orgRestoreCar)();
@ -187,7 +181,7 @@ static RwObject* GetCurrentAtomicObject( RwFrame* frame )
return obj; return obj;
} }
static RwFrame* GetFrameFromName( RwFrame* topFrame, const char* name ) RwFrame* GetFrameFromName( RwFrame* topFrame, const char* name )
{ {
class GetFramePredicate class GetFramePredicate
{ {
@ -217,7 +211,7 @@ static RwFrame* GetFrameFromName( RwFrame* topFrame, const char* name )
return RwFrameForAllChildren( topFrame, GetFramePredicate(name) ).foundFrame; return RwFrameForAllChildren( topFrame, GetFramePredicate(name) ).foundFrame;
} }
static RwFrame* GetFrameFromID( RwFrame* topFrame, int32_t ID ) RwFrame* GetFrameFromID( RwFrame* topFrame, int32_t ID )
{ {
class GetFramePredicate class GetFramePredicate
{ {
@ -486,18 +480,6 @@ void CPlane::PreRender()
} }
} }
void CBoat::PreRender_SilentPatch()
{
(this->*(orgVehiclePreRender))();
// Fixed moving prop for Predator/Tropic/Reefer
const int32_t extID = m_nModelIndex.Get();
if ( m_pBoatNode[1] == nullptr && SVF::ModelHasFeature( extID, SVF::Feature::BOAT_MOVING_PROP ) )
{
m_pBoatNode[1] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "boat_moving" );
}
}
void CAutomobile::PreRender() void CAutomobile::PreRender()
{ {
// For rotating engine components // For rotating engine components
@ -623,15 +605,6 @@ void CAutomobile::ProcessSweeper()
if ( GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PHYSICS || GetStatus() == STATUS_SIMPLE ) if ( GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PHYSICS || GetStatus() == STATUS_SIMPLE )
{ {
if ( m_pCarNode[20] == nullptr )
{
m_pCarNode[20] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "misca" );
}
if ( m_pCarNode[21] == nullptr )
{
m_pCarNode[21] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "miscb" );
}
const float angle = CTimer::m_fTimeStep * SWEEPER_BRUSH_SPEED; const float angle = CTimer::m_fTimeStep * SWEEPER_BRUSH_SPEED;
SetComponentRotation( m_pCarNode[20], ROT_AXIS_Z, angle, false ); SetComponentRotation( m_pCarNode[20], ROT_AXIS_Z, angle, false );

View file

@ -266,8 +266,6 @@ public:
static void SetComponentRotation( RwFrame* component, eRotAxis axis, float angle, bool absolute = true ); static void SetComponentRotation( RwFrame* component, eRotAxis axis, float angle, bool absolute = true );
static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha); static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha);
static void (CVehicle::*orgVehiclePreRender)();
}; };
class NOVMT CAutomobile : public CVehicle class NOVMT CAutomobile : public CVehicle
@ -359,9 +357,6 @@ class NOVMT CBoat : public CVehicle
{ {
uint8_t __pad[16]; uint8_t __pad[16];
RwFrame* m_pBoatNode[12]; RwFrame* m_pBoatNode[12];
public:
void PreRender_SilentPatch();
}; };
class CStoredCar class CStoredCar