diff --git a/main/source/mod/AvHAmbientSound.cpp b/main/source/mod/AvHAmbientSound.cpp index f9711768..92b82a5c 100644 --- a/main/source/mod/AvHAmbientSound.cpp +++ b/main/source/mod/AvHAmbientSound.cpp @@ -90,28 +90,28 @@ void AvHAmbientSound::UpdateVolume(const Vector& inListenerPosition) { if(this->mInitialized) { - Vector theDistanceVector = inListenerPosition - this->mPosition; - float theDistance = sqrt(theDistanceVector[0]*theDistanceVector[0] + theDistanceVector[1]*theDistanceVector[1] + theDistanceVector[2]*theDistanceVector[2]); + Vector theDistanceVector = inListenerPosition - this->mPosition; + float theDistance = sqrt(theDistanceVector[0]*theDistanceVector[0] + theDistanceVector[1]*theDistanceVector[1] + theDistanceVector[2]*theDistanceVector[2]); - //FSOUND_SetPan(this->mChannel, FSOUND_STEREOPAN); - int theVolume = this->mVolume; + //FSOUND_SetPan(this->mChannel, FSOUND_STEREOPAN); + int theVolume = this->mVolume; - if(this->mFadeDistance > 0) - { - theVolume = this->mVolume - this->mVolume*(theDistance/(float)this->mFadeDistance); - } + if(this->mFadeDistance > 0) + { + theVolume = this->mVolume - this->mVolume*(theDistance/(float)this->mFadeDistance); + } - float ambientscale = (CVAR_GET_FLOAT("cl_ambientsound")); + float ambientscale = CVAR_GET_FLOAT("cl_ambientsound") * 0.01f; ambientscale = min(max(0, ambientscale), 1); theVolume = min(max(0, theVolume), 255); theVolume *= ambientscale; - FMOD_INSTANCE* theFMOD = gHUD.GetFMOD(); + FMOD_INSTANCE* theFMOD = gHUD.GetFMOD(); - if (theFMOD) - { + if (theFMOD) + { theFMOD->FSOUND_SetVolume(this->mChannel, theVolume); - } + } } } \ No newline at end of file diff --git a/main/source/mod/AvHHud.cpp b/main/source/mod/AvHHud.cpp index f4115387..fd3b414f 100644 --- a/main/source/mod/AvHHud.cpp +++ b/main/source/mod/AvHHud.cpp @@ -6524,7 +6524,9 @@ void AvHHud::UpdateAmbientSounds() for(AmbientSoundListType::iterator theIter = this->mAmbientSounds.begin(); theIter != this->mAmbientSounds.end(); theIter++) { - theIter->StartPlayingIfNot(); + if (CVAR_GET_FLOAT("cl_ambientsound") != 0) + theIter->StartPlayingIfNot(); + theIter->UpdateVolume(theListenerPosition); } } diff --git a/main/source/ui/UIHud.cpp b/main/source/ui/UIHud.cpp index 93fb75f9..c98b57bf 100644 --- a/main/source/ui/UIHud.cpp +++ b/main/source/ui/UIHud.cpp @@ -530,7 +530,8 @@ int UIHud::Redraw(float flTime, int intermission) } // Initialize music the first time through - this->InitializeSound(); + if (CVAR_GET_FLOAT("cl_ambientsound") != 0) + this->InitializeSound(); } string theErrorString; @@ -568,9 +569,10 @@ void UIHud::ShutdownMusic(void) this->StopInternetStream(); - mFMOD->FSOUND_Close(); - - FMOD_FreeInstance(mFMOD); + ////Commented out to fix the dreaded hang on exit! Let HL and the OS take care of it. + //mFMOD->FSOUND_Close(); + // + //FMOD_FreeInstance(mFMOD); mFMOD = NULL; this->mSoundInitialized = false; @@ -623,13 +625,17 @@ void UIHud::ToggleMouse(void) bool UIHud::Update(float inCurrentTime, string& outError) { - this->mManager.Update(inCurrentTime); + this->mManager.Update(inCurrentTime); - this->UpdateMusic(inCurrentTime); + bool theSuccess = true; + if (CVAR_GET_FLOAT("cl_ambientsound") != 0) { + this->UpdateMusic(inCurrentTime); - bool theSuccess = this->UpdateInternetStream(inCurrentTime, outError); + //bool theSuccess = this->UpdateInternetStream(inCurrentTime, outError); + theSuccess = this->UpdateInternetStream(inCurrentTime, outError); + } - return theSuccess; + return theSuccess; } int UIHud::UpdateClientData(client_data_t *cdata, float time) diff --git a/main/user.scr b/main/user.scr index f3181594..fa52af82 100644 --- a/main/user.scr +++ b/main/user.scr @@ -50,7 +50,7 @@ DESCRIPTION INFO_OPTIONS "cl_ambientsound" { - "Ambient sound volume (0 to 1)" + "Ambient sound volume (0 to 100)" { NUMBER 0.000000 1.000000 } { "0.000000" } }