aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2010-07-02 10:18:11 +0000
committerFilippos Karapetis2010-07-02 10:18:11 +0000
commit79768098b13e20bade076b8a36c9d8cd16514b2a (patch)
tree03f37ecfc7a9d54a58b32dc895ea58795bbcd617 /engines
parent7b6be52f227aeaf2b544b3b35dd872f3643b1ff4 (diff)
downloadscummvm-rg350-79768098b13e20bade076b8a36c9d8cd16514b2a.tar.gz
scummvm-rg350-79768098b13e20bade076b8a36c9d8cd16514b2a.tar.bz2
scummvm-rg350-79768098b13e20bade076b8a36c9d8cd16514b2a.zip
Added handling for kLock called with resource id -1 (unlock all resources of the requested type). Happens e.g. in KQ6 and LSL6
svn-id: r50595
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kscripts.cpp34
-rw-r--r--engines/sci/resource.h2
2 files changed, 25 insertions, 11 deletions
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index 4f4df7d875..4a50553b34 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -86,16 +86,30 @@ reg_t kLock(EngineState *s, int argc, reg_t *argv) {
g_sci->getResMan()->findResource(id, 1);
break;
case 0 :
- which = g_sci->getResMan()->findResource(id, 0);
-
- if (which)
- g_sci->getResMan()->unlockResource(which);
- else {
- if (id.getType() == kResourceTypeInvalid)
- warning("[resMan] Attempt to unlock resource %i of invalid type %i", id.getNumber(), type);
- else
- // Happens in CD games (e.g. LSL6CD) with the message resource
- warning("[resMan] Attempt to unlock non-existant resource %s", id.toString().c_str());
+ if (id.getNumber() == 0xFFFF) {
+ // Unlock all resources of the requested type
+ Common::List<ResourceId> *resources = g_sci->getResMan()->listResources(type);
+ Common::List<ResourceId>::iterator itr = resources->begin();
+
+ while (itr != resources->end()) {
+ Resource *res = g_sci->getResMan()->testResource(*itr);
+ if (res->isLocked())
+ g_sci->getResMan()->unlockResource(res);
+ ++itr;
+ }
+
+ } else {
+ which = g_sci->getResMan()->findResource(id, 0);
+
+ if (which)
+ g_sci->getResMan()->unlockResource(which);
+ else {
+ if (id.getType() == kResourceTypeInvalid)
+ warning("[resMan] Attempt to unlock resource %i of invalid type %i", id.getNumber(), type);
+ else
+ // Happens in CD games (e.g. LSL6CD) with the message resource
+ warning("[resMan] Attempt to unlock non-existant resource %s", id.toString().c_str());
+ }
}
break;
}
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index a13781b157..f66b5b3956 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -210,7 +210,7 @@ public:
inline ResourceType getType() const { return _id.getType(); }
inline uint16 getNumber() const { return _id.getNumber(); }
-
+ bool isLocked() const { return _status == kResStatusLocked; }
/**
* Write the resource to the specified stream.
* This method is used only by the "dump" debugger command.