diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/gameloader.cpp | 83 | ||||
-rw-r--r-- | engines/fullpipe/gameloader.h | 8 | ||||
-rw-r--r-- | engines/fullpipe/messages.cpp | 4 | ||||
-rw-r--r-- | engines/fullpipe/messages.h | 1 | ||||
-rw-r--r-- | engines/fullpipe/motion.h | 1 | ||||
-rw-r--r-- | engines/fullpipe/stateloader.cpp | 6 |
6 files changed, 97 insertions, 6 deletions
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp index 142c278c56..fef7f56d46 100644 --- a/engines/fullpipe/gameloader.cpp +++ b/engines/fullpipe/gameloader.cpp @@ -27,6 +27,7 @@ #include "fullpipe/input.h" #include "fullpipe/statics.h" #include "fullpipe/interaction.h" +#include "fullpipe/motion.h" namespace Fullpipe { @@ -227,12 +228,88 @@ bool CGameLoader::gotoScene(int sceneId, int entranceId) { return true; } +bool preloadCallback(const PreloadItem &pre, int flag) { + warning("STUB: preloadCallback"); + + return true; +} + bool CGameLoader::preloadScene(int sceneId, int entranceId) { - warning("STUB: preloadScene(%d, %d), ", sceneId, entranceId); + debug(0, "preloadScene(%d, %d), ", sceneId, entranceId); + + if (_preloadSceneId != sceneId || _preloadEntranceId != entranceId) { + _preloadSceneId = sceneId; + _preloadEntranceId = entranceId; + return true; + } + + int idx = -1; + + for (uint i = 0; i < _preloadItems.size(); i++) + if (_preloadItems[i].preloadId1 == sceneId && _preloadItems[i].preloadId2 == entranceId) { + idx = i; + break; + } + + if (idx == -1) { + _preloadSceneId = 0; + _preloadEntranceId = 0; + return false; + } + + if (_preloadCallback) { + if (!_preloadCallback(_preloadItems[idx], 0)) + return false; + } + + if (g_fullpipe->_currentScene && g_fullpipe->_currentScene->_sceneId == sceneId) + g_fullpipe->_currentScene = 0; + + saveScenePicAniInfos(sceneId); + clearGlobalMessageQueueList1(); + unloadScene(sceneId); + + if (_preloadCallback) + _preloadCallback(_preloadItems[idx], 50); + + loadScene(_preloadItems[idx].sceneId); + + ExCommand *ex = new ExCommand(_preloadItems[idx].sceneId, 17, 62, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags = 2; + ex->_keyCode = _preloadItems[idx].keyCode; + + _preloadSceneId = 0; + _preloadEntranceId = 0; + + if (_preloadCallback) + _preloadCallback(_preloadItems[idx], 100); + + ex->postMessage(); return true; } +bool CGameLoader::unloadScene(int sceneId) { + SceneTag *tag; + int sceneTag = getSceneTagBySceneId(sceneId, &tag); + + if (sceneTag < 0) + return false; + + if (_sc2array[sceneTag]._isLoaded) + saveScenePicAniInfos(sceneId); + + _sc2array[sceneTag]._motionController->freeItems(); + + delete tag->_scene; + tag->_scene = 0; + + _sc2array[sceneTag]._isLoaded = 0; + _sc2array[sceneTag]._scene = 0; + + return true; +} + int CGameLoader::getSceneTagBySceneId(int sceneId, SceneTag **st) { if (_sc2array.size() > 0 && _gameProject->_sceneTagList->size() > 0) { for (uint i = 0; i < _sc2array.size(); i++) { @@ -304,6 +381,10 @@ void CGameLoader::applyPicAniInfos(Scene *sc, PicAniInfo **picAniInfo, int picAn } } +void CGameLoader::saveScenePicAniInfos(int sceneId) { + warning("STUB: CGameLoader::saveScenePicAniInfos(%d)", sceneId); +} + void CGameLoader::updateSystems(int counterdiff) { if (g_fullpipe->_currentScene) { g_fullpipe->_currentScene->update(counterdiff); diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h index 73873fb839..6db9c98fb9 100644 --- a/engines/fullpipe/gameloader.h +++ b/engines/fullpipe/gameloader.h @@ -38,9 +38,11 @@ struct PreloadItem { int preloadId1; int preloadId2; int sceneId; - int field_C; + int keyCode; }; +bool preloadCallback(const PreloadItem &pre, int flag); + class PreloadItems : public Common::Array<PreloadItem>, public CObject { public: virtual bool load(MfcArchive &file); @@ -55,11 +57,13 @@ class CGameLoader : public CObject { bool loadScene(int sceneId); bool gotoScene(int sceneId, int entranceId); bool preloadScene(int sceneId, int entranceId); + bool unloadScene(int sceneId); void updateSystems(int counterdiff); int getSceneTagBySceneId(int sceneId, SceneTag **st); void applyPicAniInfos(Scene *sc, PicAniInfo **picAniInfo, int picAniInfoCount); + void saveScenePicAniInfos(int sceneId); GameProject *_gameProject; CInteractionController *_interactionController; @@ -67,7 +71,7 @@ class CGameLoader : public CObject { CInventory2 _inventory; Sc2Array _sc2array; void *_sceneSwitcher; - void *_preloadCallback; + bool (*_preloadCallback)(const PreloadItem &pre, int flag); void *_readSavegameCallback; int16 _field_F8; int16 _field_FA; diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index 478112f75c..36fd1399ce 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -530,6 +530,10 @@ void GlobalMessageQueueList::addMessageQueue(MessageQueue *msg) { push_back(msg); } +void clearGlobalMessageQueueList1() { + warning("STUB: clearGlobalMessageQueueList1()"); +} + 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 960e184a88..7ba9126d46 100644 --- a/engines/fullpipe/messages.h +++ b/engines/fullpipe/messages.h @@ -168,6 +168,7 @@ bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id); void clearMessageHandlers(); void processMessages(); void updateGlobalMessageQueue(int id, int objid); +void clearGlobalMessageQueueList1(); } // End of namespace Fullpipe diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index 89a98967fb..85a52918f0 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -42,6 +42,7 @@ class CMotionController : public CObject { void clearEnabled() { _isEnabled = false; } virtual void addObject(StaticANIObject *obj) {} + virtual void freeItems() {} }; class CMctlCompoundArray : public Common::Array<CObject>, public CObject { diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 40169ddf9f..366872c277 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -59,8 +59,8 @@ bool FullpipeEngine::loadGam(const char *fname, int scene) { } // _sceneSwitcher = sceneSwitcher; // substituted with direct call - // _preloadCallback = gameLoaderPreloadCallback - // _readSavegameCallback = gameLoaderReadSavegameCallback; + _gameLoader->_preloadCallback = preloadCallback; + // _readSavegameCallback = gameLoaderReadSavegameCallback; // TODO _aniMan = accessScene(SC_COMMON)->getAniMan(); _scene2 = 0; @@ -155,7 +155,7 @@ bool PreloadItems::load(MfcArchive &file) { t->preloadId1 = file.readUint32LE(); t->preloadId2 = file.readUint32LE(); t->sceneId = file.readUint32LE(); - t->field_C = file.readUint32LE(); + t->keyCode = file.readUint32LE(); push_back(*t); } |