From 03a0cb68be6ed734d901c57c76c16b0806e4aee9 Mon Sep 17 00:00:00 2001 From: Silent Date: Wed, 11 Dec 2019 22:54:27 +0100 Subject: [PATCH] III: Fixed taxi light corona placement for Taxi --- SilentPatchIII/SilentPatchIII.cpp | 35 +++++++++++++++++++++++++++++++ SilentPatchIII/VehicleIII.h | 16 ++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index 0afe49f..bed7a45 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -5,6 +5,7 @@ #include "Utils/Patterns.h" #include "Common.h" #include "Common_ddraw.h" +#include "VehicleIII.h" #include #include @@ -491,6 +492,28 @@ namespace SirenSwitchingFix } }; + +// ============= Corrected siren corona placement for taxi ============= +namespace TaxiCoronaFix +{ + CVector& GetTransformedCoronaPos( CVector& out, float offsetZ, const CAutomobile* vehicle ) + { + CVector pos; + pos.x = 0.0f; + if ( vehicle->GetModelIndex() == 110 ) // TAXI + { + pos.y = -0.25f; + pos.z = 0.9f; + } + else + { + pos.y = 0.0f; + pos.z = offsetZ; + } + return out = Multiply3x3( vehicle->GetMatrix(), pos ); + } +}; + void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModulePath ) { using namespace Memory; @@ -593,6 +616,18 @@ void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModul Patch( enforcerZ2.get_first( 7 ), ENFORCER_SIREN_POS.z ); } } + { + using namespace TaxiCoronaFix; + + auto getTaxiLightPos = pattern( "E8 ? ? ? ? D9 84 24 ? ? ? ? D8 84 24 ? ? ? ? 83 C4 0C" ); + + if ( getTaxiLightPos.count_hint(1).size() == 1 ) + { + auto match = getTaxiLightPos.get_one(); + Patch( match.get( -15 ), 0x55 ); // push eax -> push ebp + InjectHook( match.get(), GetTransformedCoronaPos ); + } + } } diff --git a/SilentPatchIII/VehicleIII.h b/SilentPatchIII/VehicleIII.h index 143a50f..6b0dbad 100644 --- a/SilentPatchIII/VehicleIII.h +++ b/SilentPatchIII/VehicleIII.h @@ -1,6 +1,7 @@ #pragma once #include +#include "Maths.h" enum eVehicleType { @@ -13,12 +14,23 @@ enum eVehicleType class CVehicle { -private: - uint8_t __pad1[644]; +protected: + // TODO: Make this part of CEntity properly + void* __vmt; + CMatrix m_matrix; + uint8_t __pad2[16]; + uint16_t m_modelIndex; // TODO: THE FLA + uint8_t __pad1[548]; uint32_t m_dwVehicleClass; public: + int32_t GetModelIndex() const + { return m_modelIndex; } + + const CMatrix& GetMatrix() const + { return m_matrix; } + uint32_t GetClass() const { return m_dwVehicleClass; } };