diff --git a/SilentPatch/Common.cpp b/SilentPatch/Common.cpp index ddefa14..bafe0cd 100644 --- a/SilentPatch/Common.cpp +++ b/SilentPatch/Common.cpp @@ -70,6 +70,31 @@ namespace StaticShadowAlphaFix } }; +// ============= Corrected corona placement for taxi ============= +namespace TaxiCoronaFix +{ + CVector& GetTransformedCoronaPos( CVector& out, float offsetZ, const CAutomobile* vehicle ) + { + CVector pos; + pos.x = 0.0f; + if ( vehicle->GetModelIndex() == MI_TAXI ) + { +#if _GTA_III + pos.y = -0.25f; +#elif _GTA_VC + pos.y = -0.4f; +#endif + pos.z = 0.9f; + } + else + { + pos.y = 0.0f; + pos.z = offsetZ; + } + return out = Multiply3x3( vehicle->GetMatrix(), pos ); + } +}; + // ============= Delayed patches ============= namespace DelayedPatches { @@ -173,6 +198,21 @@ namespace Common { ReadCall( renderStaticShadows, orgRenderStoredShadows ); InjectHook( renderStaticShadows, RenderStoredShadows_StateFix ); } + + // Corrected taxi light placement for Taxi + // TODO: INI entry + { + using namespace TaxiCoronaFix; + + auto getTaxiLightPos = pattern( "E8 ? ? ? ? D9 84 24 ? ? ? ? D8 84 24 ? ? ? ? 83 C4 0C FF 35" ); + + 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 ); + } + } } void III_VC_SetDelayedPatchesFunc( void(*func)() ) diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index bed7a45..9a2c1f2 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -493,27 +493,6 @@ 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; @@ -616,18 +595,6 @@ 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 6b0dbad..3088207 100644 --- a/SilentPatchIII/VehicleIII.h +++ b/SilentPatchIII/VehicleIII.h @@ -12,6 +12,8 @@ enum eVehicleType VEHICLE_PLANE }; +constexpr uint16_t MI_TAXI = 110; + class CVehicle { protected: diff --git a/SilentPatchVC/VehicleVC.h b/SilentPatchVC/VehicleVC.h index d8a3170..c5169f3 100644 --- a/SilentPatchVC/VehicleVC.h +++ b/SilentPatchVC/VehicleVC.h @@ -1,6 +1,7 @@ #pragma once #include +#include "Maths.h" enum eVehicleType { @@ -12,10 +13,18 @@ enum eVehicleType VEHICLE_BIKE }; +constexpr uint16_t MI_TAXI = 150; + class CVehicle { -private: - uint8_t __pad1[510]; +protected: + // TODO: Make this part of CEntity properly + void* __vmt; + CMatrix m_matrix; + uint8_t __pad4[16]; + uint16_t m_modelIndex; // TODO: THE FLA + + uint8_t __pad1[414]; uint8_t m_BombOnBoard : 3; uint8_t __pad2[17]; class CEntity* m_pBombOwner; @@ -24,6 +33,12 @@ private: public: + int32_t GetModelIndex() const + { return m_modelIndex; } + + const CMatrix& GetMatrix() const + { return m_matrix; } + uint32_t GetClass() const { return m_dwVehicleClass; } @@ -33,4 +48,8 @@ public: { m_pBombOwner = owner; } }; +class CAutomobile : public CVehicle +{ +}; + static_assert(sizeof(CVehicle) == 0x2A0, "Wrong size: CVehicle"); \ No newline at end of file