From 39ea2f66ac635613c3a817c16f80b11ac207d320 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Tue, 14 Nov 2017 20:50:13 -0600 Subject: FULLPIPE: Fix deleted queue leaks & clarify flags --- engines/fullpipe/messages.cpp | 14 ++++++-------- engines/fullpipe/messages.h | 6 ++++++ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'engines/fullpipe') 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 { void deleteQueueById(int id); void removeQueueById(int id); void disableQueueById(int id); + /** `msg` becomes owned by `this` */ void addMessageQueue(MessageQueue *msg); int compact(); -- cgit v1.2.3