From 67bbf26ecd546d59304ec437125508eb70aab9a1 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 26 Jul 2013 15:42:11 +0300 Subject: FULLPIPE: Rename messagequeue.* to messages.* --- engines/fullpipe/fullpipe.cpp | 2 +- engines/fullpipe/messagequeue.cpp | 258 -------------------------------------- engines/fullpipe/messagequeue.h | 86 ------------- engines/fullpipe/messages.cpp | 258 ++++++++++++++++++++++++++++++++++++++ engines/fullpipe/messages.h | 86 +++++++++++++ engines/fullpipe/module.mk | 2 +- engines/fullpipe/scene.cpp | 2 +- engines/fullpipe/scenes.cpp | 2 +- engines/fullpipe/statics.cpp | 2 +- engines/fullpipe/utils.cpp | 2 +- 10 files changed, 350 insertions(+), 350 deletions(-) delete mode 100644 engines/fullpipe/messagequeue.cpp delete mode 100644 engines/fullpipe/messagequeue.h create mode 100644 engines/fullpipe/messages.cpp create mode 100644 engines/fullpipe/messages.h diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index f1c0aac7f8..d89e1f35f9 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -31,7 +31,7 @@ #include "fullpipe/objectnames.h" #include "fullpipe/objects.h" #include "fullpipe/gameloader.h" -#include "fullpipe/messagequeue.h" +#include "fullpipe/messages.h" #include "fullpipe/behavior.h" namespace Fullpipe { diff --git a/engines/fullpipe/messagequeue.cpp b/engines/fullpipe/messagequeue.cpp deleted file mode 100644 index 9d2ec383fb..0000000000 --- a/engines/fullpipe/messagequeue.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "fullpipe/fullpipe.h" - -#include "fullpipe/objects.h" -#include "fullpipe/messagequeue.h" - -namespace Fullpipe { - -MessageQueue::MessageQueue() { - _field_14 = 0; - _parId = 0; - _dataId = 0; - _id = 0; - _isFinished = 0; - _flags = 0; -} - -bool MessageQueue::load(MfcArchive &file) { - debug(5, "MessageQueue::load()"); - - _dataId = file.readUint16LE(); - - int count = file.readUint16LE(); - - assert(g_fullpipe->_gameProjectVersion >= 12); - - _queueName = file.readPascalString(); - - for (int i = 0; i < count; i++) { - CObject *tmp = file.readClass(); - - _exCommands.push_back(tmp); - } - - _id = -1; - _field_14 = 0; - _parId = 0; - _isFinished = 0; - - return true; -} - -MessageQueue *GlobalMessageQueueList::getMessageQueueById(int id) { - for (CPtrList::iterator s = begin(); s != end(); ++s) { - if (((MessageQueue *)s)->_id == id) - return (MessageQueue *)s; - } - - return 0; -} - -void GlobalMessageQueueList::deleteQueueById(int id) { - for (uint i = 0; i < size(); i++) - if (((MessageQueue *)((*this).operator[](i)))->_id == id) { - delete (MessageQueue *)remove_at(i); - - disableQueueById(id); - return; - } -} - -void GlobalMessageQueueList::disableQueueById(int id) { - for (CPtrList::iterator s = begin(); s != end(); ++s) { - if (((MessageQueue *)s)->_parId == id) - ((MessageQueue *)s)->_parId = 0; - } -} - -bool removeMessageHandler(int16 id, int pos) { - if (g_fullpipe->_messageHandlers) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; - MessageHandler *prevItem = 0; - int curPos = 0; - - while (id != curItem->id) { - prevItem = curItem; - curItem = curItem->nextItem; - curPos++; - - if (!curItem) - return false; - } - - if (pos == -1 || curPos == pos) { - prevItem->nextItem = curItem->nextItem; - delete curItem; - updateMessageHandlerIndex(prevItem->nextItem, -1); - - return true; - } - } - - return false; -} - -void updateMessageHandlerIndex(MessageHandler *msg, int offset) { - for (; msg; msg = msg->nextItem) - msg->index += offset; -} - -void addMessageHandler(int (*callback)(ExCommand *), int16 id) { - if (getMessageHandlerById(id)) - return; - - MessageHandler *curItem = g_fullpipe->_messageHandlers; - - if (!curItem) - return; - - int index = 0; - for (MessageHandler *i = g_fullpipe->_messageHandlers->nextItem; i; i = i->nextItem) { - curItem = i; - index++; - } - - allocMessageHandler(curItem, id, callback, index); - - if (curItem) - updateMessageHandlerIndex(curItem->nextItem->nextItem, 1); - -} - -MessageHandler *getMessageHandlerById(int16 id) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; - - if (!curItem) - return 0; - - while (id != curItem->id) { - curItem = curItem->nextItem; - - if (!curItem) - return 0; - } - - return curItem; -} - -bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExCommand *), int index) { - MessageHandler *msg = new MessageHandler; - - if (where) { - msg->nextItem = where->nextItem; - where->nextItem = msg; - msg->id = id; - msg->callback = callback; - msg->index = index; - } else { - msg->nextItem = 0; - msg->id = id; - msg->callback = callback; - msg->index = 0; - - g_fullpipe->_messageHandlers = msg; - } - - return true; -} - -int getMessageHandlersCount() { - int result; - MessageHandler *curItem = g_fullpipe->_messageHandlers; - - for (result = 0; curItem; result++) - curItem = curItem->nextItem; - - return result; -} - -bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id) { - if (getMessageHandlerById(id)) - return false; - - if (index) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; - - for (int i = index - 1; i > 0; i--) - if (curItem) - curItem = curItem->nextItem; - - bool res = allocMessageHandler(curItem, id, callback, index); - - if (res) - updateMessageHandlerIndex(curItem->nextItem->nextItem, 1); - - return res; - } else { - MessageHandler *newItem = new MessageHandler; - - newItem->nextItem = g_fullpipe->_messageHandlers; - newItem->id = id; - newItem->callback = callback; - newItem->index = 0; - - updateMessageHandlerIndex(g_fullpipe->_messageHandlers, 1); - g_fullpipe->_messageHandlers = newItem; - - return true; - } -} - -bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id) { - if (getMessageHandlerById(id)) - return false; - - MessageHandler *curItem = g_fullpipe->_messageHandlers; - - for (int i = index; i > 0; i--) - if (curItem) - curItem = curItem->nextItem; - - bool res = allocMessageHandler(curItem, id, callback, index + 1); - if (curItem) - updateMessageHandlerIndex(curItem->nextItem->nextItem, 1); - - return res; -} - -void clearMessageHandlers() { - MessageHandler *curItem; - MessageHandler *nextItem; - - curItem = g_fullpipe->_messageHandlers; - if (curItem) { - do { - nextItem = curItem->nextItem; - - delete curItem; - - curItem = nextItem; - } while (nextItem); - - g_fullpipe->_messageHandlers = 0; - } -} - -} // End of namespace Fullpipe diff --git a/engines/fullpipe/messagequeue.h b/engines/fullpipe/messagequeue.h deleted file mode 100644 index b47bf49049..0000000000 --- a/engines/fullpipe/messagequeue.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef FULLPIPE_MESSAGEQUEUE_H -#define FULLPIPE_MESSAGEQUEUE_H - -#include "fullpipe/utils.h" -#include "fullpipe/inventory.h" -#include "fullpipe/gfx.h" -#include "fullpipe/sound.h" -#include "fullpipe/scene.h" - -namespace Fullpipe { - -class MessageQueue : public CObject { - friend class GlobalMessageQueueList; - - protected: - int _id; - int _flags; - char *_queueName; - int16 _dataId; - int16 _field_12; - int _field_14; - CPtrList _exCommands; - int _counter; - int _field_38; - int _isFinished; - int _parId; - int _flag1; - - public: - MessageQueue(); - virtual bool load(MfcArchive &file); - - int getFlags() { return _flags; } -}; - -class GlobalMessageQueueList : public CPtrList { - public: - MessageQueue *getMessageQueueById(int id); - void deleteQueueById(int id); - void disableQueueById(int id); -}; - -struct MessageHandler { - int (*callback)(ExCommand *cmd); - int16 id; - int16 field_6; - int index; - MessageHandler *nextItem; -}; - -bool removeMessageHandler(int16 id, int pos); -void updateMessageHandlerIndex(MessageHandler *msg, int offset); -void addMessageHandler(int (*callback)(ExCommand *), int16 id); -MessageHandler *getMessageHandlerById(int16 id); -bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExCommand *), int index); -int getMessageHandlersCount(); -bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id); -bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id); -void clearMessageHandlers(); - - -} // End of namespace Fullpipe - -#endif /* FULLPIPE_MESSAGEQUEUE_H */ diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp new file mode 100644 index 0000000000..7f5f3b4fd8 --- /dev/null +++ b/engines/fullpipe/messages.cpp @@ -0,0 +1,258 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/messages.h" + +namespace Fullpipe { + +MessageQueue::MessageQueue() { + _field_14 = 0; + _parId = 0; + _dataId = 0; + _id = 0; + _isFinished = 0; + _flags = 0; +} + +bool MessageQueue::load(MfcArchive &file) { + debug(5, "MessageQueue::load()"); + + _dataId = file.readUint16LE(); + + int count = file.readUint16LE(); + + assert(g_fullpipe->_gameProjectVersion >= 12); + + _queueName = file.readPascalString(); + + for (int i = 0; i < count; i++) { + CObject *tmp = file.readClass(); + + _exCommands.push_back(tmp); + } + + _id = -1; + _field_14 = 0; + _parId = 0; + _isFinished = 0; + + return true; +} + +MessageQueue *GlobalMessageQueueList::getMessageQueueById(int id) { + for (CPtrList::iterator s = begin(); s != end(); ++s) { + if (((MessageQueue *)s)->_id == id) + return (MessageQueue *)s; + } + + return 0; +} + +void GlobalMessageQueueList::deleteQueueById(int id) { + for (uint i = 0; i < size(); i++) + if (((MessageQueue *)((*this).operator[](i)))->_id == id) { + delete (MessageQueue *)remove_at(i); + + disableQueueById(id); + return; + } +} + +void GlobalMessageQueueList::disableQueueById(int id) { + for (CPtrList::iterator s = begin(); s != end(); ++s) { + if (((MessageQueue *)s)->_parId == id) + ((MessageQueue *)s)->_parId = 0; + } +} + +bool removeMessageHandler(int16 id, int pos) { + if (g_fullpipe->_messageHandlers) { + MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *prevItem = 0; + int curPos = 0; + + while (id != curItem->id) { + prevItem = curItem; + curItem = curItem->nextItem; + curPos++; + + if (!curItem) + return false; + } + + if (pos == -1 || curPos == pos) { + prevItem->nextItem = curItem->nextItem; + delete curItem; + updateMessageHandlerIndex(prevItem->nextItem, -1); + + return true; + } + } + + return false; +} + +void updateMessageHandlerIndex(MessageHandler *msg, int offset) { + for (; msg; msg = msg->nextItem) + msg->index += offset; +} + +void addMessageHandler(int (*callback)(ExCommand *), int16 id) { + if (getMessageHandlerById(id)) + return; + + MessageHandler *curItem = g_fullpipe->_messageHandlers; + + if (!curItem) + return; + + int index = 0; + for (MessageHandler *i = g_fullpipe->_messageHandlers->nextItem; i; i = i->nextItem) { + curItem = i; + index++; + } + + allocMessageHandler(curItem, id, callback, index); + + if (curItem) + updateMessageHandlerIndex(curItem->nextItem->nextItem, 1); + +} + +MessageHandler *getMessageHandlerById(int16 id) { + MessageHandler *curItem = g_fullpipe->_messageHandlers; + + if (!curItem) + return 0; + + while (id != curItem->id) { + curItem = curItem->nextItem; + + if (!curItem) + return 0; + } + + return curItem; +} + +bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExCommand *), int index) { + MessageHandler *msg = new MessageHandler; + + if (where) { + msg->nextItem = where->nextItem; + where->nextItem = msg; + msg->id = id; + msg->callback = callback; + msg->index = index; + } else { + msg->nextItem = 0; + msg->id = id; + msg->callback = callback; + msg->index = 0; + + g_fullpipe->_messageHandlers = msg; + } + + return true; +} + +int getMessageHandlersCount() { + int result; + MessageHandler *curItem = g_fullpipe->_messageHandlers; + + for (result = 0; curItem; result++) + curItem = curItem->nextItem; + + return result; +} + +bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id) { + if (getMessageHandlerById(id)) + return false; + + if (index) { + MessageHandler *curItem = g_fullpipe->_messageHandlers; + + for (int i = index - 1; i > 0; i--) + if (curItem) + curItem = curItem->nextItem; + + bool res = allocMessageHandler(curItem, id, callback, index); + + if (res) + updateMessageHandlerIndex(curItem->nextItem->nextItem, 1); + + return res; + } else { + MessageHandler *newItem = new MessageHandler; + + newItem->nextItem = g_fullpipe->_messageHandlers; + newItem->id = id; + newItem->callback = callback; + newItem->index = 0; + + updateMessageHandlerIndex(g_fullpipe->_messageHandlers, 1); + g_fullpipe->_messageHandlers = newItem; + + return true; + } +} + +bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id) { + if (getMessageHandlerById(id)) + return false; + + MessageHandler *curItem = g_fullpipe->_messageHandlers; + + for (int i = index; i > 0; i--) + if (curItem) + curItem = curItem->nextItem; + + bool res = allocMessageHandler(curItem, id, callback, index + 1); + if (curItem) + updateMessageHandlerIndex(curItem->nextItem->nextItem, 1); + + return res; +} + +void clearMessageHandlers() { + MessageHandler *curItem; + MessageHandler *nextItem; + + curItem = g_fullpipe->_messageHandlers; + if (curItem) { + do { + nextItem = curItem->nextItem; + + delete curItem; + + curItem = nextItem; + } while (nextItem); + + g_fullpipe->_messageHandlers = 0; + } +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/messages.h b/engines/fullpipe/messages.h new file mode 100644 index 0000000000..b47bf49049 --- /dev/null +++ b/engines/fullpipe/messages.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef FULLPIPE_MESSAGEQUEUE_H +#define FULLPIPE_MESSAGEQUEUE_H + +#include "fullpipe/utils.h" +#include "fullpipe/inventory.h" +#include "fullpipe/gfx.h" +#include "fullpipe/sound.h" +#include "fullpipe/scene.h" + +namespace Fullpipe { + +class MessageQueue : public CObject { + friend class GlobalMessageQueueList; + + protected: + int _id; + int _flags; + char *_queueName; + int16 _dataId; + int16 _field_12; + int _field_14; + CPtrList _exCommands; + int _counter; + int _field_38; + int _isFinished; + int _parId; + int _flag1; + + public: + MessageQueue(); + virtual bool load(MfcArchive &file); + + int getFlags() { return _flags; } +}; + +class GlobalMessageQueueList : public CPtrList { + public: + MessageQueue *getMessageQueueById(int id); + void deleteQueueById(int id); + void disableQueueById(int id); +}; + +struct MessageHandler { + int (*callback)(ExCommand *cmd); + int16 id; + int16 field_6; + int index; + MessageHandler *nextItem; +}; + +bool removeMessageHandler(int16 id, int pos); +void updateMessageHandlerIndex(MessageHandler *msg, int offset); +void addMessageHandler(int (*callback)(ExCommand *), int16 id); +MessageHandler *getMessageHandlerById(int16 id); +bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExCommand *), int index); +int getMessageHandlersCount(); +bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id); +bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id); +void clearMessageHandlers(); + + +} // End of namespace Fullpipe + +#endif /* FULLPIPE_MESSAGEQUEUE_H */ diff --git a/engines/fullpipe/module.mk b/engines/fullpipe/module.mk index 934d916ed1..335d34732d 100644 --- a/engines/fullpipe/module.mk +++ b/engines/fullpipe/module.mk @@ -8,7 +8,7 @@ MODULE_OBJS = \ gfx.o \ input.o \ inventory.o \ - messagequeue.o \ + messages.o \ motion.o \ ngiarchive.o \ scene.o \ diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index 93c56daadf..1f6cb21ad7 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -25,7 +25,7 @@ #include "fullpipe/objects.h" #include "fullpipe/ngiarchive.h" #include "fullpipe/statics.h" -#include "fullpipe/messagequeue.h" +#include "fullpipe/messages.h" #include "fullpipe/gameobj.h" diff --git a/engines/fullpipe/scenes.cpp b/engines/fullpipe/scenes.cpp index c12c0a0c7f..6e033a08f3 100644 --- a/engines/fullpipe/scenes.cpp +++ b/engines/fullpipe/scenes.cpp @@ -31,7 +31,7 @@ #include "fullpipe/sound.h" #include "fullpipe/motion.h" #include "fullpipe/input.h" -#include "fullpipe/messagequeue.h" +#include "fullpipe/messages.h" #include "fullpipe/behavior.h" #include "fullpipe/gameobj.h" diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index 7d91a11eda..32dbf4a854 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -25,7 +25,7 @@ #include "fullpipe/objects.h" #include "fullpipe/ngiarchive.h" #include "fullpipe/statics.h" -#include "fullpipe/messagequeue.h" +#include "fullpipe/messages.h" #include "fullpipe/gameobj.h" #include "fullpipe/objectnames.h" diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index ec6b59029b..900ca84eea 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -28,7 +28,7 @@ #include "fullpipe/objects.h" #include "fullpipe/motion.h" #include "fullpipe/ngiarchive.h" -#include "fullpipe/messagequeue.h" +#include "fullpipe/messages.h" namespace Fullpipe { -- cgit v1.2.3