diff options
author | Paul Gilbert | 2017-08-12 20:09:18 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-08-12 20:09:18 -0400 |
commit | f132cbcf8570eb2a125d6c079997762ffffdab08 (patch) | |
tree | 90180a31c5677bd0361d59ea5badfc1f74e52565 /engines/titanic/support/files_manager.cpp | |
parent | 6a5c52019458e13941abb3f6ab3f4cd1607c3989 (diff) | |
download | scummvm-rg350-f132cbcf8570eb2a125d6c079997762ffffdab08.tar.gz scummvm-rg350-f132cbcf8570eb2a125d6c079997762ffffdab08.tar.bz2 scummvm-rg350-f132cbcf8570eb2a125d6c079997762ffffdab08.zip |
TITANIC: Add support for compressed bitmaps in titanic.dat
Diffstat (limited to 'engines/titanic/support/files_manager.cpp')
-rw-r--r-- | engines/titanic/support/files_manager.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/engines/titanic/support/files_manager.cpp b/engines/titanic/support/files_manager.cpp index 5fc9379917..eebd56c1fa 100644 --- a/engines/titanic/support/files_manager.cpp +++ b/engines/titanic/support/files_manager.cpp @@ -22,6 +22,7 @@ #include "common/file.h" #include "common/memstream.h" +#include "common/zlib.h" #include "titanic/support/files_manager.h" #include "titanic/game_manager.h" #include "titanic/titanic.h" @@ -29,7 +30,7 @@ namespace Titanic { CFilesManager::CFilesManager(TitanicEngine *vm) : _vm(vm), _gameManager(nullptr), - _assetsPath("Assets"), _drive(-1) { + _assetsPath("Assets"), _drive(-1), _version(0) { } CFilesManager::~CFilesManager() { @@ -43,19 +44,21 @@ bool CFilesManager::loadResourceIndex() { } uint headerId = _datFile.readUint32BE(); - uint version = _datFile.readUint16LE(); - if (headerId != MKTAG('S', 'V', 'T', 'N') || version < 1) { + _version = _datFile.readUint16LE(); + if (headerId != MKTAG('S', 'V', 'T', 'N') || _version < 1) { g_vm->GUIError("titanic.dat has invalid contents"); return false; } // Read in entries - uint offset, size; + uint offset, size, flags; char c; Common::String resourceName; for (;;) { offset = _datFile.readUint32LE(); size = _datFile.readUint32LE(); + flags = (_version == 1) ? 0 : _datFile.readUint16LE(); + if (offset == 0 && size == 0) break; @@ -63,7 +66,7 @@ bool CFilesManager::loadResourceIndex() { while ((c = _datFile.readByte()) != '\0') resName += c; - _resources[resName] = ResourceEntry(offset, size); + _resources[resName] = ResourceEntry(offset, size, flags); } return true; @@ -136,8 +139,13 @@ Common::SeekableReadStream *CFilesManager::getResource(const CString &str) { _datFile.seek(resEntry._offset); - return (resEntry._size > 0) ? _datFile.readStream(resEntry._size) : + Common::SeekableReadStream *stream = (resEntry._size > 0) ? + _datFile.readStream(resEntry._size) : new Common::MemoryReadStream(nullptr, 0); + if (resEntry._flags & FLAG_COMPRESSED) + stream = Common::wrapCompressedReadStream(stream); + + return stream; } } // End of namespace Titanic |