1
1
/* ****************************************************************************
2
2
*
3
- * PROJECT: Multi Theft Auto v1.0
3
+ * PROJECT: Multi Theft Auto
4
4
* LICENSE: See LICENSE in the top level directory
5
5
* FILE: game_sa/CHudSA.cpp
6
6
* PURPOSE: HUD display
19
19
20
20
extern CGameSA* pGame;
21
21
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)
24
24
25
25
static ComponentProperties componentProperties;
26
26
@@ -56,23 +56,18 @@ CHudSA::CHudSA()
56
56
{
57
57
InitComponentList ();
58
58
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) ;
61
61
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)
66
65
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
68
69
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 ();
76
71
77
72
// Initalize default data
78
73
componentProperties.hpBar = MapGet (defaultComponentProperties, HUD_HEALTH);
@@ -198,8 +193,8 @@ bool CHudSA::IsComponentVisible(eHudComponent component)
198
193
199
194
void CHudSA::UpdateStreetchCalculations ()
200
195
{
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 );
203
198
204
199
SComponentPlacement& hpPlacement = componentProperties.hpBar .placement ;
205
200
hpPlacement.height = calcStreetchY * 9 .0f ;
@@ -265,14 +260,13 @@ void CHudSA::AdjustComponents(float fAspectRatio)
265
260
// Fix for #7400 (HUD elements do not scale correctly for widescreen)
266
261
// 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 /
267
262
// 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 ));
275
264
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
+
276
270
UpdateStreetchCalculations ();
277
271
}
278
272
@@ -282,9 +276,10 @@ void CHudSA::AdjustComponents(float fAspectRatio)
282
276
void CHudSA::ResetComponentAdjustment ()
283
277
{
284
278
// 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
288
283
289
284
UpdateStreetchCalculations ();
290
285
}
0 commit comments