Skip to content

Commit

Permalink
FULLPIPE: Further work on sceneSwitcher
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent 62cbdd8 commit c4499bb
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 76 deletions.
2 changes: 2 additions & 0 deletions engines/fullpipe/fullpipe.cpp
Expand Up @@ -61,6 +61,8 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc)
_needQuit = false;

_aniMan = 0;
_aniMan2 = 0;
_currentScene = 0;
_scene2 = 0;

_globalMessageQueueList = 0;
Expand Down
2 changes: 2 additions & 0 deletions engines/fullpipe/fullpipe.h
Expand Up @@ -95,8 +95,10 @@ class FullpipeEngine : public ::Engine {
Common::Rect _sceneRect;
int _sceneWidth;
int _sceneHeight;
Scene *_currentScene;
Scene *_scene2;
StaticANIObject *_aniMan;
StaticANIObject *_aniMan2;

SoundList *_currSoundList1[11];
int _currSoundListCount;
Expand Down
8 changes: 8 additions & 0 deletions engines/fullpipe/gameloader.cpp
Expand Up @@ -27,6 +27,14 @@

namespace Fullpipe {

CInventory2 *getGameLoaderInventory() {
return &g_fullpipe->_gameLoader->_inventory;
}

CInteractionController *getGameLoaderInteractionController() {
return g_fullpipe->_gameLoader->_interactionController;
}

CGameLoader::CGameLoader() {
_interactionController = new CInteractionController();

Expand Down
5 changes: 4 additions & 1 deletion engines/fullpipe/gameloader.h
Expand Up @@ -43,10 +43,10 @@ class CGameLoader : public CObject {

CGameVar *_gameVar;
CInventory2 _inventory;
CInteractionController *_interactionController;

private:
GameProject *_gameProject;
CInteractionController *_interactionController;
int _field_C;
int _field_10;
int _field_14;
Expand All @@ -71,6 +71,9 @@ class CGameLoader : public CObject {
int _preloadId2;
};

CInventory2 *getGameLoaderInventory();
CInteractionController *getGameLoaderInteractionController();

} // End of namespace Fullpipe

#endif /* FULLPIPE_GAMELOADER_H */
38 changes: 19 additions & 19 deletions engines/fullpipe/gfx.cpp
Expand Up @@ -95,7 +95,7 @@ bool Background::load(MfcArchive &file) {

void Background::addPictureObject(PictureObject *pct) {
if (pct->_field_4)
renumPictures(pct);
pct->renumPictures(&_picObjList);

bool inserted = false;
for (uint i = 0; i < _picObjList.size(); i++) {
Expand All @@ -111,24 +111,6 @@ void Background::addPictureObject(PictureObject *pct) {
}
}

void Background::renumPictures(PictureObject *pct) {
int *buf = (int *)calloc(_picObjList.size() + 2, sizeof(int));

for (uint i = 0; i < _picObjList.size(); i++) {
if (pct->_id == ((PictureObject *)_picObjList[i])->_id)
buf[((PictureObject *)_picObjList[i])->_field_4] = 1;
}

if (buf[pct->_field_4]) {
uint count;
for (count = 1; buf[count] && count < _picObjList.size() + 2; count++)
;
pct->_field_4 = count;
}

free(buf);
}

PictureObject::PictureObject() {
_ox = 0;
_oy = 0;
Expand Down Expand Up @@ -205,6 +187,24 @@ void GameObject::setOXY(int x, int y) {
_oy = y;
}

void GameObject::renumPictures(CPtrList *lst) {
int *buf = (int *)calloc(lst->size() + 2, sizeof(int));

for (uint i = 0; i < lst->size(); i++) {
if (_id == ((PictureObject *)((*lst)[i]))->_id)
buf[((PictureObject *)((*lst)[i]))->_field_4] = 1;
}

if (buf[_field_4]) {
uint count;
for (count = 1; buf[count] && count < lst->size() + 2; count++)
;
_field_4 = count;
}

free(buf);
}

Picture::Picture() {
_x = 0;
_y = 0;
Expand Down
2 changes: 1 addition & 1 deletion engines/fullpipe/gfx.h
Expand Up @@ -109,6 +109,7 @@ class GameObject : public CObject {
GameObject();
virtual bool load(MfcArchive &file);
void setOXY(int x, int y);
void renumPictures(CPtrList *lst);
};

class PictureObject : public GameObject {
Expand Down Expand Up @@ -143,7 +144,6 @@ class Background : public CObject {
Background();
virtual bool load(MfcArchive &file);
void addPictureObject(PictureObject *pct);
void renumPictures(PictureObject *pct);
};

class Shadows : public CObject {
Expand Down
4 changes: 0 additions & 4 deletions engines/fullpipe/inventory.cpp
Expand Up @@ -28,10 +28,6 @@

namespace Fullpipe {

CInventory2 *getGameLoaderInventory() {
return &g_fullpipe->_gameLoader->_inventory;
}

bool CInventory::load(MfcArchive &file) {
debug(5, "CInventory::load()");

Expand Down
2 changes: 0 additions & 2 deletions engines/fullpipe/inventory.h
Expand Up @@ -103,8 +103,6 @@ class CInventory2 : public CInventory {

};

CInventory2 *getGameLoaderInventory();

} // End of namespace Fullpipe

#endif /* FULLPIPE_INVENTORY_H */
9 changes: 7 additions & 2 deletions engines/fullpipe/objects.h
Expand Up @@ -68,12 +68,17 @@ class CInteraction : public CObject {
class CInteractionController : public CObject {
CObList _interactions;
int16 _field_20;
int _flag24;
bool _flag24;

public:
CInteractionController() : _field_20(0), _flag24(1) {}
CInteractionController() : _field_20(0), _flag24(true) {}

virtual bool load(MfcArchive &file);

void enableFlag24() { _flag24 = true; }
void disableFlag24() { _flag24 = false; }

void sortInteractions(int sceneId);
};

class CInputControllerItemArray {
Expand Down
14 changes: 14 additions & 0 deletions engines/fullpipe/scene.cpp
Expand Up @@ -269,6 +269,20 @@ void Scene::deleteStaticANIObject(StaticANIObject *obj) {
}
}

void Scene::addStaticANIObject(StaticANIObject *obj, bool addList2) {
if (obj->_field_4)
obj->renumPictures(&_staticANIObjectList1);

_staticANIObjectList1.push_back(obj);

if (addList2) {
if (!obj->_field_4)
obj->clearFlags();

_staticANIObjectList2.push_back(obj);
}
}

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

Expand Down
3 changes: 2 additions & 1 deletion engines/fullpipe/scene.h
Expand Up @@ -52,7 +52,8 @@ class Scene : public Background {
void updateScrolling(int par);
StaticANIObject *getAniMan();
StaticANIObject *getStaticANIObject1ById(int obj, int a3);
void deleteStaticANIObject(StaticANIObject * obj);
void deleteStaticANIObject(StaticANIObject *obj);
void addStaticANIObject(StaticANIObject *obj, bool addList2);
};

class SceneTag : public CObject {
Expand Down
74 changes: 28 additions & 46 deletions engines/fullpipe/scenes.cpp
Expand Up @@ -36,17 +36,6 @@ namespace Fullpipe {

bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) {
CGameVar *sceneVar;
int v12;
int v13;
Scene *v14;
int v15;
int v16;
int v17;
int v18;
CNode *v19;
CNode *v20;
Scene *v21;
PictureObject *v22;
Common::Point sceneDim;

Scene *scene = accessScene(entrance->_sceneId);
Expand Down Expand Up @@ -100,48 +89,40 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) {
}
}

getGameLoaderInteractionController()->sortInteractions(scene->_sceneId);
_currentScene = scene;
scene->addStaticANIObject(_aniMan, 1);
_scene2 = scene;
_aniMan->_movementObj = 0;
_aniMan->_staticsObj = _aniMan->getStaticsById(ST_MAN_EMPTY);
_aniMan->setOXY(0, 0);

#if 0
v12 = scene->sceneId;
v13 = (int)getGameLoaderInteractionController();
CInteractionController_sortInteractions(v13, v12);
v14 = g_currentScene;
g_currentScene = v4;
Scene_addStaticANIObject(scene, (int)g_aniMan, 1);
g_scene2 = v4;
g_aniMan->movementObj = 0;
g_aniMan->staticsObj = StaticANIObject_getStaticsById(g_aniMan, ST_MAN_EMPTY);
(*(void (__stdcall **)(_DWORD))(g_aniMan->GameObject.CObject.vmt + 24))(0);
if (g_aniMan) {
g_aniMan2 = (int)g_aniMan;
v15 = getSc2MotionControllerBySceneId(LOWORD(entrance->sceneId));
initMovGraph2((void *)v15);
v16 = getSc2MotionControllerBySceneId(LOWORD(entrance->sceneId));
(*(void (__thiscall **)(int, StaticANIObject *))(*(_DWORD *)v16 + offsetof(CMotionControllerVmt, addObject)))(v16, g_aniMan);
v17 = getSc2MotionControllerBySceneId(LOWORD(entrance->sceneId));
(*(void (__thiscall **)(int))(*(_DWORD *)v17 + offsetof(CMotionControllerVmt, setField8)))(v17);
v18 = (int)getGameLoaderInteractionController();
CInteractionController_enableFlag24(v18);
if (_aniMan) {
_aniMan2 = _aniMan;
getSc2MotionControllerBySceneId(entrance->_sceneId)->initMovGraph2();
getSc2MotionControllerBySceneId(entrance->_sceneId)->addObject(_aniMan);
getSc2MotionControllerBySceneId(entrance->_sceneId)->setEnabled();
getGameLoaderInteractionController()->enableFlag24();
input_setInputDisabled(0);
} else {
g_aniMan2 = 0;
_aniMan2 = 0;
}
g_currentScene = v14;
Scene_setPictureObjectsFlag4((int)scene);
if (scene->staticANIObjectList1.m_nCount) {
v19 = scene->staticANIObjectList1.m_pNodeHead;
while (v19) {
v20 = v19;
v19 = v19->pNext;
GameObject_setFlags((GameObject *)v20->data, *((_WORD *)v20->data + 6) & 0xFE7F);
}

scene->setPictureObjectsFlag4();

for (CPtrList::iterator s = scene->_staticANIObjectList1.begin(); s != scene->_staticANIObjectList1.end(); ++s) {
StaticANIObject *o = (StaticANIObject *)s;
o->setFlags(o->field_6 & 0xFE7F);
}
v21 = accessScene(SC_INV);
v22 = Scene_getPictureObjectById(v21, PIC_INV_MENU, 0);
GameObject_setFlags(&v22->GameObject, v22->GameObject.flags & 0xFFFB);

PictureObject *p = accessScene(SC_INV)->getPictureObjectById(PIC_INV_MENU, 0);
p->setFlags(p->_flags & 0xFFFB);

removeMessageHandler(2, -1);
g_updateScreenCallback = 0;
_updateScreenCallback = 0;

switch (entrance->sceneId) {
switch (entrance->_sceneId) {
case SC_INTRO1:
sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_INTRO1");
scene->preloadMovements(sceneVar);
Expand Down Expand Up @@ -630,6 +611,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) {
break;
}
#endif

return true;
}

Expand Down
4 changes: 4 additions & 0 deletions engines/fullpipe/stateloader.cpp
Expand Up @@ -169,6 +169,10 @@ bool CInteractionController::load(MfcArchive &file) {
return _interactions.load(file);
}

void CInteractionController::sortInteractions(int sceneId) {
warning("STUB: CInteractionController::sortInteractions(%d)", sceneId);
}

CInputController::CInputController() {
// TODO
}
Expand Down

0 comments on commit c4499bb

Please sign in to comment.