1
1
/* ****************************************************************************
2
2
*
3
- * PROJECT: Multi Theft Auto
3
+ * PROJECT: Multi Theft Auto v1.0
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
- 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 ' };
24
24
25
25
static ComponentProperties componentProperties;
26
26
@@ -56,19 +56,24 @@ CHudSA::CHudSA()
56
56
{
57
57
InitComponentList ();
58
58
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 ;
61
61
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 );
69
66
70
67
UpdateStreetchCalculations ();
71
68
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
+
72
77
// Initalize default data
73
78
componentProperties.hpBar = MapGet (defaultComponentProperties, HUD_HEALTH);
74
79
componentProperties.breathBar = MapGet (defaultComponentProperties, HUD_BREATH);
@@ -193,8 +198,8 @@ bool CHudSA::IsComponentVisible(eHudComponent component)
193
198
194
199
void CHudSA::UpdateStreetchCalculations ()
195
200
{
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 );
198
203
199
204
SComponentPlacement& hpPlacement = componentProperties.hpBar .placement ;
200
205
hpPlacement.height = calcStreetchY * 9 .0f ;
@@ -260,13 +265,14 @@ void CHudSA::AdjustComponents(float fAspectRatio)
260
265
// Fix for #7400 (HUD elements do not scale correctly for widescreen)
261
266
// 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 /
262
267
// 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 );
264
275
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
-
270
276
UpdateStreetchCalculations ();
271
277
}
272
278
@@ -276,10 +282,9 @@ void CHudSA::AdjustComponents(float fAspectRatio)
276
282
void CHudSA::ResetComponentAdjustment ()
277
283
{
278
284
// 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 ;
283
288
284
289
UpdateStreetchCalculations ();
285
290
}
0 commit comments