aboutsummaryrefslogtreecommitdiff
path: root/engines/groovie
diff options
context:
space:
mode:
authorScott Thomas2011-04-15 21:45:32 +0930
committerScott Thomas2011-04-15 21:46:08 +0930
commitf33810a8c0617641d16953fd026b8598bd090a50 (patch)
tree1479bf25fa844356fc86aa9e876169dbcda88632 /engines/groovie
parent8e9dbe5c3dfde9e180cd1008cb888618f77c64fa (diff)
downloadscummvm-rg350-f33810a8c0617641d16953fd026b8598bd090a50.tar.gz
scummvm-rg350-f33810a8c0617641d16953fd026b8598bd090a50.tar.bz2
scummvm-rg350-f33810a8c0617641d16953fd026b8598bd090a50.zip
GROOVIE: Implement resource search-by-name for v2 games
Diffstat (limited to 'engines/groovie')
-rw-r--r--engines/groovie/resource.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/engines/groovie/resource.cpp b/engines/groovie/resource.cpp
index 179d746ec2..9c4e6fb2fa 100644
--- a/engines/groovie/resource.cpp
+++ b/engines/groovie/resource.cpp
@@ -218,7 +218,41 @@ ResMan_v2::ResMan_v2() {
}
uint32 ResMan_v2::getRef(Common::String name, Common::String scriptname) {
- return 0;
+ // Open the RL file
+ Common::File rlFile;
+ if (!rlFile.open("dir.rl")) {
+ error("Groovie::Resource: Couldn't open dir.rl");
+ return false;
+ }
+
+ uint32 resNum;
+ bool found = false;
+ for (resNum = 0; !found && !rlFile.err() && !rlFile.eos(); resNum++) {
+ // Seek past metadata
+ rlFile.seek(14, SEEK_CUR);
+
+ // Read the resource name
+ char readname[18];
+ rlFile.read(readname, 18);
+
+ // Test whether it's the resource we're searching
+ Common::String resname(readname, 18);
+ if (resname.hasPrefix(name.c_str())) {
+ debugC(2, kGroovieDebugResource | kGroovieDebugAll, "Groovie::Resource: Resource %12s matches %s", readname, name.c_str());
+ found = true;
+ }
+ }
+
+ // Close the RL file
+ rlFile.close();
+
+ // Verify we really found the resource
+ if (!found) {
+ error("Groovie::Resource: Couldn't find resource %s", name.c_str());
+ return (uint32)-1;
+ }
+
+ return resNum;
}
bool ResMan_v2::getResInfo(uint32 fileRef, ResInfo &resInfo) {