mirror of
https://github.com/ENSL/NS.git
synced 2025-03-24 11:12:25 +00:00
Fix for hang on exit.
Also change fmod to not load if cl_ambientsoun is 0 and made this cvar 0-100 to match the music volume cvar.
This commit is contained in:
parent
3d5cb0bc6d
commit
a4970388ef
4 changed files with 31 additions and 23 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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" }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue