III: Fixed taxi light corona placement for Taxi

This commit is contained in:
Silent 2019-12-11 22:54:27 +01:00
parent 9b26855d3d
commit 03a0cb68be
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
2 changed files with 49 additions and 2 deletions

View file

@ -5,6 +5,7 @@
#include "Utils/Patterns.h" #include "Utils/Patterns.h"
#include "Common.h" #include "Common.h"
#include "Common_ddraw.h" #include "Common_ddraw.h"
#include "VehicleIII.h"
#include <memory> #include <memory>
#include <Shlwapi.h> #include <Shlwapi.h>
@ -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 ) void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModulePath )
{ {
using namespace Memory; using namespace Memory;
@ -593,6 +616,18 @@ 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

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include "Maths.h"
enum eVehicleType enum eVehicleType
{ {
@ -13,12 +14,23 @@ enum eVehicleType
class CVehicle class CVehicle
{ {
private: protected:
uint8_t __pad1[644]; // 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; uint32_t m_dwVehicleClass;
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; }
}; };