III/VC: Moved taxi corona fix to shared code

This commit is contained in:
Silent 2019-12-15 18:12:34 +01:00
parent 330f1e3072
commit 7aebe3f355
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
4 changed files with 63 additions and 35 deletions

View File

@ -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 ============= // ============= Delayed patches =============
namespace DelayedPatches namespace DelayedPatches
{ {
@ -173,6 +198,21 @@ namespace Common {
ReadCall( renderStaticShadows, orgRenderStoredShadows ); ReadCall( renderStaticShadows, orgRenderStoredShadows );
InjectHook( renderStaticShadows, RenderStoredShadows_StateFix ); 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<uint8_t>( match.get<void>( -15 ), 0x55 ); // push eax -> push ebp
InjectHook( match.get<void>(), GetTransformedCoronaPos );
}
}
} }
void III_VC_SetDelayedPatchesFunc( void(*func)() ) void III_VC_SetDelayedPatchesFunc( void(*func)() )

View File

@ -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 ) void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModulePath )
{ {
using namespace Memory; using namespace Memory;
@ -616,18 +595,6 @@ void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModul
Patch<float>( enforcerZ2.get_first( 7 ), ENFORCER_SIREN_POS.z ); Patch<float>( 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<uint8_t>( match.get<void>( -15 ), 0x55 ); // push eax -> push ebp
InjectHook( match.get<void>(), GetTransformedCoronaPos );
}
}
} }

View File

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

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include "Maths.h"
enum eVehicleType enum eVehicleType
{ {
@ -12,10 +13,18 @@ enum eVehicleType
VEHICLE_BIKE VEHICLE_BIKE
}; };
constexpr uint16_t MI_TAXI = 150;
class CVehicle class CVehicle
{ {
private: protected:
uint8_t __pad1[510]; // 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 m_BombOnBoard : 3;
uint8_t __pad2[17]; uint8_t __pad2[17];
class CEntity* m_pBombOwner; class CEntity* m_pBombOwner;
@ -24,6 +33,12 @@ private:
public: public:
int32_t GetModelIndex() const
{ return m_modelIndex; }
const CMatrix& GetMatrix() const
{ return m_matrix; }
uint32_t GetClass() const uint32_t GetClass() const
{ return m_dwVehicleClass; } { return m_dwVehicleClass; }
@ -33,4 +48,8 @@ public:
{ m_pBombOwner = owner; } { m_pBombOwner = owner; }
}; };
class CAutomobile : public CVehicle
{
};
static_assert(sizeof(CVehicle) == 0x2A0, "Wrong size: CVehicle"); static_assert(sizeof(CVehicle) == 0x2A0, "Wrong size: CVehicle");