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
This commit is contained in:
Filippos Karapetis 2010-07-02 10:18:11 +00:00
parent 7b6be52f22
commit 79768098b1
2 changed files with 24 additions and 10 deletions

View file

@ -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 (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();
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());
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;
}