diff options
author | Paul Gilbert | 2013-12-08 18:23:40 -0500 |
---|---|---|
committer | Paul Gilbert | 2013-12-08 18:23:40 -0500 |
commit | 96b1fb8601ebdda0a6bd8220d55baf3386d1551a (patch) | |
tree | c3656014d5e9053dc5b083f70601bcc4510d00ad | |
parent | bad9219c27d8b62079fe0f96c8cc7020d2c58da7 (diff) | |
download | scummvm-rg350-96b1fb8601ebdda0a6bd8220d55baf3386d1551a.tar.gz scummvm-rg350-96b1fb8601ebdda0a6bd8220d55baf3386d1551a.tar.bz2 scummvm-rg350-96b1fb8601ebdda0a6bd8220d55baf3386d1551a.zip |
VOYEUR: Fixes for ControlResource initialisation
-rw-r--r-- | engines/voyeur/files.cpp | 13 | ||||
-rw-r--r-- | engines/voyeur/files.h | 1 | ||||
-rw-r--r-- | engines/voyeur/voyeur.h | 2 | ||||
-rw-r--r-- | engines/voyeur/voyeur_game.cpp | 19 |
4 files changed, 27 insertions, 8 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp index 8f188fa3c8..f9fce61f8d 100644 --- a/engines/voyeur/files.cpp +++ b/engines/voyeur/files.cpp @@ -236,7 +236,9 @@ BoltFile::BoltFile(const Common::String &filename, BoltFilesState &state): _stat } BoltFile::~BoltFile() { - _state._curFd->close(); + _file.close(); + if (_state._curFd == &_file) + _state._curFd = NULL; } bool BoltFile::getBoltGroup(uint32 id) { @@ -1306,6 +1308,7 @@ VInitCyclResource::VInitCyclResource(BoltFilesState &state, const byte *src) { /*------------------------------------------------------------------------*/ ThreadResource::ThreadResource(BoltFilesState &state, const byte *src) { + _flags = READ_LE_UINT16(&src[8]); } /*------------------------------------------------------------------------*/ @@ -1330,10 +1333,8 @@ ControlResource::ControlResource(BoltFilesState &state, const byte *src) { uint32 ptrId = READ_LE_UINT32(&src[0x32]); _ptr = state._curLibPtr->getBoltEntryFromLong(ptrId)._data; - for (int i = 0; i < 8; ++i) { + for (int i = 0; i < 8; ++i) _memberIds[i] = READ_LE_UINT16(src + i * 2); - _entries[i] = NULL; - } // Load pointer list uint32 *idP = (uint32 *)&src[0x10]; @@ -1341,9 +1342,7 @@ ControlResource::ControlResource(BoltFilesState &state, const byte *src) { for (int i = 0; i < count; ++i, ++idP) { uint32 id = READ_LE_UINT32(idP); - BoltEntry &entry = state._curLibPtr->getBoltEntryFromLong(id); - - _entries[i] = entry._data; + state._curLibPtr->resolveIt(id, &_entries[i]); } } diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h index 8cb7fc8b22..7ea7dead91 100644 --- a/engines/voyeur/files.h +++ b/engines/voyeur/files.h @@ -417,6 +417,7 @@ public: int _field0; int _controlIndex; int _field4, _field6; + int _flags; int _field3A; int _field3E; byte *_ctlPtr; diff --git a/engines/voyeur/voyeur.h b/engines/voyeur/voyeur.h index 236d83ff6d..549a335416 100644 --- a/engines/voyeur/voyeur.h +++ b/engines/voyeur/voyeur.h @@ -83,10 +83,12 @@ private: void playStamp(); void initStamp(); + void closeStamp(); void initUseCount(); void initThreadStruct(ThreadResource *thread, int v1, int idx); bool stm_loadAStack(ThreadResource *thread, int idx); void stm_unloadAStack(int idx); + void stm_unloadAllStacks(); void stm_doState(ThreadResource *thread); protected: // Engine APIs diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp index f6dc0b0d43..ee7ef66c6d 100644 --- a/engines/voyeur/voyeur_game.cpp +++ b/engines/voyeur/voyeur_game.cpp @@ -59,6 +59,9 @@ void VoyeurEngine::playStamp() { } _voy._field4386 = 0; + closeStamp(); + _stampLibPtr->freeBoltGroup(0x10000); + delete _stampLibPtr; } void VoyeurEngine::initStamp() { @@ -71,6 +74,10 @@ void VoyeurEngine::initStamp() { initUseCount(); } +void VoyeurEngine::closeStamp() { + stm_unloadAllStacks(); +} + void VoyeurEngine::initUseCount() { Common::fill(&_stm_useCount[0], &_stm_useCount[8], 0); } @@ -102,6 +109,7 @@ bool VoyeurEngine::stm_loadAStack(ThreadResource *thread, int idx) { } thread->_ctlPtr = _controlPtr->_entries[idx]; + return true; } void VoyeurEngine::stm_unloadAStack(int idx) { @@ -112,8 +120,17 @@ void VoyeurEngine::stm_unloadAStack(int idx) { } } -void VoyeurEngine::stm_doState(ThreadResource *thread) { +void VoyeurEngine::stm_unloadAllStacks() { + if (_stampFlags & 1) { + for (int i = 0; i < 8; ++i) { + if (_stm_useCount[i]) + _stampLibPtr->freeBoltMember(_controlPtr->_memberIds[i]); + } + } +} +void VoyeurEngine::stm_doState(ThreadResource *thread) { + warning("TODO: stm_doState"); } } // End of namespace Voyeur |