diff options
author | Colin Snover | 2017-11-14 20:50:13 -0600 |
---|---|---|
committer | Eugene Sandulenko | 2017-11-18 22:35:12 +0100 |
commit | 39ea2f66ac635613c3a817c16f80b11ac207d320 (patch) | |
tree | 73019faa52cec38173821559a2165d341eeb0b1e /engines/fullpipe | |
parent | 073692fd5250ae6fb2224f791821c5bd225ba5f0 (diff) | |
download | scummvm-rg350-39ea2f66ac635613c3a817c16f80b11ac207d320.tar.gz scummvm-rg350-39ea2f66ac635613c3a817c16f80b11ac207d320.tar.bz2 scummvm-rg350-39ea2f66ac635613c3a817c16f80b11ac207d320.zip |
FULLPIPE: Fix deleted queue leaks & clarify flags
Diffstat (limited to 'engines/fullpipe')
-rw-r--r-- | engines/fullpipe/messages.cpp | 14 | ||||
-rw-r--r-- | engines/fullpipe/messages.h | 6 |
2 files changed, 12 insertions, 8 deletions
diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index 111c70ce05..22a1fe7108 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -362,17 +362,16 @@ bool MessageQueue::load(MfcArchive &file) { bool MessageQueue::chain(StaticANIObject *ani) { if (checkGlobalExCommandList1() && checkGlobalExCommandList2()) { - if (!(getFlags() & 2)) { + if (!(getFlags() & kInGlobalQueue)) { g_fp->_globalMessageQueueList->addMessageQueue(this); - _flags |= 2; + _flags |= kInGlobalQueue; } if (ani) { ani->queueMessageQueue(this); - return true; } else { sendNextCommand(); - return true; } + return true; } return false; } @@ -653,8 +652,7 @@ MessageQueue *GlobalMessageQueueList::getMessageQueueById(int id) { void GlobalMessageQueueList::deleteQueueById(int id) { for (uint i = 0; i < size(); i++) if (_storage[i]->_id == id) { - remove_at(i); - + delete remove_at(i); disableQueueById(id); return; } @@ -663,7 +661,7 @@ void GlobalMessageQueueList::deleteQueueById(int id) { void GlobalMessageQueueList::removeQueueById(int id) { for (uint i = 0; i < size(); i++) if (_storage[i]->_id == id) { - _storage[i]->_flags &= 0xFD; // It is quite pointless + _storage[i]->_flags &= ~kInGlobalQueue; remove_at(i); disableQueueById(id); @@ -708,7 +706,7 @@ int GlobalMessageQueueList::compact() { } void GlobalMessageQueueList::addMessageQueue(MessageQueue *msg) { - msg->setFlags(msg->getFlags() | 2); + msg->setFlags(msg->getFlags() | kInGlobalQueue); push_back(msg); } diff --git a/engines/fullpipe/messages.h b/engines/fullpipe/messages.h index 0bdfb23835..65c5e9b372 100644 --- a/engines/fullpipe/messages.h +++ b/engines/fullpipe/messages.h @@ -31,6 +31,10 @@ namespace Fullpipe { +enum QueueFlags { + kInGlobalQueue = 2 +}; + class Message : public CObject { public: int _messageKind; @@ -146,6 +150,7 @@ class MessageQueue : public CObject { void setParamInt(int key1, int key2); + /** `ani` will own `this` if `chain` returns true */ bool chain(StaticANIObject *ani); void update(); void sendNextCommand(); @@ -168,6 +173,7 @@ class GlobalMessageQueueList : public Common::Array<MessageQueue *> { void deleteQueueById(int id); void removeQueueById(int id); void disableQueueById(int id); + /** `msg` becomes owned by `this` */ void addMessageQueue(MessageQueue *msg); int compact(); |