From 0c3099a3d900638c5dc0b3fce0763817149a104a Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Tue, 8 Aug 2023 11:15:30 +0300 Subject: [PATCH] * Put the SoundSystemAL behind the USE_OPENAL define. --- platforms/openal/SoundSystemAL.cpp | 24 ++++++++++++++++-------- platforms/openal/SoundSystemAL.hpp | 4 ++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/platforms/openal/SoundSystemAL.cpp b/platforms/openal/SoundSystemAL.cpp index f280f28..be74587 100644 --- a/platforms/openal/SoundSystemAL.cpp +++ b/platforms/openal/SoundSystemAL.cpp @@ -1,3 +1,4 @@ +#ifdef USE_OPENAL #include "SoundSystemAL.hpp" #include "client/common/Utils.hpp" @@ -251,9 +252,18 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl if (volume <= 0.0f) return; - float distance = Vec3(x, y, z).distanceTo(lastListenerPos); - if (distance >= MAX_DISTANCE) - return; + bool bIsGUI = AL_FALSE; + float distance = 0.0f; + if (x == 0 && y == 0 && z == 0) + { + bIsGUI = AL_TRUE; + } + else + { + distance = Vec3(x, y, z).distanceTo(lastListenerPos); + if (distance >= MAX_DISTANCE) + return; + } // Load Sound ALuint buffer = get_buffer(sound); @@ -286,10 +296,6 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl } } - bool isUi = AL_FALSE; - if (x == 0 && y == 0 && z == 0) - isUi = AL_TRUE; - // Set Properties alSourcef(al_source, AL_PITCH, pitch); AL_ERROR_CHECK(); @@ -301,7 +307,7 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl AL_ERROR_CHECK(); alSourcei(al_source, AL_LOOPING, AL_FALSE); AL_ERROR_CHECK(); - alSourcei(al_source, AL_SOURCE_RELATIVE, isUi); + alSourcei(al_source, AL_SOURCE_RELATIVE, bIsGUI); AL_ERROR_CHECK(); // Set Attenuation @@ -321,3 +327,5 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl AL_ERROR_CHECK(); sources.push_back(al_source); } + +#endif diff --git a/platforms/openal/SoundSystemAL.hpp b/platforms/openal/SoundSystemAL.hpp index 5f36d03..d5f331a 100644 --- a/platforms/openal/SoundSystemAL.hpp +++ b/platforms/openal/SoundSystemAL.hpp @@ -1,5 +1,7 @@ #pragma once +#ifdef USE_OPENAL + #ifdef _WIN32 #include #include @@ -44,3 +46,5 @@ private: Vec3 lastListenerPos; }; + +#endif