aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNeil Millstone2007-07-02 23:02:54 +0000
committerNeil Millstone2007-07-02 23:02:54 +0000
commit0601dbd31b4932d84deb93f7683661a59706b546 (patch)
treed745b9c897c5ffaaa8b27d181e1266e6b8a29cad /engines
parente2495f1d214308ccc879cef9063f9da54deee8cf (diff)
downloadscummvm-rg350-0601dbd31b4932d84deb93f7683661a59706b546.tar.gz
scummvm-rg350-0601dbd31b4932d84deb93f7683661a59706b546.tar.bz2
scummvm-rg350-0601dbd31b4932d84deb93f7683661a59706b546.zip
Optimisation for resource loading in Kyra engine
svn-id: r27875
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/resource.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp
index 7c15cee2f9..3ff8dd984c 100644
--- a/engines/kyra/resource.cpp
+++ b/engines/kyra/resource.cpp
@@ -195,15 +195,22 @@ uint8 *Resource::fileData(const char *file, uint32 *size) const {
if (!(*cur)->isOpen())
continue;
- uint32 fileSize = (*cur)->getFileSize(fileHash);
- if (!fileSize)
- continue;
+ uint8* result = (*cur)->getFile(fileHash);
+
+ if (result) {
+ uint32 fileSize = (*cur)->getFileSize(fileHash);
+
+ if (!fileSize)
+ continue;
+
+ if (size)
+ *size = fileSize;
+
+ return result;
+ }
- if (size)
- *size = fileSize;
- return (*cur)->getFile(fileHash);
}
}
@@ -221,13 +228,15 @@ bool Resource::getFileHandle(const char *file, uint32 *size, Common::File &fileh
if (!(*start)->isOpen())
continue;
- *size = (*start)->getFileSize(fileHash);
+ if ((*start)->getFileHandle(fileHash, filehandle)) {
+
+ *size = (*start)->getFileSize(fileHash);
- if (!(*size))
- continue;
+ if (!(*size))
+ continue;
- if ((*start)->getFileHandle(fileHash, filehandle))
return true;
+ }
}
return false;