diff options
author | Eugene Sandulenko | 2013-12-10 22:22:51 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2013-12-10 22:22:51 +0200 |
commit | 6e6685a53de4f0f3deb4414f59153b2d6f673b6b (patch) | |
tree | d752720537861467b9f5e31250fd15be43c72b9e | |
parent | 789b4b694f2fcfd54772feb4032653be03ca75f2 (diff) | |
download | scummvm-rg350-6e6685a53de4f0f3deb4414f59153b2d6f673b6b.tar.gz scummvm-rg350-6e6685a53de4f0f3deb4414f59153b2d6f673b6b.tar.bz2 scummvm-rg350-6e6685a53de4f0f3deb4414f59153b2d6f673b6b.zip |
FULLPIPE: Remove premature optimization in GlobalMessageQueueList::compact()
This fixes freeze in intro and most probably tons of other stuff.
Kudos go to eriktorbjorn for debugging it.
-rw-r--r-- | engines/fullpipe/messages.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index 6af3f731df..c28365acc5 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -557,16 +557,33 @@ void GlobalMessageQueueList::disableQueueById(int id) { } int GlobalMessageQueueList::compact() { + int *useList = new int[size() + 2]; + + for (uint i = 0; i < size() + 2; i++) + useList[i] = 0; + for (uint i = 0; i < size();) { if (((MessageQueue *)_storage[i])->_isFinished) { disableQueueById(_storage[i]->_id); remove_at(i); } else { + if (_storage[i]->_id < size() + 2) + useList[_storage[i]->_id] = 1; i++; } } - return size() + 1; + uint i; + + for (i = 1; i < size() + 2; i++) { + if (!useList[i]) { + delete [] useList; + + return i; + } + } + + return i; } void GlobalMessageQueueList::addMessageQueue(MessageQueue *msg) { |