III/VC: Made vehicle ID-based fixes data driven

This commit is contained in:
Silent 2019-12-25 16:02:42 +01:00
parent 7a96e5eefb
commit f3f9004322
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
10 changed files with 66 additions and 13 deletions

View File

@ -3,6 +3,7 @@
#include "Utils/MemoryMgr.h" #include "Utils/MemoryMgr.h"
#include "Utils/Patterns.h" #include "Utils/Patterns.h"
#include "StoredCar.h" #include "StoredCar.h"
#include "SVF.h"
#include <rwcore.h> #include <rwcore.h>
@ -72,7 +73,7 @@ namespace TaxiCoronaFix
{ {
CVector pos; CVector pos;
pos.x = 0.0f; pos.x = 0.0f;
if ( vehicle->GetModelIndex() == MI_TAXI ) if ( SVF::ModelHasFeature( vehicle->GetModelIndex(), SVF::Feature::TAXI_LIGHT ) )
{ {
#if _GTA_III #if _GTA_III
pos.y = -0.25f; pos.y = -0.25f;

View File

@ -9,6 +9,16 @@ namespace SVF
Feature GetFeatureFromName( const char* featureName ) Feature GetFeatureFromName( const char* featureName )
{ {
constexpr std::pair< const char*, Feature > features[] = { constexpr std::pair< const char*, Feature > features[] = {
#if _GTA_III || _GTA_VC
{ "TAXI_LIGHT", Feature::TAXI_LIGHT },
#endif
#if _GTA_VC
{ "FBI_RANCHER_SIREN", Feature::FBI_RANCHER_SIREN },
{ "FBI_WASHINGTON_SIREN", Feature::FBI_WASHINGTON_SIREN },
{ "VICE_CHEETAH_SIREN", Feature::VICE_CHEETAH_SIREN },
#endif
#if _GTA_SA #if _GTA_SA
{ "PHOENIX_FLUTTER", Feature::PHOENIX_FLUTTER }, { "PHOENIX_FLUTTER", Feature::PHOENIX_FLUTTER },
{ "SWEEPER_BRUSHES", Feature::SWEEPER_BRUSHES }, { "SWEEPER_BRUSHES", Feature::SWEEPER_BRUSHES },
@ -50,7 +60,14 @@ namespace SVF
} }
static std::multimap<int32_t, std::tuple<Feature, int32_t> > specialVehFeatures = { static std::multimap<int32_t, std::tuple<Feature, int32_t> > specialVehFeatures = {
#if _GTA_SA #if _GTA_III
_registerFeatureInternal( 110, Feature::TAXI_LIGHT ),
#elif _GTA_VC
_registerFeatureInternal( 147, Feature::FBI_WASHINGTON_SIREN ),
_registerFeatureInternal( 150, Feature::TAXI_LIGHT ),
_registerFeatureInternal( 220, Feature::FBI_RANCHER_SIREN ),
_registerFeatureInternal( 236, Feature::VICE_CHEETAH_SIREN ),
#elif _GTA_SA
_registerFeatureInternal( 432, Feature::RHINO_WHEELS ), _registerFeatureInternal( 432, Feature::RHINO_WHEELS ),
_registerFeatureInternal( 511, Feature::EXTRA_AILERONS1 ), _registerFeatureInternal( 511, Feature::EXTRA_AILERONS1 ),
_registerFeatureInternal( 513, Feature::EXTRA_AILERONS2 ), _registerFeatureInternal( 513, Feature::EXTRA_AILERONS2 ),

View File

@ -8,6 +8,16 @@ namespace SVF
{ {
NO_FEATURE, NO_FEATURE,
#if _GTA_III || _GTA_VC
TAXI_LIGHT, // Corrected light placement for Taxi
#endif
#if _GTA_VC
FBI_RANCHER_SIREN,
FBI_WASHINGTON_SIREN,
VICE_CHEETAH_SIREN,
#endif
#if _GTA_SA #if _GTA_SA
// Those are fully controlled by SilentPatch // Those are fully controlled by SilentPatch
PHOENIX_FLUTTER, PHOENIX_FLUTTER,

View File

@ -31,6 +31,11 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="..\SilentPatch\StoredCar.cpp" /> <ClCompile Include="..\SilentPatch\StoredCar.cpp" />
<ClCompile Include="..\SilentPatch\SVF.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Timer.cpp" /> <ClCompile Include="..\SilentPatch\Timer.cpp" />
<ClCompile Include="..\SilentPatch\Utils\Patterns.cpp"> <ClCompile Include="..\SilentPatch\Utils\Patterns.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
@ -53,6 +58,7 @@
<ClInclude Include="..\SilentPatch\RWGTA.h" /> <ClInclude Include="..\SilentPatch\RWGTA.h" />
<ClInclude Include="..\SilentPatch\StdAfx.h" /> <ClInclude Include="..\SilentPatch\StdAfx.h" />
<ClInclude Include="..\SilentPatch\StoredCar.h" /> <ClInclude Include="..\SilentPatch\StoredCar.h" />
<ClInclude Include="..\SilentPatch\SVF.h" />
<ClInclude Include="..\SilentPatch\Timer.h" /> <ClInclude Include="..\SilentPatch\Timer.h" />
<ClInclude Include="..\SilentPatch\Utils\MemoryMgr.GTA.h" /> <ClInclude Include="..\SilentPatch\Utils\MemoryMgr.GTA.h" />
<ClInclude Include="..\SilentPatch\Utils\MemoryMgr.h" /> <ClInclude Include="..\SilentPatch\Utils\MemoryMgr.h" />

View File

@ -48,6 +48,9 @@
<ClCompile Include="ModelInfoIII.cpp"> <ClCompile Include="ModelInfoIII.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\SilentPatch\SVF.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\SilentPatch\Timer.h"> <ClInclude Include="..\SilentPatch\Timer.h">
@ -89,6 +92,9 @@
<ClInclude Include="ModelInfoIII.h"> <ClInclude Include="ModelInfoIII.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\SilentPatch\SVF.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc"> <ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

View File

@ -12,8 +12,6 @@ enum eVehicleType
VEHICLE_PLANE VEHICLE_PLANE
}; };
constexpr uint16_t MI_TAXI = 110;
class CVehicle class CVehicle
{ {
protected: protected:

View File

@ -7,6 +7,7 @@
#include "Common_ddraw.h" #include "Common_ddraw.h"
#include "ModelInfoVC.h" #include "ModelInfoVC.h"
#include "VehicleVC.h" #include "VehicleVC.h"
#include "SVF.h"
#include <memory> #include <memory>
#include <Shlwapi.h> #include <Shlwapi.h>
@ -390,16 +391,23 @@ namespace FBISirenCoronaFix
// False - display siren // False - display siren
bool SetUpFBISiren( const CVehicle* vehicle ) bool SetUpFBISiren( const CVehicle* vehicle )
{ {
const int32_t modelIndex = vehicle->GetModelIndex(); SVF::Feature foundFeature = SVF::Feature::NO_FEATURE;
if ( modelIndex == MI_FBICAR || modelIndex == MI_FBIRANCH || modelIndex == MI_VICECHEE ) SVF::ForAllModelFeatures( vehicle->GetModelIndex(), [&]( SVF::Feature f ) {
if ( f >= SVF::Feature::FBI_RANCHER_SIREN && f <= SVF::Feature::VICE_CHEETAH_SIREN )
{ {
if ( modelIndex == MI_FBICAR || modelIndex == MI_FBIRANCH ) foundFeature = f;
}
} );
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 FBICAR_SIREN_POS = CVector(0.4f, 0.8f, 0.25f);
const CVector FBIRANCH_SIREN_POS = CVector(0.5f, 1.12f, 0.5f); const CVector FBIRANCH_SIREN_POS = CVector(0.5f, 1.12f, 0.5f);
overridePosition = true; overridePosition = true;
vecOverridePosition = modelIndex == MI_FBICAR ? FBICAR_SIREN_POS : FBIRANCH_SIREN_POS; vecOverridePosition = foundFeature == SVF::Feature::FBI_WASHINGTON_SIREN ? FBICAR_SIREN_POS : FBIRANCH_SIREN_POS;
} }
else else
{ {

View File

@ -177,6 +177,7 @@
<ClInclude Include="..\SilentPatch\RWGTA.h" /> <ClInclude Include="..\SilentPatch\RWGTA.h" />
<ClInclude Include="..\SilentPatch\StdAfx.h" /> <ClInclude Include="..\SilentPatch\StdAfx.h" />
<ClInclude Include="..\SilentPatch\StoredCar.h" /> <ClInclude Include="..\SilentPatch\StoredCar.h" />
<ClInclude Include="..\SilentPatch\SVF.h" />
<ClInclude Include="..\SilentPatch\Timer.h" /> <ClInclude Include="..\SilentPatch\Timer.h" />
<ClInclude Include="..\SilentPatch\Utils\MemoryMgr.GTA.h" /> <ClInclude Include="..\SilentPatch\Utils\MemoryMgr.GTA.h" />
<ClInclude Include="..\SilentPatch\Utils\MemoryMgr.h" /> <ClInclude Include="..\SilentPatch\Utils\MemoryMgr.h" />
@ -201,6 +202,11 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="..\SilentPatch\StoredCar.cpp" /> <ClCompile Include="..\SilentPatch\StoredCar.cpp" />
<ClCompile Include="..\SilentPatch\SVF.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Timer.cpp" /> <ClCompile Include="..\SilentPatch\Timer.cpp" />
<ClCompile Include="..\SilentPatch\Utils\Patterns.cpp"> <ClCompile Include="..\SilentPatch\Utils\Patterns.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>

View File

@ -57,6 +57,9 @@
<ClInclude Include="..\SilentPatch\Maths.h"> <ClInclude Include="..\SilentPatch\Maths.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\SilentPatch\SVF.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\SilentPatch\Timer.cpp"> <ClCompile Include="..\SilentPatch\Timer.cpp">
@ -86,6 +89,9 @@
<ClCompile Include="..\SilentPatch\RWGTA.cpp"> <ClCompile Include="..\SilentPatch\RWGTA.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\SilentPatch\SVF.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc"> <ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

View File

@ -13,11 +13,6 @@ enum eVehicleType
VEHICLE_BIKE VEHICLE_BIKE
}; };
constexpr uint16_t MI_FBICAR = 147;
constexpr uint16_t MI_TAXI = 150;
constexpr uint16_t MI_FBIRANCH = 220;
constexpr uint16_t MI_VICECHEE = 236;
class CVehicle class CVehicle
{ {
protected: protected: