[Scummvm-cvs-logs] SF.net SVN: scummvm: [30835] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Feb 9 16:18:35 CET 2008


Revision: 30835
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30835&view=rev
Author:   lordhoto
Date:     2008-02-09 07:18:35 -0800 (Sat, 09 Feb 2008)

Log Message:
-----------
Added filename check before header check when trying to detect archives types, this should lower the file i/o need a lot when starting up kyra2.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/resource.cpp
    scummvm/trunk/engines/kyra/resource.h

Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp	2008-02-09 15:08:49 UTC (rev 30834)
+++ scummvm/trunk/engines/kyra/resource.cpp	2008-02-09 15:18:35 UTC (rev 30835)
@@ -355,17 +355,23 @@
 			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 @@
 
 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 @@
 	}
 };
 
+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 @@
 
 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 @@
 	}
 };
 
+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();

Modified: scummvm/trunk/engines/kyra/resource.h
===================================================================
--- scummvm/trunk/engines/kyra/resource.h	2008-02-09 15:08:49 UTC (rev 30834)
+++ scummvm/trunk/engines/kyra/resource.h	2008-02-09 15:18:35 UTC (rev 30835)
@@ -64,6 +64,7 @@
 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


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list