Not deleting in a "foreach"-loop

This commit is contained in:
Stiffly
2014-06-04 06:09:59 +02:00
parent 27b735325a
commit 5e78fdc930
+9 -4
View File
@@ -59,16 +59,21 @@ void Systems::SoundSystem::Update(double dt)
} }
//LOG_INFO("Antal emitters i listan: %i", m_Channels.size()); //LOG_INFO("Antal emitters i listan: %i", m_Channels.size());
for (auto channel : m_Channels)
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
for(it = m_Channels.begin(); it != m_Channels.end();)
{ {
FMOD_BOOL isPlaying = false; FMOD_BOOL isPlaying = false;
FMOD_Channel_IsPlaying(channel.second, &isPlaying); FMOD_Channel_IsPlaying(it->second, &isPlaying);
if(!isPlaying) if(!isPlaying)
{ {
m_Channels.erase(channel.first); it = m_Channels.erase(it);
}
else
{
it++;
} }
} }
} }
void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)