Extras working correctly on bikes - VC

This commit is contained in:
Silent 2018-03-27 22:28:45 +02:00
parent f853e96918
commit fcc799645f
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
6 changed files with 71 additions and 0 deletions

View File

@ -1,6 +1,8 @@
#ifndef __GENERAL
#define __GENERAL
#include <cstdint>
class CRGBA
{
public:

View File

@ -0,0 +1,24 @@
#include "StdAfx.h"
#include "ModelInfoVC.h"
#include "VehicleVC.h"
auto GetFrameFromId = hook::get_pattern<RwFrame*(RpClump*,int)>( "8B 4C 24 0C 89 04 24", -7 );
RwFrame* CVehicleModelInfo::GetExtrasFrame( RpClump* clump )
{
RwFrame* frame;
if ( m_dwType == VEHICLE_AUTOMOBILE || m_dwType == VEHICLE_BIKE )
{
frame = GetFrameFromId( clump, 1 );
if ( frame == nullptr )
{
frame = RpClumpGetFrame( clump );
}
}
else
{
frame = RpClumpGetFrame( clump );
}
return frame;
}

View File

@ -0,0 +1,18 @@
#pragma once
#include "General.h"
#include <rwcore.h>
#include <rpworld.h>
class CVehicleModelInfo
{
private:
uint8_t __pad1[60];
unsigned int m_dwType;
uint8_t __pad2[308];
public:
RwFrame* GetExtrasFrame( RpClump* clump );
};
static_assert(sizeof(CVehicleModelInfo) == 0x174, "Wrong size: CvehicleModelInfo");

View File

@ -5,6 +5,7 @@
#include "Common.h"
#include "Common_ddraw.h"
#include "General.h"
#include "ModelInfoVC.h"
#include <memory>
@ -146,6 +147,17 @@ void __declspec(naked) SubtitlesShadowFix()
}
}
void __declspec(naked) CreateInstance_BikeFix()
{
_asm
{
push eax
mov ecx, ebp
call CVehicleModelInfo::GetExtrasFrame
retn
}
}
extern char** ppUserFilesDir = AddressByVersion<char**>(0x6022AA, 0x60228A, 0x601ECA);
static LARGE_INTEGER FrameTime;
@ -666,6 +678,13 @@ void Patch_VC_Common()
InjectHook( give_weapon, GiveWeapon_SP );
}
// Extras working correctly on bikes
{
auto createInstance = get_pattern( "89 C1 8B 41 04" );
InjectHook( createInstance, CreateInstance_BikeFix, PATCH_CALL );
}
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

View File

@ -181,6 +181,7 @@
<ClInclude Include="..\SilentPatch\StdAfx.h" />
<ClInclude Include="..\SilentPatch\StoredCar.h" />
<ClInclude Include="..\SilentPatch\Timer.h" />
<ClInclude Include="ModelInfoVC.h" />
<ClInclude Include="VehicleVC.h" />
</ItemGroup>
<ItemGroup>
@ -201,6 +202,7 @@
</ClCompile>
<ClCompile Include="..\SilentPatch\StoredCar.cpp" />
<ClCompile Include="..\SilentPatch\Timer.cpp" />
<ClCompile Include="ModelInfoVC.cpp" />
<ClCompile Include="SilentPatchVC.cpp" />
<ClCompile Include="StdAfxVC.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

View File

@ -39,6 +39,9 @@
<ClInclude Include="..\SilentPatch\Common_ddraw.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ModelInfoVC.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\Timer.cpp">
@ -62,6 +65,9 @@
<ClCompile Include="..\SilentPatch\Common_ddraw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ModelInfoVC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">