Skip to content

Commit e5d8db3

Browse files
committed
Fixed FOV setting not updating
1 parent 236cf93 commit e5d8db3

File tree

7 files changed

+51
-31
lines changed

7 files changed

+51
-31
lines changed

Client/core/CCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,11 @@ void CCore::ApplyGameSettings ( void )
611611
CVARS_GET ( "classic_controls", bval ); pController->SetClassicControls ( bval );
612612
CVARS_GET ( "volumetric_shadows", bval ); m_pGame->GetSettings ()->SetVolumetricShadowsEnabled ( bval );
613613
CVARS_GET ( "aspect_ratio", iVal ); m_pGame->GetSettings ()->SetAspectRatio ( (eAspectRatio)iVal, CVARS_GET_VALUE < bool > ( "hud_match_aspect_ratio" ) );
614-
CVARS_GET ( "fov", iVal ); iVal = Clamp ( 70, iVal, 100 ); m_pGame->GetSettings ()->SetFieldOfView ( iVal );
615614
CVARS_GET ( "grass", bval ); m_pGame->GetSettings ()->SetGrassEnabled ( bval );
616615
CVARS_GET ( "heat_haze", bval ); m_pMultiplayer->SetHeatHazeEnabled ( bval );
617616
CVARS_GET ( "fast_clothes_loading", iVal ); m_pMultiplayer->SetFastClothesLoading ( (CMultiplayer::EFastClothesLoading)iVal );
618617
CVARS_GET ( "tyre_smoke_enabled", bval ); m_pMultiplayer->SetTyreSmokeEnabled ( bval );
618+
m_pGame->GetSettings ()->UpdateFieldOfViewFromSettings();
619619
m_pGame->GetSettings ()->ResetVehiclesLODDistance ( );
620620
pController->SetVerticalAimSensitivityRawValue( CVARS_GET_VALUE < float > ( "vertical_aim_sensitivity" ) );
621621
}

Client/core/CSettings.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,13 +2008,6 @@ bool CSettings::OnVideoDefaultClick ( CGUIElement* pElement )
20082008
{
20092009
CGameSettings * gameSettings = CCore::GetSingleton ().GetGame ()->GetSettings ();
20102010

2011-
2012-
//gameSettings->SetMipMappingEnabled (); // Doesn't appear to even be enabled
2013-
gameSettings->SetFieldOfView( 70 );
2014-
gameSettings->SetDrawDistance( 1.19625f ); // All values taken from a default SA install, no gta_sa.set or coreconfig.xml modifications.
2015-
gameSettings->SetBrightness ( 253 );
2016-
gameSettings->SetFXQuality ( 2 );
2017-
gameSettings->SetAntiAliasing ( 1, true );
20182011
CVARS_SET ("aspect_ratio", ASPECT_RATIO_AUTO );
20192012
CVARS_SET ("fov", 70 );
20202013
CVARS_SET ("anisotropic", 0 );
@@ -2023,6 +2016,11 @@ bool CSettings::OnVideoDefaultClick ( CGUIElement* pElement )
20232016
CVARS_SET ( "heat_haze", true );
20242017
CVARS_SET ( "tyre_smoke_enabled", true );
20252018
CVARS_SET ( "high_detail_vehicles", false );
2019+
gameSettings->UpdateFieldOfViewFromSettings();
2020+
gameSettings->SetDrawDistance( 1.19625f ); // All values taken from a default SA install, no gta_sa.set or coreconfig.xml modifications.
2021+
gameSettings->SetBrightness ( 253 );
2022+
gameSettings->SetFXQuality ( 2 );
2023+
gameSettings->SetAntiAliasing ( 1, true );
20262024

20272025
// change
20282026
bool bIsVideoModeChanged = GetVideoModeManager ()->SetVideoMode ( 0, false, false, FULLSCREEN_STANDARD );
@@ -3022,6 +3020,7 @@ void CSettings::SaveData ( void )
30223020
// iFieldOfView
30233021
int iFieldOfView = std::min < int > ( 4, ( m_pFieldOfView->GetScrollPosition () ) * ( 4 + 1 ) ) * 5 + 70;
30243022
CVARS_SET ( "fov", iFieldOfView );
3023+
gameSettings->UpdateFieldOfViewFromSettings();
30253024

30263025
// Anisotropic filtering
30273026
int iAnisotropic = std::min < int > ( m_iMaxAnisotropic, ( m_pAnisotropic->GetScrollPosition () ) * ( m_iMaxAnisotropic + 1 ) );

Client/game_sa/CSettingsSA.cpp

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ void CSettingsSA::SetRadarMode ( eRadarMode hudMode )
491491
float ms_fFOV = 70;
492492
float ms_fFOVCar = 70;
493493
float ms_fFOVCarMax = 100; // at high vehicle velocity
494+
bool ms_bFOVPlayerFromScript = false;
495+
bool ms_bFOVVehicleFromScript = false;
494496

495497
// consider moving this to the camera class - qaisjp
496498
float CSettingsSA::GetFieldOfViewPlayer ( void )
@@ -508,22 +510,39 @@ float CSettingsSA::GetFieldOfViewVehicleMax ( void )
508510
return ms_fFOVCarMax;
509511
}
510512

