From 0259af5c805043987543a8312fb6f27fe03de216 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Thu, 4 Jul 2013 22:54:38 -0400 Subject: [PATCH] Prevent possible crash noticed during testing. --- src/Player.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Player.cpp b/src/Player.cpp index 75da9f0ca0..e8fd8ad661 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -1443,15 +1443,20 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, vector *pVolume = Preference::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); + } } }