aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Brown2002-09-25 03:04:28 +0000
committerJames Brown2002-09-25 03:04:28 +0000
commite9c1d9d802fdc96769a791c7135e1a6f6451c252 (patch)
tree51103290fbee3cdb9a2f6261e427d2318c662b9d
parent1bfaa3c02f0a3fb56c581fc204b644d457d45ae0 (diff)
downloadscummvm-rg350-e9c1d9d802fdc96769a791c7135e1a6f6451c252.tar.gz
scummvm-rg350-e9c1d9d802fdc96769a791c7135e1a6f6451c252.tar.bz2
scummvm-rg350-e9c1d9d802fdc96769a791c7135e1a6f6451c252.zip
Patch 613933: Return code for validateresource.
svn-id: r5017
-rw-r--r--scumm/resource.cpp26
-rw-r--r--scumm/scumm.h2
2 files changed, 19 insertions, 9 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index e5a8ad1af1..71245cd57c 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -1111,7 +1111,9 @@ byte *Scumm::getResourceAddress(int type, int idx)
{
byte *ptr;
- CHECK_HEAP validateResource("getResourceAddress", type, idx);
+ CHECK_HEAP if (!validateResource("getResourceAddress", type, idx))
+ return NULL;
+
if (!res.address[type]) {
debug(9, "getResourceAddress(%s,%d), res.address[type] == NULL", resTypeFromId(type), idx);
return NULL;
@@ -1174,7 +1176,8 @@ byte *Scumm::createResource(int type, int idx, uint32 size)
CHECK_HEAP debug(9, "createResource(%s,%d,%d)", resTypeFromId(type), idx, size);
- validateResource("allocating", type, idx);
+ if (!validateResource("allocating", type, idx))
+ return NULL;
nukeResource(type, idx);
expireResources(size);
@@ -1192,11 +1195,13 @@ byte *Scumm::createResource(int type, int idx, uint32 size)
return ptr + sizeof(MemBlkHeader); /* skip header */
}
-void Scumm::validateResource(const char *str, int type, int idx)
+bool Scumm::validateResource(const char *str, int type, int idx)
{
if (type < rtFirst || type > rtLast || (uint) idx >= (uint) res.num[type]) {
warning("%s Illegal Glob type %s (%d) num %d", str, resTypeFromId(type), type, idx);
+ return false;
}
+ return true;
}
void Scumm::nukeResource(int type, int idx)
@@ -1370,7 +1375,8 @@ byte *findResourceSmall(uint32 tag, byte *searchin, int idx)
void Scumm::lock(int type, int i)
{
- validateResource("Locking", type, i);
+ if (!validateResource("Locking", type, i))
+ return;
res.flags[type][i] |= RF_LOCK;
// debug(1, "locking %d,%d", type, i);
@@ -1378,7 +1384,8 @@ void Scumm::lock(int type, int i)
void Scumm::unlock(int type, int i)
{
- validateResource("Unlocking", type, i);
+ if (!validateResource("Unlocking", type, i))
+ return;
res.flags[type][i] &= ~RF_LOCK;
// debug(1, "unlocking %d,%d", type, i);
@@ -1386,7 +1393,8 @@ void Scumm::unlock(int type, int i)
bool Scumm::isResourceInUse(int type, int i)
{
- validateResource("isResourceInUse", type, i);
+ if (!validateResource("isResourceInUse", type, i))
+ return false;
switch (type) {
case rtRoom:
return _roomResource == (byte)i;
@@ -1503,7 +1511,8 @@ void Scumm::loadPtrToResource(int type, int resindex, byte *source)
bool Scumm::isResourceLoaded(int type, int idx)
{
- validateResource("isLoaded", type, idx);
+ if (!validateResource("isLoaded", type, idx))
+ return false;
return res.address[type][idx] != NULL;
}
@@ -1674,7 +1683,8 @@ void Scumm::allocateArrays()
bool Scumm::isGlobInMemory(int type, int idx)
{
- validateResource("isGlobInMemory", type, idx);
+ if (!validateResource("isGlobInMemory", type, idx))
+ return false;
return res.address[type][idx] != NULL;
}
diff --git a/scumm/scumm.h b/scumm/scumm.h
index fee7eb45b3..d034ad6789 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -601,7 +601,7 @@ public:
int readSoundResource(int type, int index);
int readSoundResourceSmallHeader(int type, int index);
void setResourceCounter(int type, int index, byte flag);
- void validateResource(const char *str, int type, int index);
+ bool validateResource(const char *str, int type, int index);
void increaseResourceCounter();
bool isResourceInUse(int type, int i);
bool isResourceLoaded(int type, int index);