Skip to content

Commit 26d1828

Browse files
authored
add ped dynamic shadows functions (#3809)
1 parent a5dfc52 commit 26d1828

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed

Client/game_sa/CSettingsSA.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,20 @@ void CSettingsSA::SetDynamicPedShadowsEnabled(bool bEnable)
316316
m_bDynamicPedShadowsEnabled = bEnable;
317317
}
318318

319+
bool CSettingsSA::IsDynamicPedShadowsEnabledByVideoSetting() const noexcept
320+
{
321+
bool pedDynamicShadows;
322+
g_pCore->GetCVars()->Get("dynamic_ped_shadows", pedDynamicShadows);
323+
return pedDynamicShadows;
324+
}
325+
326+
bool CSettingsSA::ResetDynamicPedShadows() noexcept
327+
{
328+
pGame->GetSettings()->SetDynamicPedShadowsEnabled(pGame->GetSettings()->IsDynamicPedShadowsEnabledByVideoSetting());
329+
return true;
330+
}
331+
332+
319333
//
320334
// Volumetric shadow hooks
321335
//

Client/game_sa/CSettingsSA.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ class CSettingsSA : public CGameSettings
147147

148148
bool IsDynamicPedShadowsEnabled();
149149
void SetDynamicPedShadowsEnabled(bool bEnable);
150+
bool IsDynamicPedShadowsEnabledByVideoSetting() const noexcept;
151+
bool ResetDynamicPedShadows() noexcept;
150152

151153
float GetAspectRatioValue();
152154
eAspectRatio GetAspectRatio();

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5456,10 +5456,6 @@ void CClientGame::ResetMapInfo()
54565456
// Players
54575457
m_pPlayerManager->ResetAll();
54585458

5459-
// Reset Frozen Time
5460-
g_pGame->GetClock()->ResetTimeFrozen();
5461-
g_pGame->GetSettings()->ResetVolumetricShadows();
5462-
54635459
// Disable the change of any player stats
54645460
g_pMultiplayer->SetLocalStatsStatic(true);
54655461

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

68886884
// Reset volumetric shadows
68896885
g_pGame->GetSettings()->ResetVolumetricShadows();
6886+
6887+
// Reset Frozen Time
6888+
g_pGame->GetClock()->ResetTimeFrozen();
6889+
6890+
// Reset DynamicPedShadows
6891+
g_pGame->GetSettings()->ResetDynamicPedShadows();
68906892
}
68916893

68926894
void CClientGame::OnWindowFocusChange(bool state)

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void CLuaWorldDefs::LoadFunctions()
106106
{"restoreWorldModel", RestoreWorldBuilding},
107107
{"setTimeFrozen", ArgumentParser<SetTimeFrozen>},
108108
{"setVolumetricShadowsEnabled", ArgumentParser<SetVolumetricShadowsEnabled>},
109+
{"setDynamicPedShadowsEnabled", ArgumentParser<SetDynamicPedShadowsEnabled>},
109110

110111
// World create funcs
111112
{"createSWATRope", CreateSWATRope},
@@ -131,6 +132,7 @@ void CLuaWorldDefs::LoadFunctions()
131132
{"resetTimeFrozen", ArgumentParser<ResetTimeFrozen>},
132133
{"resetVolumetricShadows", ArgumentParser<ResetVolumetricShadows>},
133134
{"resetWorldProperties", ArgumentParser<ResetWorldProperties>},
135+
{"resetDynamicPedShadows", ArgumentParser<ResetDynamicPedShadows>},
134136

135137
// World check funcs
136138
{"areTrafficLightsLocked", AreTrafficLightsLocked},
@@ -139,7 +141,8 @@ void CLuaWorldDefs::LoadFunctions()
139141
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, IsWorldSpecialPropertyEnabled>},
140142
{"isGarageOpen", IsGarageOpen},
141143
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>},
142-
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>}};
144+
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>},
145+
{"isDynamicPedShadowsEnabled", ArgumentParser<IsDynamicPedShadowsEnabled>}};
143146

144147
// Add functions
145148
for (const auto& [name, func] : functions)
@@ -2278,3 +2281,19 @@ void CLuaWorldDefs::ResetWorldProperties(std::optional<bool> resetSpecialWorldPr
22782281
{
22792282
g_pClientGame->ResetWorldProperties(ResetWorldPropsInfo{resetSpecialWorldProperties.value_or(true), resetWorldProperties.value_or(true), resetWeatherProperties.value_or(true), resetLODs.value_or(true), resetSounds.value_or(true)});
22802283
}
2284+
2285+
bool CLuaWorldDefs::SetDynamicPedShadowsEnabled(bool enable)
2286+
{
2287+
g_pGame->GetSettings()->SetDynamicPedShadowsEnabled(enable);
2288+
return true;
2289+
}
2290+
2291+
bool CLuaWorldDefs::IsDynamicPedShadowsEnabled() noexcept
2292+
{
2293+
return g_pGame->GetSettings()->IsDynamicPedShadowsEnabled();
2294+
}
2295+
2296+
bool CLuaWorldDefs::ResetDynamicPedShadows() noexcept
2297+
{
2298+
return g_pGame->GetSettings()->ResetDynamicPedShadows();
2299+
}

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class CLuaWorldDefs : public CLuaDefs
140140
static bool ResetVolumetricShadows() noexcept;
141141

142142
static void ResetWorldProperties(std::optional<bool> resetSpecialWorldProperties, std::optional<bool> resetWorldProperties, std::optional<bool> resetWeatherProperties, std::optional<bool> resetLODs, std::optional<bool> resetSounds) noexcept;
143-
143+
144+
static bool SetDynamicPedShadowsEnabled(bool enable);
145+
static bool IsDynamicPedShadowsEnabled() noexcept;
146+
static bool ResetDynamicPedShadows() noexcept;
144147
};
145148

Client/sdk/game/CSettings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class CGameSettings
140140

141141
virtual bool IsDynamicPedShadowsEnabled() = 0;
142142
virtual void SetDynamicPedShadowsEnabled(bool bEnable) = 0;
143+
virtual bool IsDynamicPedShadowsEnabledByVideoSetting() const noexcept = 0;
144+
virtual bool ResetDynamicPedShadows() noexcept = 0;
143145

144146
virtual float GetAspectRatioValue() = 0;
145147
virtual eAspectRatio GetAspectRatio() = 0;

0 commit comments

Comments
 (0)