- fixed sound channel iterator to properly handle callbacks that delete sounds.cpp

This commit is contained in:
Christoph Oelckers 2020-02-23 17:12:40 +01:00
parent e28de10c00
commit c8aa006f82

View file

@ -380,10 +380,13 @@ public:
template<class func> bool EnumerateChannels(func callback) template<class func> bool EnumerateChannels(func callback)
{ {
for (FSoundChan* chan = Channels; chan; chan = chan->NextChan) FSoundChan* chan = Channels;
while (chan)
{ {
auto next = chan = chan->NextChan;
int res = callback(chan); int res = callback(chan);
if (res) return res > 0; if (res) return res > 0;
chan = next;
} }
return false; return false;
} }