Skip to content

Commit 70fdd7b

Browse files
committed
conditional operator, check if client is underwater
1 parent 2c3ac63 commit 70fdd7b

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,7 @@ void CMultiplayerSA::SetNightVisionEnabled(bool bEnabled, bool bNoiseEnabled)
156156

157157
void CMultiplayerSA::SetUnderwaterEffectEnabled(bool bEnabled)
158158
{
159-
if (bEnabled)
160-
{
161-
MemPutFast<BYTE>(0xC402D3, 1);
162-
}
163-
else
164-
{
165-
MemPutFast<BYTE>(0xC402D3, 0);
166-
}
159+
MemPutFast<BYTE>(0xC402D3, bEnabled ? 1 : 0);
167160
}
168161

169162
void CMultiplayerSA::SetUnderwaterEffectSpeed(float fSpeed, float fFrequency)
@@ -174,14 +167,7 @@ void CMultiplayerSA::SetUnderwaterEffectSpeed(float fSpeed, float fFrequency)
174167

175168
void CMultiplayerSA::SetUnderwaterDarkness(bool bEnabled, float fFullDarknessDepth)
176169
{
177-
if (bEnabled)
178-
{
179-
MemPutFast<BYTE>(0x8D5144, 1);
180-
}
181-
else
182-
{
183-
MemPutFast<BYTE>(0x8D5144, 0);
184-
}
170+
MemPutFast<BYTE>(0x8D5144, bEnabled ? 1 : 0);
185171

186172
MemPutFast<float>(0x8D5148, fFullDarknessDepth);
187173
}
@@ -218,7 +204,7 @@ bool CMultiplayerSA::IsThermalVisionEnabled()
218204

219205
std::tuple<bool, float, float> CMultiplayerSA::GetUnderwaterEffect()
220206
{
221-
bool bEnabled = (*(BYTE*)0xC402D3 == 1);
207+
bool bEnabled = (*(BYTE*)0xC402D3 == 1) || (*(float*)0xC8132C) >= 0.535f;
222208
float fSpeed = (*(float*)0x8D5138);
223209
float fFrequency = (*(float*)0x8D513C);
224210

@@ -235,7 +221,7 @@ std::tuple<bool, float> CMultiplayerSA::GetUnderwaterDarkness()
235221
}
236222

237223
void CMultiplayerSA::InitHooks_Postprocess()
238-
{
224+
{
239225
HookInstallCall(HOOKPOS_GrainEffect_NightModifier, (DWORD)GrainEffect::NightModifier::ApplyEffect);
240226
HookInstallCall(HOOKPOS_GrainEffect_InfraredModifier, (DWORD)GrainEffect::InfraredModifier::ApplyEffect);
241227
HookInstallCall(HOOKPOS_GrainEffect_RainModifier, (DWORD)GrainEffect::RainModifier::ApplyEffect);

0 commit comments

Comments
 (0)