From e516c862efebc1a5cdbed82e64f10b9702e5f651 Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Fri, 14 Feb 2025 23:04:17 +0000 Subject: [PATCH] ChaosMod/EffectSound3D: Replace game paused native call in thread with ping timeouts --- ChaosMod/Components/EffectSound/EffectSound3D.cpp | 8 +++++--- ChaosMod/Components/EffectSound/EffectSound3D.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChaosMod/Components/EffectSound/EffectSound3D.cpp b/ChaosMod/Components/EffectSound/EffectSound3D.cpp index ce9f52ce0..edb5c09f4 100644 --- a/ChaosMod/Components/EffectSound/EffectSound3D.cpp +++ b/ChaosMod/Components/EffectSound/EffectSound3D.cpp @@ -21,7 +21,7 @@ EffectSound3D::EffectSound3D() { Sleep(100); - if (IS_PAUSE_MENU_ACTIVE()) + if (GetTickCount64() > m_ThreadPingTimestamp + 100) { std::lock_guard lock(m_SoundsMutex); for (auto &[soundId, sound] : m_Sounds) @@ -55,9 +55,11 @@ void EffectSound3D::OnRun() if (m_Sounds.empty()) return; - auto playerPed = PLAYER_PED_ID(); + m_ThreadPingTimestamp = GetTickCount64(); - auto adjCamCoords = GET_GAMEPLAY_CAM_COORD(); + auto playerPed = PLAYER_PED_ID(); + + auto adjCamCoords = GET_GAMEPLAY_CAM_COORD(); ma_engine_listener_set_position(&m_maEngine, 0, adjCamCoords.x, adjCamCoords.y, adjCamCoords.z); float camHeading = GET_GAMEPLAY_CAM_RELATIVE_HEADING(); diff --git a/ChaosMod/Components/EffectSound/EffectSound3D.h b/ChaosMod/Components/EffectSound/EffectSound3D.h index f04d1abf8..175c46a8a 100644 --- a/ChaosMod/Components/EffectSound/EffectSound3D.h +++ b/ChaosMod/Components/EffectSound/EffectSound3D.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -23,6 +24,7 @@ class EffectSound3D : public EffectSoundManager std::mutex m_SoundsMutex; bool m_IsStopping = false; std::thread m_PauseSoundsThread; + uint64_t m_ThreadPingTimestamp; public: EffectSound3D();