Skip to content

Commit 07c2934

Browse files
committed
Revert " Fix HUD size when playing on widescreen (PR #3444, Fixes #848)"
This reverts commit 76f7cc2.
1 parent 0d04cec commit 07c2934

File tree

7 files changed

+32
-118
lines changed

7 files changed

+32
-118
lines changed

Client/game_sa/CHudSA.cpp

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto
3+
* PROJECT: Multi Theft Auto v1.0
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: game_sa/CHudSA.cpp
66
* PURPOSE: HUD display
@@ -19,8 +19,8 @@
1919

2020
extern CGameSA* pGame;
2121

22-
static float radarAltimeterFix = 0.0014625f; // Changes altimeter width (and maybe x pos)
23-
static constexpr float aspectRatioMultiplicatorUntouched = 0.0015625f; // (1 / 640)
22+
char szVehicleName[50] = {'\0'};
23+
char szZoneName[50] = {'\0'};
2424

2525
static ComponentProperties componentProperties;
2626

@@ -56,19 +56,24 @@ CHudSA::CHudSA()
5656
{
5757
InitComponentList();
5858

59-
m_pfAspectRatioMultiplicatorX = reinterpret_cast<float*>(VAR_AspectRatioMultX);
60-
m_pfAspectRatioMultiplicatorY = reinterpret_cast<float*>(VAR_AspectRatioMult);
59+
// Set the default values
60+
m_fSniperCrosshairScale = 210.0f;
6161

62-
MemPut<float>(0x866C84, 640.0f / ((4.0f / 3.0f) * 448.0f)); // 0x866C84: Weapon sprite x position
63-
MemPut<float>(m_pfAspectRatioMultiplicatorX, 0.0015625f); // (1 / 640)
64-
MemPut<float>(m_pfAspectRatioMultiplicatorY, 0.002232143f); // (1 / 448)
65-
66-
MemPut<const float*>(0x58B141, &aspectRatioMultiplicatorUntouched); // Vehicle name x pos
67-
MemPut<const float*>(0x58AE4C, &aspectRatioMultiplicatorUntouched); // Area name x pos
68-
MemPut<float*>(0x58A6E0, &radarAltimeterFix); // Fix radar altimeter
62+
m_pfCameraCrosshairScale = (float*)VAR_CameraCrosshairScale;
63+
MemPut<float>(m_pfCameraCrosshairScale, 192.0f);
64+
m_pfAspectRatioMultiplicator = (float*)VAR_AspectRatioMult;
65+
MemPut<float>(m_pfAspectRatioMultiplicator, 0.002232143f);
6966

7067
UpdateStreetchCalculations();
7168

69+
// Patch xrefs to 0x863B34, because this variable seems to be shared (2 other functions without any context access to it; probably a compiler optimization)
70+
MemPut<DWORD>(0x58E7D4 + 2, (DWORD)&m_fSniperCrosshairScale);
71+
MemPut<DWORD>(0x58E7EA + 2, (DWORD)&m_fSniperCrosshairScale);
72+
MemPut<DWORD>(0x53E3ED + 2, (DWORD)&m_fSniperCrosshairScale);
73+
MemPut<DWORD>(0x53E41A + 2, (DWORD)&m_fSniperCrosshairScale);
74+
MemPut<DWORD>(0x53E488 + 2, (DWORD)&m_fSniperCrosshairScale);
75+
MemPut<DWORD>(0x53E4BF + 2, (DWORD)&m_fSniperCrosshairScale);
76+
7277
// Initalize default data
7378
componentProperties.hpBar = MapGet(defaultComponentProperties, HUD_HEALTH);
7479
componentProperties.breathBar = MapGet(defaultComponentProperties, HUD_BREATH);
@@ -193,8 +198,8 @@ bool CHudSA::IsComponentVisible(eHudComponent component)
193198

194199
void CHudSA::UpdateStreetchCalculations()
195200
{
196-
calcStreetchX = rsGlobal->maximumWidth * (*m_pfAspectRatioMultiplicatorX);
197-
calcStreetchY = rsGlobal->maximumHeight * (*m_pfAspectRatioMultiplicatorY);
201+
calcStreetchX = rsGlobal->maximumWidth * (*reinterpret_cast<float*>(VAR_AspectRatioMultX));
202+
calcStreetchY = rsGlobal->maximumHeight * (*m_pfAspectRatioMultiplicator);
198203

199204
SComponentPlacement& hpPlacement = componentProperties.hpBar.placement;
200205
hpPlacement.height = calcStreetchY * 9.0f;
@@ -260,13 +265,14 @@ void CHudSA::AdjustComponents(float fAspectRatio)
260265
// Fix for #7400 (HUD elements do not scale correctly for widescreen)
261266
// 0x859524: GTA multiplies all HUD and menu transformation variables by this floating point value. It is equal to 1/448, so just translate it to 16/10 /
262267
// 16/9
263-
const float ratio = (640.0f / (fAspectRatio * 448.0f));
268+
MemPut<float>(m_pfAspectRatioMultiplicator, 0.002232143f / (4.0f / 3.0f) * fAspectRatio);
269+
270+
// Set the sniper crosshair scale (fix for #7659)
271+
m_fSniperCrosshairScale = 210.0f * (4.0f / 3.0f) / fAspectRatio;
272+
273+
// Set the camera crosshair scale (same display flaw as in #7659)
274+
MemPut<float>(m_pfCameraCrosshairScale, 192.0f * (4.0f / 3.0f) / fAspectRatio);
264275

265-
radarAltimeterFix = ratio * 0.00147f;
266-
MemPut<float>(m_pfAspectRatioMultiplicatorX, ratio * 0.0015625f);
267-
MemPut<float>(m_pfAspectRatioMultiplicatorY, ratio * 0.002232143f);
268-
MemPut<float>(0x866C84, ratio * 0.17343046f); // 0x866C84: Weapon sprite x position
269-
270276
UpdateStreetchCalculations();
271277
}
272278

@@ -276,10 +282,9 @@ void CHudSA::AdjustComponents(float fAspectRatio)
276282
void CHudSA::ResetComponentAdjustment()
277283
{
278284
// Restore default values (4:3 aspect ratio)
279-
radarAltimeterFix = 0.0014625f;
280-
MemPut<float>(m_pfAspectRatioMultiplicatorX, 0.0015625f); // (1 / 640)
281-
MemPut<float>(m_pfAspectRatioMultiplicatorY, 0.002232143f); // (1 / 448)
282-
MemPut<float>(0x866C84, 0.17343046f); // 0x866C84: Weapon sprite x position
285+
MemPut<float>(m_pfAspectRatioMultiplicator, 0.002232143f);
286+
MemPut<float>(m_pfCameraCrosshairScale, 192.0f);
287+
m_fSniperCrosshairScale = 210.0f;
283288

284289
UpdateStreetchCalculations();
285290
}

Client/game_sa/CHudSA.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ class CHudSA : public CHud
273273
private:
274274
std::map<eHudComponent, SHudComponent> m_HudComponentMap;
275275

276-
float* m_pfAspectRatioMultiplicatorX;
277-
float* m_pfAspectRatioMultiplicatorY;
276+
float* m_pfAspectRatioMultiplicator;
278277
float* m_pfCameraCrosshairScale;
279278
float m_fSniperCrosshairScale;
280279

Client/game_sa/CSettingsSA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CSettingsSA::CSettingsSA()
5151
HookInstall(HOOKPOS_StoreShadowForVehicle, (DWORD)HOOK_StoreShadowForVehicle, 9);
5252
m_iDesktopWidth = 0;
5353
m_iDesktopHeight = 0;
54-
MemPut<BYTE>(0x6FF420, 0xC3);
54+
MemPut<BYTE>(0x6FF420, 0xC3); // Truncate CalculateAspectRatio
5555

5656
MemPut(0x732926, &ms_fVehicleLODDistance);
5757
MemPut(0x732940, &ms_fTrainPlaneLODDistance);

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,6 @@ void CMultiplayerSA::InitHooks()
15911591

15921592
InitHooks_Streaming();
15931593
InitHooks_FrameRateFixes();
1594-
InitHooks_WidescreenFix();
15951594
InitHooks_ProjectileCollisionFix();
15961595
InitHooks_ObjectStreamerOptimization();
15971596

Client/multiplayer_sa/CMultiplayerSA.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class CMultiplayerSA : public CMultiplayer
7777
void InitHooks_FixLineOfSightArgs();
7878
void InitHooks_Streaming();
7979
void InitHooks_FrameRateFixes();
80-
void InitHooks_WidescreenFix();
8180
void InitHooks_ProjectileCollisionFix();
8281
void InitHooks_ObjectStreamerOptimization();
8382
void InitHooks_Postprocess();

Client/multiplayer_sa/CMultiplayerSA_WidescreenFix.cpp

Lines changed: 0 additions & 88 deletions
This file was deleted.

Client/sdk/game/CSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class CGameSettings
145145

146146
virtual float GetAspectRatioValue() = 0;
147147
virtual eAspectRatio GetAspectRatio() = 0;
148-
virtual void SetAspectRatio(eAspectRatio aspectRatio, bool isAdjustmentEnabled) = 0;
148+
virtual void SetAspectRatio(eAspectRatio aspectRatio, bool bAdjustmentEnabled = true) = 0;
149149

150150
virtual bool IsGrassEnabled() = 0;
151151
virtual void SetGrassEnabled(bool bEnable) = 0;

0 commit comments

Comments
 (0)