511-
void CSettingsSA::SetFieldOfView ( float fAngle )
513+
void CSettingsSA::UpdateFieldOfViewFromSettings( void )
512514
{
513-
SetFieldOfViewPlayer ( fAngle );
514-
SetFieldOfViewVehicle ( fAngle );
515+
float fFieldOfView;
516+
g_pCore->GetCVars()->Get( "fov", fFieldOfView );
517+
fFieldOfView = Clamp( 70.f, fFieldOfView, 100.f );
518+
SetFieldOfViewPlayer( fFieldOfView, false );
519+
SetFieldOfViewVehicle( fFieldOfView, false );
520+
SetFieldOfViewVehicleMax( 100, false );
515521
}
516-
517-
void CSettingsSA::SetFieldOfViewPlayer ( float fAngle )
522+
523+
void CSettingsSA::ResetFieldOfViewFromScript( void )
524+
{
525+
ms_bFOVPlayerFromScript = false;
526+
ms_bFOVVehicleFromScript = false;
527+
UpdateFieldOfViewFromSettings();
528+
}
529+
530+
void CSettingsSA::SetFieldOfViewPlayer ( float fAngle, bool bFromScript )
518531
{
532+
if ( !bFromScript && ms_bFOVPlayerFromScript )
533+
return;
534+
ms_bFOVPlayerFromScript = bFromScript;
519535
ms_fFOV = fAngle;
520536
MemPut < void* > ( 0x0522F3A, &ms_fFOV );
521537
MemPut < void* > ( 0x0522F5D, &ms_fFOV );
522538
MemPut < float > ( 0x0522F7A, ms_fFOV );
523539
}
524540

525-
void CSettingsSA::SetFieldOfViewVehicle ( float fAngle )
541+
void CSettingsSA::SetFieldOfViewVehicle ( float fAngle, bool bFromScript )
526542
{
543+
if ( !bFromScript && ms_bFOVVehicleFromScript )
544+
return;
545+
ms_bFOVVehicleFromScript = bFromScript;
527546
ms_fFOVCar = fAngle;
528547
MemPut < void* > ( 0x0524B76, &ms_fFOVCar );
529548
MemPut < void* > ( 0x0524B9A, &ms_fFOVCar );
@@ -532,8 +551,11 @@ void CSettingsSA::SetFieldOfViewVehicle ( float fAngle )
532551
MemPut < float > ( 0x0524BE4, ms_fFOVCar );
533552
}
534553

