Small SVF refactor

This commit is contained in:
Silent 2024-02-01 19:07:51 +01:00
parent f63425cff0
commit 0fa88b0260
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
4 changed files with 14 additions and 8 deletions

View File

@ -127,12 +127,15 @@ namespace SVF
} ) != results.second;
}
std::function<void(Feature)> ForAllModelFeatures( int32_t modelID, std::function<void(Feature)> pred )
std::function<bool(Feature)> ForAllModelFeatures( int32_t modelID, std::function<bool(Feature)> pred )
{
auto results = specialVehFeatures.equal_range( modelID );
for ( auto it = results.first; it != results.second; ++it )
{
pred(std::get<Feature>(it->second));
if (!pred(std::get<Feature>(it->second)))
{
break;
}
}
return std::move(pred);
}

View File

@ -47,5 +47,5 @@ namespace SVF
void DeleteFeature( int32_t cookie );
void DisableStockVehiclesForFeature( Feature feature );
bool ModelHasFeature( int32_t modelID, Feature feature );
std::function<void(Feature)> ForAllModelFeatures( int32_t modelID, std::function<void(Feature)> pred );
std::function<bool(Feature)> ForAllModelFeatures( int32_t modelID, std::function<bool(Feature)> pred );
};

View File

@ -66,18 +66,19 @@ bool __stdcall CheckDoubleRWheelsList( void* modelInfo, uint8_t* handlingData )
bool foundFeature = false;
bool featureStatus = false;
SVF::ForAllModelFeatures( modelID, [&]( SVF::Feature f ) {
if ( foundFeature ) return;
if ( f == SVF::Feature::_INTERNAL_FORCE_DOUBLE_RWHEELS_OFF )
{
foundFeature = true;
featureStatus = false;
return false;
}
else if ( f == SVF::Feature::_INTERNAL_FORCE_DOUBLE_RWHEELS_ON )
if ( f == SVF::Feature::_INTERNAL_FORCE_DOUBLE_RWHEELS_ON )
{
foundFeature = true;
featureStatus = true;
return false;
}
return true;
} );
if ( !foundFeature )
{

View File

@ -399,15 +399,17 @@ namespace FBISirenCoronaFix
if ( f >= SVF::Feature::FBI_RANCHER_SIREN && f <= SVF::Feature::VICE_CHEETAH_SIREN )
{
foundFeature = f;
return false;
}
return true;
} );
if ( foundFeature != SVF::Feature::NO_FEATURE )
{
if ( foundFeature != SVF::Feature::VICE_CHEETAH_SIREN )
{
const CVector FBICAR_SIREN_POS = CVector(0.4f, 0.8f, 0.25f);
const CVector FBIRANCH_SIREN_POS = CVector(0.5f, 1.12f, 0.5f);
constexpr CVector FBICAR_SIREN_POS(0.4f, 0.8f, 0.25f);
constexpr CVector FBIRANCH_SIREN_POS(0.5f, 1.12f, 0.5f);
overridePosition = true;
vecOverridePosition = foundFeature == SVF::Feature::FBI_WASHINGTON_SIREN ? FBICAR_SIREN_POS : FBIRANCH_SIREN_POS;