diff --git a/SilentPatchIII/ModelInfoIII.cpp b/SilentPatchIII/ModelInfoIII.cpp new file mode 100644 index 0000000..2fa52db --- /dev/null +++ b/SilentPatchIII/ModelInfoIII.cpp @@ -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; +} diff --git a/SilentPatchIII/ModelInfoIII.h b/SilentPatchIII/ModelInfoIII.h new file mode 100644 index 0000000..8d573e2 --- /dev/null +++ b/SilentPatchIII/ModelInfoIII.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +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"); \ No newline at end of file diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index 3ec4edf..7b78da0 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -6,6 +6,7 @@ #include "Common.h" #include "Common_ddraw.h" #include "VehicleIII.h" +#include "ModelInfoIII.h" #include #include @@ -611,6 +612,23 @@ void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModul InjectHook( match.get(), 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(), { 0x89, 0xD9 } ); + InjectHook( match.get( 2 ), &CSimpleModelInfo::SetNearDistanceForLOD_SilentPatch, PATCH_CALL ); + } + } } void InjectDelayedPatches_III_Common() diff --git a/SilentPatchIII/SilentPatchIII.vcxproj b/SilentPatchIII/SilentPatchIII.vcxproj index a5ff2e6..316e48b 100644 --- a/SilentPatchIII/SilentPatchIII.vcxproj +++ b/SilentPatchIII/SilentPatchIII.vcxproj @@ -37,6 +37,7 @@ NotUsing NotUsing + Create @@ -56,6 +57,7 @@ + diff --git a/SilentPatchIII/SilentPatchIII.vcxproj.filters b/SilentPatchIII/SilentPatchIII.vcxproj.filters index f36b263..f24c11e 100644 --- a/SilentPatchIII/SilentPatchIII.vcxproj.filters +++ b/SilentPatchIII/SilentPatchIII.vcxproj.filters @@ -45,6 +45,9 @@ Source Files + + Source Files + @@ -83,6 +86,9 @@ Header Files + + Header Files +