FULLPIPE: Implement CGameLoader::preloadScene()

This commit is contained in:
Eugene Sandulenko 2013-09-12 22:47:45 +03:00
parent 7e08d4f6b2
commit 6cd830fb1b
6 changed files with 98 additions and 7 deletions

View File

@ -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 CGameLoader::preloadScene(int sceneId, int entranceId) {
warning("STUB: preloadScene(%d, %d), ", sceneId, entranceId);
bool preloadCallback(const PreloadItem &pre, int flag) {
warning("STUB: preloadCallback");
return true;
}
bool CGameLoader::preloadScene(int sceneId, int 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);

View File

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

View File

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

View File

@ -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

View File

@ -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 {

View File

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