Prevent possible crash noticed during testing.

This commit is contained in:
Jason Felds
2013-07-04 22:54:38 -04:00
parent 162b626e3e
commit 0259af5c80
+11 -6
View File
@@ -1443,15 +1443,20 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, vector<TrackRowTap
tn.HoldResult.fLife = fLife;
tn.HoldResult.hns = hns;
// Stop the playing keysound for the hold note.
// I think this causes crashes too. -aj (Possibly fixed. -?)
// I think this causes crashes too. -aj
// This can still crash. I think it expects a full game and quit before the preference works:
// otherwise, it causes problems on holds. At least, that hapened on my Mac. -wolfman2000
Preference<float> *pVolume = Preference<float>::GetPreferenceByName("SoundVolume");
float fVol = pVolume->Get();
if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() )
if (pVolume != NULL)
{
float factor = (tn.subType == TapNote::hold_head_roll ? 2.0f * fLifeFraction : 10.0f * fLifeFraction - 8.5f);
m_vKeysounds[tn.iKeysoundIndex].SetProperty ("Volume", max(0.0f, min(1.0f, factor)) * fVol);
float fVol = pVolume->Get();
if( tn.iKeysoundIndex >= 0 && tn.iKeysoundIndex < (int) m_vKeysounds.size() )
{
float factor = (tn.subType == TapNote::hold_head_roll ? 2.0f * fLifeFraction : 10.0f * fLifeFraction - 8.5f);
m_vKeysounds[tn.iKeysoundIndex].SetProperty ("Volume", max(0.0f, min(1.0f, factor)) * fVol);
}
}
}