diff options
author | Kamil Zbróg | 2013-12-26 14:55:11 +0000 |
---|---|---|
committer | Kamil Zbróg | 2013-12-26 14:55:11 +0000 |
commit | 165b8be77f4621ff5de8a483c6cd9ac497492a0a (patch) | |
tree | 41065a7a961c1b0caa07ac4b2b1b6c027c12ae99 /engines/fullpipe/messages.cpp | |
parent | fc04a3c328e70733eea1b065cb5dacc9ec6999f2 (diff) | |
parent | f3691700436e647e808023180430263a6567bfaf (diff) | |
download | scummvm-rg350-165b8be77f4621ff5de8a483c6cd9ac497492a0a.tar.gz scummvm-rg350-165b8be77f4621ff5de8a483c6cd9ac497492a0a.tar.bz2 scummvm-rg350-165b8be77f4621ff5de8a483c6cd9ac497492a0a.zip |
Merge remote-tracking branch 'sync/master' into prince-malik
Diffstat (limited to 'engines/fullpipe/messages.cpp')
-rw-r--r-- | engines/fullpipe/messages.cpp | 107 |
1 files changed, 63 insertions, 44 deletions
diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index 8ed99fce15..8ca416bb9e 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -73,7 +73,7 @@ bool ExCommand::load(MfcArchive &file) { _field_3C = 0; - if (g_fullpipe->_gameProjectVersion >= 12) { + if (g_fp->_gameProjectVersion >= 12) { _excFlags = file.readUint32LE(); _parId = file.readUint32LE(); } @@ -83,12 +83,12 @@ bool ExCommand::load(MfcArchive &file) { bool ExCommand::handleMessage() { int cnt = 0; - for (MessageHandler *m = g_fullpipe->_messageHandlers; m; m = m->nextItem) + for (MessageHandler *m = g_fp->_messageHandlers; m; m = m->nextItem) cnt += m->callback(this); if (_messageKind == 17 || (_excFlags & 1)) { if (_parId) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(_parId); if (mq) mq->update(); } @@ -101,18 +101,18 @@ bool ExCommand::handleMessage() { } void ExCommand::sendMessage() { - g_fullpipe->_exCommandList.push_back(this); + g_fp->_exCommandList.push_back(this); processMessages(); } void ExCommand::postMessage() { - g_fullpipe->_exCommandList.push_back(this); + g_fp->_exCommandList.push_back(this); } void ExCommand::handle() { - if (g_fullpipe->_modalObject) { - g_fullpipe->_modalObject->handleMessage(this); + if (g_fp->_modalObject) { + g_fp->_modalObject->handleMessage(this); delete this; } else { @@ -205,7 +205,7 @@ MessageQueue::MessageQueue(int dataId) { _field_14 = 0; _parId = 0; _dataId = dataId; - _id = g_fullpipe->_globalMessageQueueList->compact(); + _id = g_fp->_globalMessageQueueList->compact(); _isFinished = 0; _flags = 0; _queueName = 0; @@ -231,11 +231,11 @@ MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) { else _parId = src->_parId; - _id = g_fullpipe->_globalMessageQueueList->compact(); + _id = g_fp->_globalMessageQueueList->compact(); _dataId = src->_dataId; _flags = src->_flags; - g_fullpipe->_globalMessageQueueList->addMessageQueue(this); + g_fp->_globalMessageQueueList->addMessageQueue(this); _isFinished = 0; _flag1 = 0; @@ -255,7 +255,7 @@ MessageQueue::~MessageQueue() { delete _field_14; if (_flags & 2) { - g_fullpipe->_globalMessageQueueList->removeQueueById(_id); + g_fp->_globalMessageQueueList->removeQueueById(_id); } finish(); @@ -270,7 +270,7 @@ bool MessageQueue::load(MfcArchive &file) { int count = file.readUint16LE(); - assert(g_fullpipe->_gameProjectVersion >= 12); + assert(g_fp->_gameProjectVersion >= 12); _queueName = file.readPascalString(); @@ -291,7 +291,7 @@ bool MessageQueue::load(MfcArchive &file) { bool MessageQueue::chain(StaticANIObject *ani) { if (checkGlobalExCommandList1() && checkGlobalExCommandList2()) { if (!(getFlags() & 2)) { - g_fullpipe->_globalMessageQueueList->addMessageQueue(this); + g_fp->_globalMessageQueueList->addMessageQueue(this); _flags |= 2; } if (ani) { @@ -331,7 +331,7 @@ void MessageQueue::addExCommandToEnd(ExCommand *ex) { } ExCommand *MessageQueue::getExCommandByIndex(uint idx) { - if (idx > getCount()) + if (idx >= getCount()) return 0; Common::List<ExCommand *>::iterator it = _exCommands.begin(); @@ -345,7 +345,7 @@ ExCommand *MessageQueue::getExCommandByIndex(uint idx) { } void MessageQueue::deleteExCommandByIndex(uint idx, bool doFree) { - if (idx > getCount()) + if (idx >= getCount()) return; Common::List<ExCommand *>::iterator it = _exCommands.begin(); @@ -398,7 +398,7 @@ bool MessageQueue::checkGlobalExCommandList1() { if (ex->_messageKind != 1 && ex->_messageKind != 20 && ex->_messageKind != 5 && ex->_messageKind != 27) continue; - for (Common::List<ExCommand *>::iterator it = g_fullpipe->_exCommandList.begin(); it != g_fullpipe->_exCommandList.end(); it++) { + for (Common::List<ExCommand *>::iterator it = g_fp->_exCommandList.begin(); it != g_fp->_exCommandList.end(); it++) { ex1 = *it; if (ex1->_messageKind != 1 && ex1->_messageKind != 20 && ex1->_messageKind != 5 && ex1->_messageKind != 27) @@ -407,7 +407,7 @@ bool MessageQueue::checkGlobalExCommandList1() { if (ex1->_keyCode != ex->_keyCode && ex1->_keyCode != -1 && ex->_keyCode != -1) continue; - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex1->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex1->_parId); if (mq) { if (mq->getFlags() & 1) @@ -427,7 +427,7 @@ bool MessageQueue::checkGlobalExCommandList2() { if (ex->_messageKind != 1 && ex->_messageKind != 20 && ex->_messageKind != 5 && ex->_messageKind != 27) continue; - for (Common::List<ExCommand *>::iterator it = g_fullpipe->_exCommandList.begin(); it != g_fullpipe->_exCommandList.end();) { + for (Common::List<ExCommand *>::iterator it = g_fp->_exCommandList.begin(); it != g_fp->_exCommandList.end();) { ex1 = *it; if (ex1->_messageKind != 1 && ex1->_messageKind != 20 && ex1->_messageKind != 5 && ex1->_messageKind != 27) { @@ -440,7 +440,7 @@ bool MessageQueue::checkGlobalExCommandList2() { continue; } - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex1->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex1->_parId); if (mq) { if (mq->getFlags() & 1) @@ -449,7 +449,7 @@ bool MessageQueue::checkGlobalExCommandList2() { delete mq; } - it = g_fullpipe->_exCommandList.erase(it); + it = g_fp->_exCommandList.erase(it); if (ex1->_excFlags & 2) { delete ex1; @@ -463,7 +463,7 @@ void MessageQueue::finish() { if (!_parId) return; - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(_parId); _parId = 0; @@ -573,7 +573,7 @@ int GlobalMessageQueueList::compact() { disableQueueById(_storage[i]->_id); remove_at(i); } else { - if (_storage[i]->_id < size() + 2) + if ((uint)_storage[i]->_id < size() + 2) useList[_storage[i]->_id] = 1; i++; } @@ -602,8 +602,8 @@ void clearGlobalMessageQueueList1() { } bool removeMessageHandler(int16 id, int pos) { - if (g_fullpipe->_messageHandlers) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + if (g_fp->_messageHandlers) { + MessageHandler *curItem = g_fp->_messageHandlers; MessageHandler *prevItem = 0; int curPos = 0; @@ -637,13 +637,13 @@ void addMessageHandler(int (*callback)(ExCommand *), int16 id) { if (getMessageHandlerById(id)) return; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; if (!curItem) return; int index = 0; - for (MessageHandler *i = g_fullpipe->_messageHandlers->nextItem; i; i = i->nextItem) { + for (MessageHandler *i = g_fp->_messageHandlers->nextItem; i; i = i->nextItem) { curItem = i; index++; } @@ -655,7 +655,7 @@ void addMessageHandler(int (*callback)(ExCommand *), int16 id) { } MessageHandler *getMessageHandlerById(int16 id) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; if (!curItem) return 0; @@ -685,7 +685,7 @@ bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExComm msg->callback = callback; msg->index = 0; - g_fullpipe->_messageHandlers = msg; + g_fp->_messageHandlers = msg; } return true; @@ -693,7 +693,7 @@ bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExComm int getMessageHandlersCount() { int result; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (result = 0; curItem; result++) curItem = curItem->nextItem; @@ -706,7 +706,7 @@ bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id) return false; if (index) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (int i = index - 1; i > 0; i--) if (curItem) @@ -724,13 +724,13 @@ bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id) } else { MessageHandler *newItem = new MessageHandler; - newItem->nextItem = g_fullpipe->_messageHandlers; + newItem->nextItem = g_fp->_messageHandlers; newItem->id = id; newItem->callback = callback; newItem->index = 0; - updateMessageHandlerIndex(g_fullpipe->_messageHandlers, 1); - g_fullpipe->_messageHandlers = newItem; + updateMessageHandlerIndex(g_fp->_messageHandlers, 1); + g_fp->_messageHandlers = newItem; return true; } @@ -740,7 +740,7 @@ bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id) { if (getMessageHandlerById(id)) return false; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (int i = index; i > 0; i--) if (curItem) @@ -757,7 +757,7 @@ void clearMessageHandlers() { MessageHandler *curItem; MessageHandler *nextItem; - curItem = g_fullpipe->_messageHandlers; + curItem = g_fp->_messageHandlers; if (curItem) { do { nextItem = curItem->nextItem; @@ -767,32 +767,32 @@ void clearMessageHandlers() { curItem = nextItem; } while (nextItem); - g_fullpipe->_messageHandlers = 0; + g_fp->_messageHandlers = 0; } } void processMessages() { - if (!g_fullpipe->_isProcessingMessages) { - g_fullpipe->_isProcessingMessages = true; + if (!g_fp->_isProcessingMessages) { + g_fp->_isProcessingMessages = true; - while (g_fullpipe->_exCommandList.size()) { - ExCommand *ex = g_fullpipe->_exCommandList.front(); - g_fullpipe->_exCommandList.pop_front(); + while (g_fp->_exCommandList.size()) { + ExCommand *ex = g_fp->_exCommandList.front(); + g_fp->_exCommandList.pop_front(); ex->handleMessage(); } - g_fullpipe->_isProcessingMessages = false; + g_fp->_isProcessingMessages = false; } } void updateGlobalMessageQueue(int id, int objid) { - MessageQueue *m = g_fullpipe->_globalMessageQueueList->getMessageQueueById(id); + MessageQueue *m = g_fp->_globalMessageQueueList->getMessageQueueById(id); if (m) { m->update(); } } bool chainQueue(int queueId, int flags) { - MessageQueue *mq = g_fullpipe->_currentScene->getMessageQueueById(queueId); + MessageQueue *mq = g_fp->_currentScene->getMessageQueueById(queueId); if (!mq) return false; @@ -810,6 +810,25 @@ bool chainQueue(int queueId, int flags) { return true; } +bool chainObjQueue(StaticANIObject *obj, int queueId, int flags) { + MessageQueue *mq = g_fp->_currentScene->getMessageQueueById(queueId); + + if (!mq) + return false; + + MessageQueue *nmq = new MessageQueue(mq, 0, 0); + + nmq->_flags |= flags; + + if (!nmq->chain(obj)) { + delete nmq; + + return false; + } + + return true; +} + void postExCommand(int parentId, int keyCode, int x, int y, int f20, int f14) { ExCommand *ex = new ExCommand(parentId, 17, 64, 0, 0, 0, 1, 0, 0, 0); |