From 663d08b192027a534f077168b72e79fe63a799fd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 15 Dec 2013 17:51:47 -0500 Subject: VOYEUR: Fix for when multiple bolt files are open --- engines/voyeur/files.cpp | 10 ++++++---- engines/voyeur/files.h | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp index a9473d4b70..28f4763877 100644 --- a/engines/voyeur/files.cpp +++ b/engines/voyeur/files.cpp @@ -163,9 +163,10 @@ byte *BoltFilesState::decompress(byte *buf, int size, int mode) { #undef NEXT_BYTE void BoltFilesState::nextBlock() { - if (_curFilePosition != _bufferEnd) - _curFd->seek(_bufferEnd); + if (&_curLibPtr->_file != _curFd || _curFilePosition != _bufferEnd) + _curLibPtr->_file.seek(_bufferEnd); + _curFd = &_curLibPtr->_file; _bufferBegin = _bufferEnd; int bytesRead = _curFd->read(_bufStart, _bufSize); @@ -219,7 +220,6 @@ byte *FilesManager::fload(const Common::String &filename, int *size) { /*------------------------------------------------------------------------*/ BoltFile::BoltFile(const Common::String &filename, BoltFilesState &state): _state(state) { - _state._curFd = &_file; if (!_file.open(filename)) error("Could not open %s", filename.c_str()); _state._curFilePosition = 0; @@ -233,13 +233,15 @@ BoltFile::BoltFile(const Common::String &filename, BoltFilesState &state): _stat int totalGroups = header[11] ? header[11] : 0x100; for (int i = 0; i < totalGroups; ++i) - _groups.push_back(BoltGroup(_state._curFd)); + _groups.push_back(BoltGroup(&_file)); } BoltFile::~BoltFile() { _file.close(); if (_state._curFd == &_file) _state._curFd = NULL; + if (_state._curLibPtr == this) + _state._curLibPtr = NULL; } BoltGroup *BoltFile::getBoltGroup(uint16 id, bool process) { diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h index 28c77bb5f1..e82d6a83bc 100644 --- a/engines/voyeur/files.h +++ b/engines/voyeur/files.h @@ -100,7 +100,6 @@ public: class BoltFile { private: Common::Array _groups; - Common::File _file; protected: BoltFilesState &_state; @@ -115,6 +114,8 @@ private: void termMem() {} // TODO void initGro() {} // TODO void termGro() {} // TODO +public: + Common::File _file; public: BoltFile(const Common::String &filename, BoltFilesState &state); virtual ~BoltFile(); -- cgit v1.2.3