diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/gameloader.cpp | 69 | ||||
-rw-r--r-- | engines/fullpipe/messages.cpp | 69 | ||||
-rw-r--r-- | engines/fullpipe/messages.h | 14 | ||||
-rw-r--r-- | engines/fullpipe/scene.cpp | 8 | ||||
-rw-r--r-- | engines/fullpipe/scene.h | 1 |
5 files changed, 160 insertions, 1 deletions
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp index 61a4915fa7..1d53cd3e15 100644 --- a/engines/fullpipe/gameloader.cpp +++ b/engines/fullpipe/gameloader.cpp @@ -25,6 +25,7 @@ #include "fullpipe/gameloader.h" #include "fullpipe/scene.h" #include "fullpipe/input.h" +#include "fullpipe/statics.h" namespace Fullpipe { @@ -153,7 +154,73 @@ bool CGameLoader::loadScene(int sceneId) { } bool CGameLoader::gotoScene(int sceneId, int entranceId) { - warning("STUB: CGameLoader::gotoScene(%d, %d)", sceneId, entranceId); + SceneTag *st; + + int sc2idx = getSceneTagBySceneId(sceneId, &st); + + if (sc2idx < 0) + return false; + + if (!_sc2array[sc2idx]._isLoaded) + return 0; + + if (_sc2array[sc2idx]._entranceDataCount < 1) { + g_fullpipe->_currentScene = st->_scene; + return true; + } + + if (_sc2array[sc2idx]._entranceDataCount <= 0 ) + return false; + + int entranceIdx; + for (entranceIdx = 0; _sc2array[sc2idx]._entranceData[entranceIdx]->_field_4 != entranceId; entranceIdx++) { + if (entranceIdx >= _sc2array[sc2idx]._entranceDataCount) + return false; + } + + CGameVar *sg = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); + + if (sg || (sg = _gameVar->getSubVarByName("OBJSTATES")->addSubVarAsInt("SAVEGAME", 0)) != 0) + sg->setSubVarAsInt("Entrance", entranceId); + + if (!g_fullpipe->sceneSwitcher(_sc2array[sc2idx]._entranceData[entranceIdx])) + return 0; + + g_fullpipe->_msgObjectId2 = 0; + g_fullpipe->_msgY = -1; + g_fullpipe->_msgX = -1; + + g_fullpipe->_currentScene = st->_scene; + + MessageQueue *mq1 = g_fullpipe->_currentScene->getMessageQueueById(_sc2array[sc2idx]._entranceData[entranceIdx]->_messageQueueId); + if (mq1) { + MessageQueue *mq = new MessageQueue(mq1, 0, 0); + + StaticANIObject *stobj = g_fullpipe->_currentScene->getStaticANIObject1ById(_field_FA, -1); + if (stobj) { + stobj->setFlags(stobj->_flags & 0x100); + + ExCommand *ex = new ExCommand(stobj->_id, 34, 256, 0, 0, 0, 1, 0, 0, 0); + + ex->_field_14 = 256; + ex->_messageNum = 0; + ex->_excFlags |= 3; + + mq->_exCommands.push_back(ex); + } + + mq->setFlags(mq->getFlags() | 1); + + if (!mq->chain(0)) { + delete mq; + + return false; + } + } else { + StaticANIObject *stobj = g_fullpipe->_currentScene->getStaticANIObject1ById(_field_FA, -1); + if (stobj) + stobj->setFlags(stobj->_flags & 0xfeff); + } return true; } diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index 6b07a4ef69..69b29dcef8 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -42,6 +42,14 @@ ExCommand::ExCommand(ExCommand *src) : Message(src) { } +ExCommand::ExCommand(int16 parentId, int messageKind, int messageNum, int x, int y, int a7, int a8, int sceneClickX, int sceneClickY, int a11) : + Message(parentId, messageKind, x, y, a7, a8, sceneClickX, sceneClickY, a11) { + _field_3C = 1; + _messageNum = messageNum; + _excFlags = 0; + _parId = 0; +} + bool ExCommand::load(MfcArchive &file) { debug(5, "ExCommand::load()"); @@ -103,6 +111,22 @@ Message::Message(Message *src) { _field_34 = src->_field_34; } +Message::Message(int16 parentId, int messageKind, int x, int y, int a6, int a7, int sceneClickX, int sceneClickY, int a10) { + _messageKind = messageKind; + _parentId = parentId; + _x = x; + _y = y; + _field_14 = a6; + _sceneClickX = sceneClickX; + _sceneClickY = sceneClickY; + _field_24 = a7; + _field_20 = a10; + _param28 = 0; + _field_2C = 0; + _field_30 = 0; + _field_34 = 0; +} + CObjstateCommand::CObjstateCommand() { _value = 0; } @@ -128,6 +152,32 @@ MessageQueue::MessageQueue() { _flags = 0; } +MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) { + _counter = 0; + _field_38 = (field_38 == 0); + + for (uint i = 0; i < src->_exCommands.size(); i++) { + ExCommand *ex = new ExCommand((ExCommand *)src->_exCommands[i]); + ex->_excFlags |= 2; + + _exCommands.push_back(ex); + } + _field_14 = src->_field_14; + + if (parId) + _parId = parId; + else + _parId = src->_parId; + + _id = g_fullpipe->_globalMessageQueueList->compact(); + _dataId = src->_dataId; + _flags = src->_flags; + + g_fullpipe->_globalMessageQueueList->addMessageQueue(this); + + _isFinished = 0; +} + bool MessageQueue::load(MfcArchive &file) { debug(5, "MessageQueue::load()"); @@ -153,6 +203,13 @@ bool MessageQueue::load(MfcArchive &file) { return true; } +bool MessageQueue::chain(StaticANIObject *ani) { + warning("STUB: MessageQueue::chain()"); + + return true; +} + + MessageQueue *GlobalMessageQueueList::getMessageQueueById(int id) { for (CPtrList::iterator s = begin(); s != end(); ++s) { if (((MessageQueue *)s)->_id == id) @@ -179,6 +236,18 @@ void GlobalMessageQueueList::disableQueueById(int id) { } } +int GlobalMessageQueueList::compact() { + warning("STUB: GlobalMessageQueueList::compact()"); + + return 0; +} + +void GlobalMessageQueueList::addMessageQueue(MessageQueue *msg) { + msg->setFlags(msg->getFlags() | 2); + + push_back(msg); +} + bool removeMessageHandler(int16 id, int pos) { if (g_fullpipe->_messageHandlers) { MessageHandler *curItem = g_fullpipe->_messageHandlers; diff --git a/engines/fullpipe/messages.h b/engines/fullpipe/messages.h index 97e416426b..c8fe264da3 100644 --- a/engines/fullpipe/messages.h +++ b/engines/fullpipe/messages.h @@ -50,9 +50,13 @@ class Message : public CObject { public: Message(); Message(Message *src); + Message(int16 parentId, int messageKind, int x, int y, int a6, int a7, int sceneClickX, int sceneClickY, int a10); }; class ExCommand : public Message { + friend class CGameLoader; + friend class MessageQueue; + int _messageNum; int _field_3C; int _excFlags; @@ -61,6 +65,7 @@ class ExCommand : public Message { public: ExCommand(); ExCommand(ExCommand *src); + ExCommand(int16 parentId, int messageKind, int messageNum, int x, int y, int a7, int a8, int sceneClickX, int sceneClickY, int a11); virtual ~ExCommand() {} virtual bool load(MfcArchive &file); @@ -78,6 +83,8 @@ class CObjstateCommand : public CObject { class MessageQueue : public CObject { friend class GlobalMessageQueueList; + friend class CGameLoader; + friend class Scene; protected: int _id; @@ -95,9 +102,13 @@ class MessageQueue : public CObject { public: MessageQueue(); + MessageQueue(MessageQueue *src, int parId, int field_38); virtual bool load(MfcArchive &file); int getFlags() { return _flags; } + void setFlags(int flags) { _flags = flags; } + + bool chain(StaticANIObject *ani); }; class GlobalMessageQueueList : public CPtrList { @@ -105,6 +116,9 @@ class GlobalMessageQueueList : public CPtrList { MessageQueue *getMessageQueueById(int id); void deleteQueueById(int id); void disableQueueById(int id); + void addMessageQueue(MessageQueue *msg); + + int compact(); }; struct MessageHandler { diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index 5347d761d2..9f4901d83a 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -332,6 +332,14 @@ PictureObject *Scene::getPictureObjectById(int objId, int flags) { return 0; } +MessageQueue *Scene::getMessageQueueById(int messageId) { + for (uint i = 0; i < _messageQueueList.size(); i++) + if (((MessageQueue *)_messageQueueList[i])->_dataId == messageId) + return (MessageQueue *)_messageQueueList[i]; + + return 0; +} + void Scene::preloadMovements(CGameVar *var) { CGameVar *preload = var->getSubVarByName("PRELOAD"); if (!preload) diff --git a/engines/fullpipe/scene.h b/engines/fullpipe/scene.h index 95528d2e9e..b3dbdcc605 100644 --- a/engines/fullpipe/scene.h +++ b/engines/fullpipe/scene.h @@ -57,6 +57,7 @@ class Scene : public Background { StaticANIObject *getAniMan(); StaticANIObject *getStaticANIObject1ById(int obj, int a3); StaticANIObject *getStaticANIObject1ByName(char *name, int a3); + MessageQueue *getMessageQueueById(int messageId); void deleteStaticANIObject(StaticANIObject *obj); void addStaticANIObject(StaticANIObject *obj, bool addList2); |