diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/resource.cpp | 24 | ||||
-rw-r--r-- | engines/kyra/resource.h | 1 |
2 files changed, 22 insertions, 3 deletions
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 112011cf5a..049c51727e 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -355,17 +355,23 @@ void Resource::detectFileTypes() { continue; if (i->_value.type == ResFileEntry::kAutoDetect) { + Common::SeekableReadStream *stream = 0; for (LoaderIterator l = _loaders.begin(); l != _loaders.end(); ++l) { - Common::SeekableReadStream *stream = getFileStream(i->_key); + if (!(*l)->checkFilename(i->_key)) + continue; + + if (!stream) + stream = getFileStream(i->_key); + if ((*l)->isLoadable(i->_key, *stream)) { i->_value.type = (*l)->getType(); i->_value.loadable = false; i->_value.preload = false; break; } - delete stream; - stream = 0; } + delete stream; + stream = 0; if (i->_value.type == ResFileEntry::kAutoDetect) { i->_value.type = ResFileEntry::kRaw; @@ -381,6 +387,7 @@ void Resource::detectFileTypes() { class ResLoaderPak : public ResArchiveLoader { public: + bool checkFilename(Common::String filename) const; bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const; bool loadFile(const Common::String &filename, Common::SeekableReadStream &stream, ResFileMap &map) const; Common::SeekableReadStream *loadFileFromArchive(const Common::String &file, Common::SeekableReadStream *archive, const ResFileMap &map) const; @@ -390,6 +397,11 @@ public: } }; +bool ResLoaderPak::checkFilename(Common::String filename) const { + filename.toUppercase(); + return (filename.hasSuffix(".PAK") || filename.hasSuffix(".APK") || filename.hasSuffix(".VRM") || filename.hasSuffix(".TLK") || filename.equalsIgnoreCase(StaticResource::staticDataFilename())); +} + bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const { uint32 filesize = stream.size(); uint32 offset = 0; @@ -530,6 +542,7 @@ Common::SeekableReadStream *ResLoaderPak::loadFileFromArchive(const Common::Stri class ResLoaderIns : public ResArchiveLoader { public: + bool checkFilename(Common::String filename) const; bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const; bool loadFile(const Common::String &filename, Common::SeekableReadStream &stream, ResFileMap &map) const; Common::SeekableReadStream *loadFileFromArchive(const Common::String &file, Common::SeekableReadStream *archive, const ResFileMap &map) const; @@ -539,6 +552,11 @@ public: } }; +bool ResLoaderIns::checkFilename(Common::String filename) const { + filename.toUppercase(); + return (filename.hasSuffix(".001")); +} + bool ResLoaderIns::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const { stream.seek(3); uint32 size = stream.readUint32LE(); diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index 344e40fe68..b5cb2143b3 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -64,6 +64,7 @@ class ResArchiveLoader { public: virtual ~ResArchiveLoader() {} + virtual bool checkFilename(Common::String filename) const = 0; virtual bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const = 0; virtual bool loadFile(const Common::String &filename, Common::SeekableReadStream &stream, ResFileMap &map) const = 0; // parameter 'archive' can be deleted by this method and it may not be deleted from the caller |