[Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.11,1.12 scumm.h,1.29,1.30

James Brown ender at users.sourceforge.net
Tue Sep 24 20:05:01 CEST 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv5876/scumm

Modified Files:
	resource.cpp scumm.h 
Log Message:
Patch 613933: Return code for validateresource.



Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- resource.cpp	22 Sep 2002 04:20:20 -0000	1.11
+++ resource.cpp	25 Sep 2002 03:04:28 -0000	1.12
@@ -1111,7 +1111,9 @@
 {
 	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 @@
 
 	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 @@
 	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 @@
 
 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::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 @@
 
 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 @@
 
 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 @@
 
 bool Scumm::isGlobInMemory(int type, int idx)
 {
-	validateResource("isGlobInMemory", type, idx);
+	if (!validateResource("isGlobInMemory", type, idx))
+		return false;
 
 	return res.address[type][idx] != NULL;
 }

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- scumm.h	24 Sep 2002 23:45:25 -0000	1.29
+++ scumm.h	25 Sep 2002 03:04:28 -0000	1.30
@@ -601,7 +601,7 @@
 	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);





More information about the Scummvm-git-logs mailing list