535-
void CSettingsSA::SetFieldOfViewVehicleMax ( float fAngle )
554+
void CSettingsSA::SetFieldOfViewVehicleMax ( float fAngle, bool bFromScript )
536555
{
556+
if ( !bFromScript && ms_bFOVVehicleFromScript )
557+
return;
558+
ms_bFOVVehicleFromScript = bFromScript;
537559
ms_fFOVCarMax = fAngle;
538560
MemPut < void* > ( 0x0524BB4, &ms_fFOVCarMax );
539561
MemPut < float > ( 0x0524BC5, ms_fFOVCarMax );

Client/game_sa/CSettingsSA.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,11 @@ class CSettingsSA : public CGameSettings
150150
eRadarMode GetRadarMode ( void );
151151
void SetRadarMode ( eRadarMode hudMode );
152152

153-
void SetFieldOfView ( float fAngle );
154-
void SetFieldOfViewPlayer ( float fAngle );
155-
void SetFieldOfViewVehicle ( float fAngle );
156-
void SetFieldOfViewVehicleMax ( float fAngle );
153+
void UpdateFieldOfViewFromSettings ( void );
154+
void ResetFieldOfViewFromScript ( void );
155+
void SetFieldOfViewPlayer ( float fAngle, bool bFromScript );
156+
void SetFieldOfViewVehicle ( float fAngle, bool bFromScript );
157+
void SetFieldOfViewVehicleMax ( float fAngle, bool bFromScript );
157158
float GetFieldOfViewPlayer ( void );
158159
float GetFieldOfViewVehicle ( void );
159160
float GetFieldOfViewVehicleMax ( void );

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5453,11 +5453,7 @@ void CClientGame::ResetMapInfo ( void )
54535453
m_pCamera->FadeOut ( 0.0f, 0, 0, 0 );
54545454
g_pGame->GetWorld ()->SetCurrentArea ( 0 );
54555455
m_pCamera->SetFocusToLocalPlayer ();
5456-
5457-
float fFOV;
5458-
g_pCore->GetCVars ()->Get ( "fov", fFOV );
5459-
g_pGame->GetSettings ()->SetFieldOfView ( Clamp ( 70.f, fFOV, 100.f ) );
5460-
g_pGame->GetSettings ()->SetFieldOfViewVehicleMax ( 100 );
5456+
g_pGame->GetSettings ()->ResetFieldOfViewFromScript();
54615457

54625458
// Dimension
54635459
SetAllDimensions ( 0 );

Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ int CLuaCameraDefs::SetCameraFieldOfView ( lua_State* luaVM )
253253
}
254254

255255
if ( eMode == FOV_MODE_PLAYER )
256-
g_pGame->GetSettings ()->SetFieldOfViewPlayer ( fFOV );
256+
g_pGame->GetSettings ()->SetFieldOfViewPlayer ( fFOV, true );
257257
else if ( eMode == FOV_MODE_VEHICLE )
258-
g_pGame->GetSettings ()->SetFieldOfViewVehicle ( fFOV );
258+
g_pGame->GetSettings ()->SetFieldOfViewVehicle ( fFOV, true );
259259
else if ( eMode == FOV_MODE_VEHICLE_MAX )
260-
g_pGame->GetSettings ()->SetFieldOfViewVehicleMax ( fFOV );
260+
g_pGame->GetSettings ()->SetFieldOfViewVehicleMax ( fFOV, true );
261261
else {
262262
argStream.m_iIndex = 1;
263263
argStream.SetCustomError ( SString ( "Enum not yet implemented: " + EnumToString ( eMode ) ) );

Client/sdk/game/CSettings.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,12 @@ class CGameSettings
147147
virtual eRadarMode GetRadarMode ( void ) = 0;
148148
virtual void SetRadarMode ( eRadarMode hudMode ) = 0;
149149

150-
virtual void SetFieldOfView ( float fAngle ) = 0;
151-
virtual void SetFieldOfViewPlayer ( float fAngle ) = 0;
152-
virtual void SetFieldOfViewVehicle ( float fAngle ) = 0;
153-
virtual void SetFieldOfViewVehicleMax( float fAngle ) = 0;
150+
virtual void UpdateFieldOfViewFromSettings ( void ) = 0;
151+
virtual void ResetFieldOfViewFromScript ( void ) = 0;
152+
virtual void SetFieldOfViewPlayer ( float fAngle, bool bFromScript ) = 0;
153+
virtual void SetFieldOfViewVehicle ( float fAngle, bool bFromScript ) = 0;
154+
virtual void SetFieldOfViewVehicleMax ( float fAngle, bool bFromScript ) = 0;
155+
154156
virtual float GetFieldOfViewPlayer ( void ) = 0;
155157
virtual float GetFieldOfViewVehicle ( void ) = 0;
156158
virtual float GetFieldOfViewVehicleMax( void ) = 0;

0 commit comments

Comments
 (0)