diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 5e836ee04..3f40f5710 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -553,8 +553,15 @@ void Material::initCustomSFX(const XMLNode *sfx) sfx->get("max-pitch", &m_sfx_max_pitch); // 2.4 style sfx->get("max_pitch", &m_sfx_max_pitch); // 2.5 style - m_sfx_pitch_per_speed = (m_sfx_max_pitch - m_sfx_min_pitch) - / (m_sfx_max_speed - m_sfx_min_speed); + if (m_sfx_max_speed == m_sfx_min_speed) + { + m_sfx_pitch_per_speed = 0.0f; + } + else + { + m_sfx_pitch_per_speed = (m_sfx_max_pitch - m_sfx_min_pitch) + / (m_sfx_max_speed - m_sfx_min_speed); + } if(!SFXManager::get()->soundExist(m_sfx_name)) { @@ -675,6 +682,8 @@ void Material::setSFXSpeed(SFXBase *sfx, float speed, bool should_be_paused) con return; } + assert(!isnan(speed)); + float f = m_sfx_pitch_per_speed*(speed-m_sfx_min_speed) + m_sfx_min_pitch; assert(!isnan(f)); sfx->setSpeed(f);