Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Client/game_sa/CSettingsSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void CSettingsSA::Save()
}
}

bool CSettingsSA::IsVolumetricShadowsEnabled()
bool CSettingsSA::IsVolumetricShadowsEnabled() const noexcept
{
return m_bVolumetricShadowsEnabled && !m_bVolumetricShadowsSuspended;
}
Expand All @@ -287,6 +287,20 @@ void CSettingsSA::SetVolumetricShadowsEnabled(bool bEnable)
MemPut<BYTE>(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;
Expand Down
5 changes: 4 additions & 1 deletion Client/game_sa/CSettingsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 21 additions & 2 deletions Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void CLuaWorldDefs::LoadFunctions()
{"restoreAllWorldModels", RestoreWorldBuildings},
{"restoreWorldModel", RestoreWorldBuilding},
{"setTimeFrozen", ArgumentParser<SetTimeFrozen>},
{"setVolumetricShadowsEnabled", ArgumentParser<SetVolumetricShadowsEnabled>},

// World create funcs
{"createSWATRope", CreateSWATRope},
Expand All @@ -128,14 +129,16 @@ void CLuaWorldDefs::LoadFunctions()
{"resetBlurLevel", ResetBlurLevel},
{"resetWorldProperty", ArgumentParserWarn<false, ResetWorldProperty>},
{"resetTimeFrozen", ArgumentParser<ResetTimeFrozen>},

{"resetVolumetricShadows", ArgumentParser<ResetVolumetricShadows>},

// World check funcs
{"areTrafficLightsLocked", AreTrafficLightsLocked},
{"isPedTargetingMarkerEnabled", IsPedTargetingMarkerEnabled},
{"isLineOfSightClear", IsLineOfSightClear},
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, IsWorldSpecialPropertyEnabled>},
{"isGarageOpen", IsGarageOpen},
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>}};
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>},
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>}};

// Add functions
for (const auto& [name, func] : functions)
Expand Down Expand Up @@ -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();
}
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

@TracerDS TracerDS Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any void type lua functions? How would that work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test later with void because last time I used argument parser with void type the build was failing and gives error function has no return value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any void type lua functions? How would that work here?

I forgot that @Proxy-99 uses ArgumentParser here, sorry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test later with void because last time I used argument parser with void type the build was failing and gives error function has no return value

I forgot that you are using ArgumentParser here, the function need to have a return value, sorry.

static bool IsVolumetricShadowsEnabled() noexcept;
static bool ResetVolumetricShadows() noexcept;
};

4 changes: 3 additions & 1 deletion Client/sdk/game/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down