diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index b1b8f0ed861..4ce70b5eed9 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -273,7 +273,7 @@ void CSettingsSA::Save() } } -bool CSettingsSA::IsVolumetricShadowsEnabled() +bool CSettingsSA::IsVolumetricShadowsEnabled() const noexcept { return m_bVolumetricShadowsEnabled && !m_bVolumetricShadowsSuspended; } @@ -287,6 +287,20 @@ void CSettingsSA::SetVolumetricShadowsEnabled(bool bEnable) MemPut(0x5E682A + 1, bEnable); } + +bool CSettingsSA::GetVolumetricShadowsEnabledByVideoSetting() const noexcept +{ + bool volumetricShadow; + g_pCore->GetCVars()->Get("volumetric_shadows", volumetricShadow); + return volumetricShadow; +} + +bool CSettingsSA::ResetVolumetricShadows() noexcept +{ + pGame->GetSettings()->SetVolumetricShadowsEnabled(pGame->GetSettings()->GetVolumetricShadowsEnabledByVideoSetting()); + return true; +} + void CSettingsSA::SetVolumetricShadowsSuspended(bool bSuspended) { m_bVolumetricShadowsSuspended = bSuspended; diff --git a/Client/game_sa/CSettingsSA.h b/Client/game_sa/CSettingsSA.h index 9bb313e5668..7947c94929a 100644 --- a/Client/game_sa/CSettingsSA.h +++ b/Client/game_sa/CSettingsSA.h @@ -138,7 +138,10 @@ class CSettingsSA : public CGameSettings bool IsMipMappingEnabled(); void SetMipMappingEnabled(bool bEnable); - bool IsVolumetricShadowsEnabled(); + bool IsVolumetricShadowsEnabled() const noexcept; + bool GetVolumetricShadowsEnabledByVideoSetting() const noexcept; + bool ResetVolumetricShadows() noexcept; + void SetVolumetricShadowsEnabled(bool bEnable); void SetVolumetricShadowsSuspended(bool bSuspended); diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index df20bf6eaab..d9a7e7c2d06 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -5558,6 +5558,7 @@ void CClientGame::ResetMapInfo() g_pGame->GetWeather()->ResetWaterFog(); g_pGame->GetWeather()->ResetSandstorm(); g_pGame->GetWeather()->ResetRainbow(); + g_pGame->GetSettings()->ResetVolumetricShadows(); // Disable the change of any player stats g_pMultiplayer->SetLocalStatsStatic(true); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp index 7f8af634e7a..8f508a7fab6 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp @@ -105,6 +105,7 @@ void CLuaWorldDefs::LoadFunctions() {"restoreAllWorldModels", RestoreWorldBuildings}, {"restoreWorldModel", RestoreWorldBuilding}, {"setTimeFrozen", ArgumentParser}, + {"setVolumetricShadowsEnabled", ArgumentParser}, // World create funcs {"createSWATRope", CreateSWATRope}, @@ -128,14 +129,16 @@ void CLuaWorldDefs::LoadFunctions() {"resetBlurLevel", ResetBlurLevel}, {"resetWorldProperty", ArgumentParserWarn}, {"resetTimeFrozen", ArgumentParser}, - + {"resetVolumetricShadows", ArgumentParser}, + // World check funcs {"areTrafficLightsLocked", AreTrafficLightsLocked}, {"isPedTargetingMarkerEnabled", IsPedTargetingMarkerEnabled}, {"isLineOfSightClear", IsLineOfSightClear}, {"isWorldSpecialPropertyEnabled", ArgumentParserWarn}, {"isGarageOpen", IsGarageOpen}, - {"isTimeFrozen", ArgumentParser}}; + {"isTimeFrozen", ArgumentParser}, + {"isVolumetricShadowsEnabled", ArgumentParser}}; // Add functions for (const auto& [name, func] : functions) @@ -2253,3 +2256,19 @@ bool CLuaWorldDefs::ResetTimeFrozen() noexcept { return g_pGame->GetClock()->ResetTimeFrozen(); } + +bool CLuaWorldDefs::SetVolumetricShadowsEnabled(bool enable) noexcept +{ + g_pGame->GetSettings()->SetVolumetricShadowsEnabled(enable); + return true; +} + +bool CLuaWorldDefs::IsVolumetricShadowsEnabled() noexcept +{ + return g_pGame->GetSettings()->IsVolumetricShadowsEnabled(); +} + +bool CLuaWorldDefs::ResetVolumetricShadows() noexcept +{ + return g_pGame->GetSettings()->ResetVolumetricShadows(); +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h index 6f79c9081ab..6ac901a1054 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h @@ -134,5 +134,9 @@ class CLuaWorldDefs : public CLuaDefs static bool SetTimeFrozen(bool value) noexcept; static bool IsTimeFrozen() noexcept; static bool ResetTimeFrozen() noexcept; + + static bool SetVolumetricShadowsEnabled(bool enable) noexcept; + static bool IsVolumetricShadowsEnabled() noexcept; + static bool ResetVolumetricShadows() noexcept; }; diff --git a/Client/sdk/game/CSettings.h b/Client/sdk/game/CSettings.h index 1bed48acfce..d5ef10a05b4 100644 --- a/Client/sdk/game/CSettings.h +++ b/Client/sdk/game/CSettings.h @@ -132,9 +132,11 @@ class CGameSettings virtual bool IsMipMappingEnabled() = 0; virtual void SetMipMappingEnabled(bool bEnable) = 0; - virtual bool IsVolumetricShadowsEnabled() = 0; + virtual bool IsVolumetricShadowsEnabled() const noexcept = 0; + virtual bool GetVolumetricShadowsEnabledByVideoSetting() const noexcept = 0; virtual void SetVolumetricShadowsEnabled(bool bEnable) = 0; virtual void SetVolumetricShadowsSuspended(bool bSuspended) = 0; + virtual bool ResetVolumetricShadows() noexcept = 0; virtual bool IsDynamicPedShadowsEnabled() = 0; virtual void SetDynamicPedShadowsEnabled(bool bEnable) = 0;