Skip to content

Commit

Permalink
add ped dynamic shadows functions (#3809)
Browse files Browse the repository at this point in the history
  • Loading branch information
Proxy-99 authored Oct 23, 2024
1 parent a5dfc52 commit 26d1828
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
14 changes: 14 additions & 0 deletions Client/game_sa/CSettingsSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,20 @@ void CSettingsSA::SetDynamicPedShadowsEnabled(bool bEnable)
m_bDynamicPedShadowsEnabled = bEnable;
}

bool CSettingsSA::IsDynamicPedShadowsEnabledByVideoSetting() const noexcept
{
bool pedDynamicShadows;
g_pCore->GetCVars()->Get("dynamic_ped_shadows", pedDynamicShadows);
return pedDynamicShadows;
}

bool CSettingsSA::ResetDynamicPedShadows() noexcept
{
pGame->GetSettings()->SetDynamicPedShadowsEnabled(pGame->GetSettings()->IsDynamicPedShadowsEnabledByVideoSetting());
return true;
}


//
// Volumetric shadow hooks
//
Expand Down
2 changes: 2 additions & 0 deletions Client/game_sa/CSettingsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class CSettingsSA : public CGameSettings

bool IsDynamicPedShadowsEnabled();
void SetDynamicPedShadowsEnabled(bool bEnable);
bool IsDynamicPedShadowsEnabledByVideoSetting() const noexcept;
bool ResetDynamicPedShadows() noexcept;

float GetAspectRatioValue();
eAspectRatio GetAspectRatio();
Expand Down
10 changes: 6 additions & 4 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5456,10 +5456,6 @@ void CClientGame::ResetMapInfo()
// Players
m_pPlayerManager->ResetAll();

// Reset Frozen Time
g_pGame->GetClock()->ResetTimeFrozen();
g_pGame->GetSettings()->ResetVolumetricShadows();

// Disable the change of any player stats
g_pMultiplayer->SetLocalStatsStatic(true);

Expand Down Expand Up @@ -6887,6 +6883,12 @@ void CClientGame::ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo

// Reset volumetric shadows
g_pGame->GetSettings()->ResetVolumetricShadows();

// Reset Frozen Time
g_pGame->GetClock()->ResetTimeFrozen();

// Reset DynamicPedShadows
g_pGame->GetSettings()->ResetDynamicPedShadows();
}

void CClientGame::OnWindowFocusChange(bool state)
Expand Down
21 changes: 20 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void CLuaWorldDefs::LoadFunctions()
{"restoreWorldModel", RestoreWorldBuilding},
{"setTimeFrozen", ArgumentParser<SetTimeFrozen>},
{"setVolumetricShadowsEnabled", ArgumentParser<SetVolumetricShadowsEnabled>},
{"setDynamicPedShadowsEnabled", ArgumentParser<SetDynamicPedShadowsEnabled>},

// World create funcs
{"createSWATRope", CreateSWATRope},
Expand All @@ -131,6 +132,7 @@ void CLuaWorldDefs::LoadFunctions()
{"resetTimeFrozen", ArgumentParser<ResetTimeFrozen>},
{"resetVolumetricShadows", ArgumentParser<ResetVolumetricShadows>},
{"resetWorldProperties", ArgumentParser<ResetWorldProperties>},
{"resetDynamicPedShadows", ArgumentParser<ResetDynamicPedShadows>},

// World check funcs
{"areTrafficLightsLocked", AreTrafficLightsLocked},
Expand All @@ -139,7 +141,8 @@ void CLuaWorldDefs::LoadFunctions()
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, IsWorldSpecialPropertyEnabled>},
{"isGarageOpen", IsGarageOpen},
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>},
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>}};
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>},
{"isDynamicPedShadowsEnabled", ArgumentParser<IsDynamicPedShadowsEnabled>}};

// Add functions
for (const auto& [name, func] : functions)
Expand Down Expand Up @@ -2278,3 +2281,19 @@ void CLuaWorldDefs::ResetWorldProperties(std::optional<bool> resetSpecialWorldPr
{
g_pClientGame->ResetWorldProperties(ResetWorldPropsInfo{resetSpecialWorldProperties.value_or(true), resetWorldProperties.value_or(true), resetWeatherProperties.value_or(true), resetLODs.value_or(true), resetSounds.value_or(true)});
}

bool CLuaWorldDefs::SetDynamicPedShadowsEnabled(bool enable)
{
g_pGame->GetSettings()->SetDynamicPedShadowsEnabled(enable);
return true;
}

bool CLuaWorldDefs::IsDynamicPedShadowsEnabled() noexcept
{
return g_pGame->GetSettings()->IsDynamicPedShadowsEnabled();
}

bool CLuaWorldDefs::ResetDynamicPedShadows() noexcept
{
return g_pGame->GetSettings()->ResetDynamicPedShadows();
}
5 changes: 4 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ class CLuaWorldDefs : public CLuaDefs
static bool ResetVolumetricShadows() noexcept;

static void ResetWorldProperties(std::optional<bool> resetSpecialWorldProperties, std::optional<bool> resetWorldProperties, std::optional<bool> resetWeatherProperties, std::optional<bool> resetLODs, std::optional<bool> resetSounds) noexcept;


static bool SetDynamicPedShadowsEnabled(bool enable);
static bool IsDynamicPedShadowsEnabled() noexcept;
static bool ResetDynamicPedShadows() noexcept;
};

2 changes: 2 additions & 0 deletions Client/sdk/game/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class CGameSettings

virtual bool IsDynamicPedShadowsEnabled() = 0;
virtual void SetDynamicPedShadowsEnabled(bool bEnable) = 0;
virtual bool IsDynamicPedShadowsEnabledByVideoSetting() const noexcept = 0;
virtual bool ResetDynamicPedShadows() noexcept = 0;

virtual float GetAspectRatioValue() = 0;
virtual eAspectRatio GetAspectRatio() = 0;
Expand Down

0 comments on commit 26d1828

Please sign in to comment.