diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/configure.engine | 2 | ||||
-rw-r--r-- | engines/titanic/support/files_manager.cpp | 20 | ||||
-rw-r--r-- | engines/titanic/support/files_manager.h | 9 |
3 files changed, 22 insertions, 9 deletions
diff --git a/engines/titanic/configure.engine b/engines/titanic/configure.engine index 1697a779c0..23a3b4e599 100644 --- a/engines/titanic/configure.engine +++ b/engines/titanic/configure.engine @@ -1,3 +1,3 @@ # This file is included from the main "configure" script # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] -add_engine titanic "Starship Titanic" no "" "" "16bit jpeg highres mad" +add_engine titanic "Starship Titanic" no "" "" "16bit jpeg highres mad zlib" 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 diff --git a/engines/titanic/support/files_manager.h b/engines/titanic/support/files_manager.h index 7627ececdd..c1e3c3b274 100644 --- a/engines/titanic/support/files_manager.h +++ b/engines/titanic/support/files_manager.h @@ -29,6 +29,8 @@ namespace Titanic { +enum ResourceFlag { FLAG_COMPRESSED = 1 }; + class TitanicEngine; class CGameManager; @@ -39,9 +41,11 @@ class CFilesManager { struct ResourceEntry { uint _offset; uint _size; + uint _flags; - ResourceEntry() : _offset(0), _size(0) {} - ResourceEntry(uint offset, uint size) : _offset(offset), _size(size) {} + ResourceEntry() : _offset(0), _size(0), _flags(0) {} + ResourceEntry(uint offset, uint size, uint flags) : + _offset(offset), _size(size), _flags(flags) {} }; typedef Common::HashMap<Common::String, ResourceEntry> ResourceHash; private: @@ -52,6 +56,7 @@ private: CFilesManagerList _list; int _drive; const CString _assetsPath; + int _version; public: CFilesManager(TitanicEngine *vm); ~CFilesManager(); |