Skip to content

Commit

Permalink
FULLPIPE: More work on sceneSwitcher. MessageHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent 7aa2377 commit 9d83eb1
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 2 deletions.
3 changes: 3 additions & 0 deletions engines/fullpipe/fullpipe.cpp
Expand Up @@ -69,6 +69,9 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc)
_scene2 = 0;

_globalMessageQueueList = 0;
_messageHandlers = 0;

_updateScreenCallback = 0;

g_fullpipe = this;
}
Expand Down
4 changes: 4 additions & 0 deletions engines/fullpipe/fullpipe.h
Expand Up @@ -50,6 +50,7 @@ class CInventory2;
class EntranceInfo;
class GameProject;
class GlobalMessageQueueList;
class MessageHandler;
class NGIArchive;
class Scene;
class SoundList;
Expand Down Expand Up @@ -110,6 +111,7 @@ class FullpipeEngine : public ::Engine {
bool _flgSoundList;

GlobalMessageQueueList *_globalMessageQueueList;
MessageHandler *_messageHandlers;

bool _needQuit;

Expand All @@ -124,6 +126,8 @@ class FullpipeEngine : public ::Engine {
Scene *_inventoryScene;
CInventory2 *_inventory;

int (*_updateScreenCallback)(void *);

void setObjectState(const char *name, int state);
int getObjectEnumState(const char *name, const char *state);

Expand Down
1 change: 1 addition & 0 deletions engines/fullpipe/gfx.h
Expand Up @@ -110,6 +110,7 @@ class GameObject : public CObject {
virtual bool load(MfcArchive &file);
void setOXY(int x, int y);
void renumPictures(CPtrList *lst);
void setFlags(int16 flags) { _flags = flags; }
};

class PictureObject : public GameObject {
Expand Down
32 changes: 32 additions & 0 deletions engines/fullpipe/messagequeue.cpp
Expand Up @@ -87,4 +87,36 @@ void GlobalMessageQueueList::disableQueueById(int id) {
}
}

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;
}

} // End of namespace Fullpipe
11 changes: 11 additions & 0 deletions engines/fullpipe/messagequeue.h
Expand Up @@ -62,6 +62,17 @@ class GlobalMessageQueueList : public CPtrList {
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);

} // End of namespace Fullpipe

#endif /* FULLPIPE_MESSAGEQUEUE_H */
15 changes: 15 additions & 0 deletions engines/fullpipe/scene.cpp
Expand Up @@ -283,6 +283,21 @@ void Scene::addStaticANIObject(StaticANIObject *obj, bool addList2) {
}
}

void Scene::setPictureObjectsFlag4() {
for (uint i = 0; i < _picObjList.size(); i++) {
((PictureObject *)_picObjList[i])->_flags |= 4;
}
}

PictureObject *Scene::getPictureObjectById(int objId, int flags) {
for (uint i = 1; i < _picObjList.size(); i++) {
if(((PictureObject *)_picObjList[i])->_id == objId && ((PictureObject *)_picObjList[i])->_field_4 == flags)
return (PictureObject *)_picObjList[i];
}

return 0;
}

void Scene::draw(int par) {
updateScrolling(par);

Expand Down
2 changes: 2 additions & 0 deletions engines/fullpipe/scene.h
Expand Up @@ -54,6 +54,8 @@ class Scene : public Background {
StaticANIObject *getStaticANIObject1ById(int obj, int a3);
void deleteStaticANIObject(StaticANIObject *obj);
void addStaticANIObject(StaticANIObject *obj, bool addList2);
void setPictureObjectsFlag4();
PictureObject *getPictureObjectById(int objId, int flags);
};

class SceneTag : public CObject {
Expand Down
5 changes: 3 additions & 2 deletions engines/fullpipe/scenes.cpp
Expand Up @@ -31,6 +31,7 @@
#include "fullpipe/sound.h"
#include "fullpipe/motion.h"
#include "fullpipe/input.h"
#include "fullpipe/messagequeue.h"

#include "fullpipe/gameobj.h"

Expand Down Expand Up @@ -111,12 +112,11 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) {
_aniMan2 = 0;
}

#if 0
scene->setPictureObjectsFlag4();

for (CPtrList::iterator s = scene->_staticANIObjectList1.begin(); s != scene->_staticANIObjectList1.end(); ++s) {
StaticANIObject *o = (StaticANIObject *)s;
o->setFlags(o->field_6 & 0xFE7F);
o->setFlags(o->_field_6 & 0xFE7F);
}

PictureObject *p = accessScene(SC_INV)->getPictureObjectById(PIC_INV_MENU, 0);
Expand All @@ -125,6 +125,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) {
removeMessageHandler(2, -1);
_updateScreenCallback = 0;

#if 0
switch (entrance->_sceneId) {
case SC_INTRO1:
sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_INTRO1");
Expand Down

0 comments on commit 9d83eb1

Please sign in to comment.