III: Fix SetupBigBuilding for cranes, bright windows and others

This commit is contained in:
Silent 2019-12-24 00:02:06 +01:00
parent c803927c80
commit b46e91918c
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
5 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,8 @@
#include "StdAfx.h"
#include "ModelInfoIII.h"
void CSimpleModelInfo::SetNearDistanceForLOD_SilentPatch()
{
// 100.0f for real LOD's, 0.0f otherwise
m_lodDistances[2] = _strnicmp( m_name, "lod", 3 ) == 0 ? 100.0f : 0.0f;
}

View file

@ -0,0 +1,18 @@
#pragma once
#include <cstdint>
class CSimpleModelInfo
{
private:
void* __vmt;
char m_name[24];
uint8_t __pad[32];
float m_lodDistances[3];
uint8_t __pad2[4];
public:
void SetNearDistanceForLOD_SilentPatch();
};
static_assert(sizeof(CSimpleModelInfo) == 0x4C, "Wrong size: CSimpleModelInfo");

View file

@ -6,6 +6,7 @@
#include "Common.h"
#include "Common_ddraw.h"
#include "VehicleIII.h"
#include "ModelInfoIII.h"
#include <memory>
#include <Shlwapi.h>
@ -611,6 +612,23 @@ void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModul
InjectHook( match.get<void>(), UsesSirenSwitching_FbiCar );
}
}
// Corrected CSimpleModelInfo::SetupBigBuilding minimum draw distance for big buildings without a matching model
// Fixes cranes in Portland and bright windows in the city
// By aap
{
auto setupMinDist = pattern( "C7 43 44 00 00 C8 42" ).count_hint(1);
if ( setupMinDist.size() == 1 ) // In case of another mod or second instance of SP changing it
{
auto match = setupMinDist.get_one();
// mov ecx, ebx
// call CSimpleModelInfo::SetNearDistanceForLOD
Patch( match.get<void>(), { 0x89, 0xD9 } );
InjectHook( match.get<void>( 2 ), &CSimpleModelInfo::SetNearDistanceForLOD_SilentPatch, PATCH_CALL );
}
}
}
void InjectDelayedPatches_III_Common()

View file

@ -37,6 +37,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ModelInfoIII.cpp" />
<ClCompile Include="SilentPatchIII.cpp" />
<ClCompile Include="StdAfxIII.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@ -56,6 +57,7 @@
<ClInclude Include="..\SilentPatch\Utils\MemoryMgr.GTA.h" />
<ClInclude Include="..\SilentPatch\Utils\MemoryMgr.h" />
<ClInclude Include="..\SilentPatch\Utils\Patterns.h" />
<ClInclude Include="ModelInfoIII.h" />
<ClInclude Include="VehicleIII.h" />
</ItemGroup>
<ItemGroup>

View file

@ -45,6 +45,9 @@
<ClCompile Include="..\SilentPatch\RWGTA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ModelInfoIII.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\Timer.h">
@ -83,6 +86,9 @@
<ClInclude Include="..\SilentPatch\Maths.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ModelInfoIII.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">