mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
Additional compatibility code for widescreen fixes
This commit is contained in:
parent
ee0adecc4b
commit
048999d74a
3 changed files with 110 additions and 37 deletions
|
@ -37,31 +37,44 @@ static void (*PrintString)(float,float,const wchar_t*);
|
|||
static bool* bWantsToDrawHud;
|
||||
static bool* bCamCheck;
|
||||
static RsGlobalType* RsGlobal;
|
||||
static const float* ResolutionWidthMult;
|
||||
static const float* ResolutionHeightMult;
|
||||
static const void* SubtitlesShadowFix_JumpBack;
|
||||
|
||||
inline float GetWidthMult()
|
||||
{
|
||||
static const float& ResolutionWidthMult = **AddressByVersion<float**>(0x57E956, 0x57ECA6, 0x57EBA6);
|
||||
return ResolutionWidthMult;
|
||||
}
|
||||
|
||||
inline float GetHeightMult()
|
||||
{
|
||||
static const float& ResolutionHeightMult = **AddressByVersion<float**>(0x57E940, 0x57EC90, 0x57EB90);
|
||||
return ResolutionHeightMult;
|
||||
}
|
||||
|
||||
void ShowRadarTrace(float fX, float fY, unsigned int nScale, BYTE r, BYTE g, BYTE b, BYTE a)
|
||||
{
|
||||
if ( *bWantsToDrawHud == true && !*bCamCheck )
|
||||
{
|
||||
DrawRect(CRect( fX - ((nScale+1.0f) * *ResolutionWidthMult * RsGlobal->MaximumWidth),
|
||||
fY + ((nScale+1.0f) * *ResolutionHeightMult * RsGlobal->MaximumHeight),
|
||||
fX + ((nScale+1.0f) * *ResolutionWidthMult * RsGlobal->MaximumWidth),
|
||||
fY - ((nScale+1.0f) * *ResolutionHeightMult * RsGlobal->MaximumHeight)),
|
||||
float fWidthMult = GetWidthMult();
|
||||
float fHeightMult = GetHeightMult();
|
||||
|
||||
DrawRect(CRect( fX - ((nScale+1.0f) * fWidthMult * RsGlobal->MaximumWidth),
|
||||
fY + ((nScale+1.0f) * fHeightMult * RsGlobal->MaximumHeight),
|
||||
fX + ((nScale+1.0f) * fWidthMult * RsGlobal->MaximumWidth),
|
||||
fY - ((nScale+1.0f) * fHeightMult * RsGlobal->MaximumHeight)),
|
||||
CRGBA(0, 0, 0, a));
|
||||
|
||||
DrawRect(CRect( fX - (nScale * *ResolutionWidthMult * RsGlobal->MaximumWidth),
|
||||
fY + (nScale * *ResolutionHeightMult * RsGlobal->MaximumHeight),
|
||||
fX + (nScale * *ResolutionWidthMult * RsGlobal->MaximumWidth),
|
||||
fY - (nScale * *ResolutionHeightMult * RsGlobal->MaximumHeight)),
|
||||
DrawRect(CRect( fX - (nScale * fWidthMult * RsGlobal->MaximumWidth),
|
||||
fY + (nScale * fHeightMult * RsGlobal->MaximumHeight),
|
||||
fX + (nScale * fWidthMult * RsGlobal->MaximumWidth),
|
||||
fY - (nScale * fHeightMult * RsGlobal->MaximumHeight)),
|
||||
CRGBA(r, g, b, a));
|
||||
}
|
||||
}
|
||||
|
||||
void SetScaleProperly(float fX, float fY)
|
||||
{
|
||||
SetScale(fX * *ResolutionWidthMult * RsGlobal->MaximumWidth, fY * *ResolutionHeightMult * RsGlobal->MaximumHeight);
|
||||
SetScale(fX * GetWidthMult() * RsGlobal->MaximumWidth, fY * GetHeightMult() * RsGlobal->MaximumHeight);
|
||||
}
|
||||
|
||||
void PurpleNinesGlitchFix()
|
||||
|
@ -117,8 +130,8 @@ static float fShadowXSize, fShadowYSize;
|
|||
|
||||
void __stdcall Recalculate(signed int nShadow)
|
||||
{
|
||||
fShadowXSize = nShadow * *ResolutionWidthMult * RsGlobal->MaximumWidth;
|
||||
fShadowYSize = nShadow * *ResolutionHeightMult * RsGlobal->MaximumHeight;
|
||||
fShadowXSize = nShadow * GetWidthMult() * RsGlobal->MaximumWidth;
|
||||
fShadowYSize = nShadow * GetHeightMult() * RsGlobal->MaximumHeight;
|
||||
}
|
||||
|
||||
template<int pFltX, int pFltY>
|
||||
|
@ -126,7 +139,7 @@ void AlteredPrintString(float fX, float fY, const wchar_t* pText)
|
|||
{
|
||||
float fMarginX = **reinterpret_cast<float**>(pFltX);
|
||||
float fMarginY = **reinterpret_cast<float**>(pFltY);
|
||||
PrintString(fX - fMarginX + (fMarginX * *ResolutionWidthMult * RsGlobal->MaximumWidth), fY - fMarginY + (fMarginY * *ResolutionHeightMult * RsGlobal->MaximumHeight), pText);
|
||||
PrintString(fX - fMarginX + (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY - fMarginY + (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText);
|
||||
}
|
||||
|
||||
template<int pFltX, int pFltY>
|
||||
|
@ -134,21 +147,21 @@ void AlteredPrintStringMinus(float fX, float fY, const wchar_t* pText)
|
|||
{
|
||||
float fMarginX = **reinterpret_cast<float**>(pFltX);
|
||||
float fMarginY = **reinterpret_cast<float**>(pFltY);
|
||||
PrintString(fX + fMarginX - (fMarginX * *ResolutionWidthMult * RsGlobal->MaximumWidth), fY + fMarginY - (fMarginY * *ResolutionHeightMult * RsGlobal->MaximumHeight), pText);
|
||||
PrintString(fX + fMarginX - (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY + fMarginY - (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText);
|
||||
}
|
||||
|
||||
template<int pFltX>
|
||||
void AlteredPrintStringXOnly(float fX, float fY, const wchar_t* pText)
|
||||
{
|
||||
float fMarginX = **reinterpret_cast<float**>(pFltX);
|
||||
PrintString(fX - fMarginX + (fMarginX * *ResolutionWidthMult * RsGlobal->MaximumWidth), fY, pText);
|
||||
PrintString(fX - fMarginX + (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY, pText);
|
||||
}
|
||||
|
||||
template<int pFltY>
|
||||
void AlteredPrintStringYOnly(float fX, float fY, const wchar_t* pText)
|
||||
{
|
||||
float fMarginY = **reinterpret_cast<float**>(pFltY);
|
||||
PrintString(fX, fY - fMarginY + (fMarginY * *ResolutionHeightMult * RsGlobal->MaximumHeight), pText);
|
||||
PrintString(fX, fY - fMarginY + (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText);
|
||||
}
|
||||
|
||||
float FixedRefValue()
|
||||
|
@ -182,8 +195,6 @@ void Patch_III_10()
|
|||
bWantsToDrawHud = *(bool**)0x4A5877;
|
||||
bCamCheck = *(bool**)0x4A588C;
|
||||
RsGlobal = *(RsGlobalType**)0x584C42;
|
||||
ResolutionWidthMult = *(float**)0x57E956;
|
||||
ResolutionHeightMult = *(float**)0x57E940;
|
||||
HeadlightsFix_JumpBack = (void*)0x5382F2;
|
||||
SubtitlesShadowFix_JumpBack = (void*)0x500D32;
|
||||
|
||||
|
@ -295,8 +306,6 @@ void Patch_III_11()
|
|||
bWantsToDrawHud = *(bool**)0x4A5967;
|
||||
bCamCheck = *(bool**)0x4A597C;
|
||||
RsGlobal = *(RsGlobalType**)0x584F82;
|
||||
ResolutionWidthMult = *(float**)0x57ECA6;
|
||||
ResolutionHeightMult = *(float**)0x57EC90;
|
||||
HeadlightsFix_JumpBack = (void*)0x538532;
|
||||
SubtitlesShadowFix_JumpBack = (void*)0x500E12;
|
||||
|
||||
|
@ -402,8 +411,6 @@ void Patch_III_Steam()
|
|||
bWantsToDrawHud = *(bool**)0x4A58F7;
|
||||
bCamCheck = *(bool**)0x4A590C;
|
||||
RsGlobal = *(RsGlobalType**)0x584E72;
|
||||
ResolutionWidthMult = *(float**)0x57EBA6;
|
||||
ResolutionHeightMult = *(float**)0x57EB90;
|
||||
SubtitlesShadowFix_JumpBack = (void*)0x500DA2;
|
||||
|
||||
CTimer::ms_fTimeScale = *(float**)0x43F73F;
|
||||
|
|
|
@ -35,6 +35,66 @@ inline void* GetDummy()
|
|||
return &dwDummy;
|
||||
}
|
||||
|
||||
#if defined SILENTPATCH_III_VER
|
||||
|
||||
// This function initially detects III version then chooses the address basing on game version
|
||||
template<typename T>
|
||||
inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
||||
{
|
||||
signed char* bVer = GetVer();
|
||||
|
||||
if ( *bVer == -1 )
|
||||
{
|
||||
if (*(DWORD*)0x5C1E70 == 0x53E58955) *bVer = 0;
|
||||
else if (*(DWORD*)0x5C2130 == 0x53E58955) *bVer = 1;
|
||||
else if (*(DWORD*)0x5C6FD0 == 0x53E58955) *bVer = 2;
|
||||
}
|
||||
|
||||
switch ( *bVer )
|
||||
{
|
||||
case 1:
|
||||
assert(address11);
|
||||
return (T)address11;
|
||||
case 2:
|
||||
assert(addressSteam);
|
||||
return (T)addressSteam;
|
||||
default:
|
||||
assert(address10);
|
||||
return (T)address10;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined SILENTPATCH_VC_VER
|
||||
|
||||
// This function initially detects VC version then chooses the address basing on game version
|
||||
template<typename T>
|
||||
inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
||||
{
|
||||
signed char* bVer = GetVer();
|
||||
|
||||
if ( *bVer == -1 )
|
||||
{
|
||||
if (*(DWORD*)0x667BF0 == 0x53E58955) *bVer = 0;
|
||||
else if (*(DWORD*)0x667C40 == 0x53E58955) *bVer = 1;
|
||||
else if (*(DWORD*)0x666BA0 == 0x53E58955) *bVer = 2;
|
||||
}
|
||||
|
||||
switch ( *bVer )
|
||||
{
|
||||
case 1:
|
||||
assert(address11);
|
||||
return (T)address11;
|
||||
case 2:
|
||||
assert(addressSteam);
|
||||
return (T)addressSteam;
|
||||
default:
|
||||
assert(address10);
|
||||
return (T)address10;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// This function initially detects SA version then chooses the address basing on game version
|
||||
template<typename T>
|
||||
inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
||||
|
@ -180,6 +240,8 @@ inline T AddressByRegion_11(DWORD address11)
|
|||
return (T)address11;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
template<typename T, typename AT>
|
||||
|
|
|
@ -24,10 +24,20 @@ void (__stdcall *AudioResetTimers)(unsigned int);
|
|||
static void (*PrintString)(float,float,const wchar_t*);
|
||||
|
||||
static RsGlobalType* RsGlobal;
|
||||
static const float* ResolutionWidthMult;
|
||||
static const float* ResolutionHeightMult;
|
||||
static const void* SubtitlesShadowFix_JumpBack;
|
||||
|
||||
inline float GetWidthMult()
|
||||
{
|
||||
static const float& ResolutionWidthMult = **AddressByVersion<float**>(0x5FA15E, 0x5FA17E, 0x5F9DBE);
|
||||
return ResolutionWidthMult;
|
||||
}
|
||||
|
||||
inline float GetHeightMult()
|
||||
{
|
||||
static const float& ResolutionHeightMult = **AddressByVersion<float**>(0x5FA148, 0x5FA168, 0x5F9DA8);
|
||||
return ResolutionHeightMult;
|
||||
}
|
||||
|
||||
|
||||
void __declspec(naked) RosiesAudioFix()
|
||||
{
|
||||
|
@ -41,8 +51,8 @@ void __declspec(naked) RosiesAudioFix()
|
|||
|
||||
void __stdcall Recalculate(float& fX, float& fY, signed int nShadow)
|
||||
{
|
||||
fX = nShadow * *ResolutionWidthMult * RsGlobal->MaximumWidth;
|
||||
fY = nShadow * *ResolutionHeightMult * RsGlobal->MaximumHeight;
|
||||
fX = nShadow * GetWidthMult() * RsGlobal->MaximumWidth;
|
||||
fY = nShadow * GetHeightMult() * RsGlobal->MaximumHeight;
|
||||
}
|
||||
|
||||
template<int pFltX, int pFltY>
|
||||
|
@ -50,7 +60,7 @@ void AlteredPrintString(float fX, float fY, const wchar_t* pText)
|
|||
{
|
||||
float fMarginX = **reinterpret_cast<float**>(pFltX);
|
||||
float fMarginY = **reinterpret_cast<float**>(pFltY);
|
||||
PrintString(fX - fMarginX + (fMarginX * *ResolutionWidthMult * RsGlobal->MaximumWidth), fY - fMarginY + (fMarginY * *ResolutionHeightMult * RsGlobal->MaximumHeight), pText);
|
||||
PrintString(fX - fMarginX + (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY - fMarginY + (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText);
|
||||
}
|
||||
|
||||
template<int pFltX, int pFltY>
|
||||
|
@ -58,21 +68,21 @@ void AlteredPrintStringMinus(float fX, float fY, const wchar_t* pText)
|
|||
{
|
||||
float fMarginX = **reinterpret_cast<float**>(pFltX);
|
||||
float fMarginY = **reinterpret_cast<float**>(pFltY);
|
||||
PrintString(fX + fMarginX - (fMarginX * *ResolutionWidthMult * RsGlobal->MaximumWidth), fY + fMarginY - (fMarginY * *ResolutionHeightMult * RsGlobal->MaximumHeight), pText);
|
||||
PrintString(fX + fMarginX - (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY + fMarginY - (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText);
|
||||
}
|
||||
|
||||
template<int pFltX>
|
||||
void AlteredPrintStringXOnly(float fX, float fY, const wchar_t* pText)
|
||||
{
|
||||
float fMarginX = **reinterpret_cast<float**>(pFltX);
|
||||
PrintString(fX - fMarginX + (fMarginX * *ResolutionWidthMult * RsGlobal->MaximumWidth), fY, pText);
|
||||
PrintString(fX - fMarginX + (fMarginX * GetWidthMult() * RsGlobal->MaximumWidth), fY, pText);
|
||||
}
|
||||
|
||||
template<int pFltY>
|
||||
void AlteredPrintStringYOnly(float fX, float fY, const wchar_t* pText)
|
||||
{
|
||||
float fMarginY = **reinterpret_cast<float**>(pFltY);
|
||||
PrintString(fX, fY - fMarginY + (fMarginY * *ResolutionHeightMult * RsGlobal->MaximumHeight), pText);
|
||||
PrintString(fX, fY - fMarginY + (fMarginY * GetHeightMult() * RsGlobal->MaximumHeight), pText);
|
||||
}
|
||||
|
||||
float FixedRefValue()
|
||||
|
@ -106,8 +116,6 @@ void Patch_VC_10()
|
|||
|
||||
bSnapShotActive = *(bool**)0x4D1239;
|
||||
RsGlobal = *(RsGlobalType**)0x602D32;
|
||||
ResolutionWidthMult = *(float**)0x5FA15E;
|
||||
ResolutionHeightMult = *(float**)0x5FA148;
|
||||
RosieAudioFix_JumpBack = (void*)0x42BFFE;
|
||||
SubtitlesShadowFix_JumpBack = (void*)0x551701;
|
||||
|
||||
|
@ -166,8 +174,6 @@ void Patch_VC_11()
|
|||
|
||||
bSnapShotActive = *(bool**)0x4D1259;
|
||||
RsGlobal = *(RsGlobalType**)0x602D12;
|
||||
ResolutionWidthMult = *(float**)0x5FA17E;
|
||||
ResolutionHeightMult = *(float**)0x5FA168;
|
||||
RosieAudioFix_JumpBack = (void*)0x42BFFE;
|
||||
SubtitlesShadowFix_JumpBack = (void*)0x551721;
|
||||
|
||||
|
@ -226,8 +232,6 @@ void Patch_VC_Steam()
|
|||
|
||||
bSnapShotActive = *(bool**)0x4D10F9;
|
||||
RsGlobal = *(RsGlobalType**)0x602952;
|
||||
ResolutionWidthMult = *(float**)0x5F9DBE;
|
||||
ResolutionHeightMult = *(float**)0x5F9DA8;
|
||||
RosieAudioFix_JumpBack = (void*)0x42BFCE;
|
||||
SubtitlesShadowFix_JumpBack = (void*)0x5515F1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue