diff --git a/source/lib/res/sound/snd_mgr.cpp b/source/lib/res/sound/snd_mgr.cpp index 3d09497fa7..837aae7960 100644 --- a/source/lib/res/sound/snd_mgr.cpp +++ b/source/lib/res/sound/snd_mgr.cpp @@ -1686,6 +1686,7 @@ Handle snd_open(const char* snd_fn, bool is_stream) */ LibError snd_free(Handle& hvs) { + if(!hvs) return INFO::OK; return h_free(hvs, H_VSrc); } diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index c4490c4e29..93f74e13c9 100644 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -757,8 +757,9 @@ int CEntity::DestroyNotifier( CEntity* target ) std::vector::iterator newEnd2 = std::remove_if( m_notifiers.begin(), m_notifiers.end(), bind2nd(std::equal_to(), target)); - int removed = std::distance(newEnd2, m_notifiers.end()); - m_notifiers.erase(newEnd2, m_notifiers.end()); + int removed = m_notifiers.end() - newEnd2; + //m_notifiers.erase(newEnd2, m_notifiers.end()); + m_notifiers.resize(m_notifiers.size() - removed); return removed; } void CEntity::DestroyAllNotifiers() @@ -766,7 +767,7 @@ void CEntity::DestroyAllNotifiers() debug_assert(entf_get(ENTF_DESTROY_NOTIFIERS)); //Make them stop listening to us while ( ! m_notifiers.empty() ) - DestroyNotifier( m_notifiers[0] ); + DestroyNotifier( m_notifiers[m_notifiers.size()-1] ); } CEntityFormation* CEntity::GetFormation() { diff --git a/source/simulation/EntityManager.cpp b/source/simulation/EntityManager.cpp index 667e57871d..b6f751a4ea 100644 --- a/source/simulation/EntityManager.cpp +++ b/source/simulation/EntityManager.cpp @@ -191,6 +191,7 @@ void CEntityManager::GetInRange( float x, float z, float radius, std::vectorm_position.X; float dz = z - e->m_position.Z; if( dx*dx + dz*dz <= radiusSq ) diff --git a/source/sound/JSI_Sound.cpp b/source/sound/JSI_Sound.cpp index ec222830be..c71a747922 100644 --- a/source/sound/JSI_Sound.cpp +++ b/source/sound/JSI_Sound.cpp @@ -118,7 +118,8 @@ bool JSI_Sound::Loop( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(a // sounds are freed automatically when done playing. bool JSI_Sound::Free( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) ) { - snd_free(m_Handle); // resets it to 0 + if(m_Handle) + snd_free(m_Handle); // resets it to 0 return true; }