11/* ****************************************************************************
22 *
3- * PROJECT: Multi Theft Auto v1.0
3+ * PROJECT: Multi Theft Auto
44 * LICENSE: See LICENSE in the top level directory
55 * FILE: game_sa/CHudSA.cpp
66 * PURPOSE: HUD display
1919
2020extern CGameSA* pGame;
2121
22- char szVehicleName[ 50 ] = { ' \0 ' };
23- char szZoneName[ 50 ] = { ' \0 ' };
22+ static float radarAltimeterFix = 0 . 0014625f ; // Changes altimeter width (and maybe x pos)
23+ static constexpr float aspectRatioMultiplicatorUntouched = 0 . 0015625f ; // (1 / 640)
2424
2525static ComponentProperties componentProperties;
2626
@@ -56,23 +56,18 @@ CHudSA::CHudSA()
5656{
5757 InitComponentList ();
5858
59- // Set the default values
60- m_fSniperCrosshairScale = 210 . 0f ;
59+ m_pfAspectRatioMultiplicatorX = reinterpret_cast < float *>(VAR_AspectRatioMultX);
60+ m_pfAspectRatioMultiplicatorY = reinterpret_cast < float *>(VAR_AspectRatioMult) ;
6161
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 );
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)
6665
67- UpdateStreetchCalculations ();
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
6869
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);
70+ UpdateStreetchCalculations ();
7671
7772 // Initalize default data
7873 componentProperties.hpBar = MapGet (defaultComponentProperties, HUD_HEALTH);
@@ -198,8 +193,8 @@ bool CHudSA::IsComponentVisible(eHudComponent component)
198193
199194void CHudSA::UpdateStreetchCalculations ()
200195{
201- calcStreetchX = rsGlobal->maximumWidth * (*reinterpret_cast < float *>(VAR_AspectRatioMultX) );
202- calcStreetchY = rsGlobal->maximumHeight * (*m_pfAspectRatioMultiplicator );
196+ calcStreetchX = rsGlobal->maximumWidth * (*m_pfAspectRatioMultiplicatorX );
197+ calcStreetchY = rsGlobal->maximumHeight * (*m_pfAspectRatioMultiplicatorY );
203198
204199 SComponentPlacement& hpPlacement = componentProperties.hpBar .placement ;
205200 hpPlacement.height = calcStreetchY * 9 .0f ;
@@ -265,14 +260,13 @@ void CHudSA::AdjustComponents(float fAspectRatio)
265260 // Fix for #7400 (HUD elements do not scale correctly for widescreen)
266261 // 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 /
267262 // 16/9
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 );
263+ const float ratio = (640 .0f / (fAspectRatio * 448 .0f ));
275264
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+
276270 UpdateStreetchCalculations ();
277271}
278272
@@ -282,9 +276,10 @@ void CHudSA::AdjustComponents(float fAspectRatio)
282276void CHudSA::ResetComponentAdjustment ()
283277{
284278 // Restore default values (4:3 aspect ratio)
285- MemPut<float >(m_pfAspectRatioMultiplicator, 0 .002232143f );
286- MemPut<float >(m_pfCameraCrosshairScale, 192 .0f );
287- m_fSniperCrosshairScale = 210 .0f ;
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
288283
289284 UpdateStreetchCalculations ();
290285}
0 commit comments