[Scummvm-cvs-logs] CVS: scummvm/scumm resource.h,1.10,1.11 script_v6.cpp,1.364,1.365 script_v6he.cpp,2.79,2.80 script_v7he.cpp,2.31,2.32 script_v8.cpp,2.261,2.262

Max Horn fingolfin at users.sourceforge.net
Sat Jul 31 18:55:04 CEST 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31800

Modified Files:
	resource.h script_v6.cpp script_v6he.cpp script_v7he.cpp 
	script_v8.cpp 
Log Message:
Add symbolic names for the array types, which makes the code easier to read/understand (note that array types != res types)

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- resource.h	23 Jun 2004 01:36:57 -0000	1.10
+++ resource.h	1 Aug 2004 01:54:36 -0000	1.11
@@ -31,6 +31,14 @@
 	uint32 tag, size;
 } GCC_PACK;
 
+enum ArrayType {
+	kBitArray = 1,
+	kNibbleArray = 2,
+	kByteArray = 3,
+	kStringArray = 4,
+	kIntArray = 5
+};
+
 struct ArrayHeader {
 	int16 dim1;
 	int16 type;

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.364
retrieving revision 1.365
diff -u -d -r1.364 -r1.365
--- script_v6.cpp	1 Aug 2004 01:21:26 -0000	1.364
+++ script_v6.cpp	1 Aug 2004 01:54:36 -0000	1.365
@@ -402,13 +402,23 @@
 	int id;
 	int size;
 	ArrayHeader *ah;
+	
+	assert(0 <= type && type <= 5);
 
+	
 	if (_heversion >= 60) {
-		if (type == rtScript || type == rtRoom)
-			type = rtCostume;
+		// FIXME: Fingolfin asks: What is this change good for? It doesn't hurt,
+		// but it also has no effect whatsoever...
+		if (type == 1 || type == 2)
+			type = 3;
 	} else {
-		if (type != rtSound)
-			type = rtInventory;
+		// The following code basically turn all arrays except string arrays 
+		// into integer arrays. There seems to be no purpose in this, and it
+		// wastes space. However, we can't just change this either, as that
+		// would break savegame compatibility. So do not touch this unless you
+		// are adding code which updated old savegames, too.
+		if (type != 4)
+			type = 5;
 	}
 
 	nukeArray(array);
@@ -423,7 +433,7 @@
 			error("Can't define bit variable as array pointer");
 		}
 
-		size = (type == 5) ? 32 : 8;
+		size = (type == kIntArray) ? 4 : 1;
 	} else {
 		if (array & 0x4000) {
 		}
@@ -432,14 +442,13 @@
 			error("Can't define bit variable as array pointer");
 		}
 
-		size = (type == 5) ? 16 : 8;
+		size = (type == kIntArray) ? 2 : 1;
 	}
 
 	writeVar(array, id);
 
 	size *= dim2 + 1;
 	size *= dim1 + 1;
-	size >>= 3;
 
 	ah = (ArrayHeader *)createResource(rtString, id, size + sizeof(ArrayHeader));
 
@@ -543,10 +552,7 @@
 		a = _fileHandle.readUint16LE();
 		b = _fileHandle.readUint16LE();
 		c = _fileHandle.readUint16LE();
-		if (c == 1)
-			defineArray(num, 1, a, b);
-		else
-			defineArray(num, 5, a, b);
+		defineArray(num, c, a, b);
 	}
 }
 
@@ -2073,7 +2079,7 @@
 	case 205:		// SO_ASSIGN_STRING
 		b = pop();
 		len = resStrLen(_scriptPointer);
-		ah = defineArray(array, 4, 0, len + 1);
+		ah = defineArray(array, kStringArray, 0, len + 1);
 		copyScriptString(ah->data + b);
 		break;
 	case 208:		// SO_ASSIGN_INT_LIST
@@ -2081,7 +2087,7 @@
 		c = pop();
 		d = readVar(array);
 		if (d == 0) {
-			defineArray(array, 5, 0, b + c);
+			defineArray(array, kIntArray, 0, b + c);
 		}
 		while (c--) {
 			writeArray(array, 0, b + c, pop());
@@ -2364,19 +2370,19 @@
 
 	switch (fetchScriptByte()) {
 	case 199:		// SO_INT_ARRAY
-		data = 5;
+		data = kIntArray;
 		break;
 	case 200:		// SO_BIT_ARRAY
-		data = 1;
+		data = kBitArray;
 		break;
 	case 201:		// SO_NIBBLE_ARRAY
-		data = 2;
+		data = kNibbleArray;
 		break;
 	case 202:		// SO_BYTE_ARRAY
-		data = 3;
+		data = kByteArray;
 		break;
 	case 203:		// SO_STRING_ARRAY
-		data = 4;
+		data = kStringArray;
 		break;
 	case 204:		// SO_UNDIM_ARRAY
 		nukeArray(fetchScriptWord());
@@ -2396,19 +2402,19 @@
 	int a, b, data;
 	switch (fetchScriptByte()) {
 	case 199:		// SO_INT_ARRAY
-		data = 5;
+		data = kIntArray;
 		break;
 	case 200:		// SO_BIT_ARRAY
-		data = 1;
+		data = kBitArray;
 		break;
 	case 201:		// SO_NIBBLE_ARRAY
-		data = 2;
+		data = kNibbleArray;
 		break;
 	case 202:		// SO_BYTE_ARRAY
-		data = 3;
+		data = kByteArray;
 		break;
 	case 203:		// SO_STRING_ARRAY
-		data = 4;
+		data = kStringArray;
 		break;
 	default:
 		error("o6_dim2dimArray: default case");
@@ -2957,7 +2963,7 @@
 	if (a != _currentRoom)
 		warning("o6_findAllObjects: current room is not %d", a);
 	writeVar(0, 0);
-	defineArray(0, 5, 0, _numLocalObjects + 1);
+	defineArray(0, kIntArray, 0, _numLocalObjects + 1);
 	writeArray(0, 0, 0, _numLocalObjects);
 	
 	while (i < _numLocalObjects) {
@@ -3001,7 +3007,7 @@
 	int value = fetchScriptWord();
 
 	if (readVar(value) == 0) {
-		defineArray(value, 5, 0, num + 1);
+		defineArray(value, kIntArray, 0, num + 1);
 		if (num > 0) {
 			int16 counter = 0;
 			do {

Index: script_v6he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6he.cpp,v
retrieving revision 2.79
retrieving revision 2.80
diff -u -d -r2.79 -r2.80
--- script_v6he.cpp	25 Jul 2004 11:29:38 -0000	2.79
+++ script_v6he.cpp	1 Aug 2004 01:54:37 -0000	2.80
@@ -838,7 +838,7 @@
 		// Fatty Bear's Birthday Surprise
 		// XXX gdi_virtScreen = 0;
 		writeVar(0, 0);
-		defineArray(0, rtCostume, 0, virtScreenSave(0, args[1], args[2], args[3], args[4]));
+		defineArray(0, kByteArray, 0, virtScreenSave(0, args[1], args[2], args[3], args[4]));
 		retval = readVar(0);
 		ah = (ArrayHeader *)getResourceAddress(rtString, retval);
 		virtScreenSave(ah->data, args[1], args[2], args[3], args[4]);
@@ -1051,7 +1051,7 @@
 
 	writeVar(0, 0);
 
-	ArrayHeader *ah = defineArray(0, rtCostume, 0, size);
+	ArrayHeader *ah = defineArray(0, kByteArray, 0, size);
 	_hFileTable[slot].read(ah->data, size);
 
 	return readVar(0);

Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.31
retrieving revision 2.32
diff -u -d -r2.31 -r2.32
--- script_v7he.cpp	14 Jul 2004 07:29:09 -0000	2.31
+++ script_v7he.cpp	1 Aug 2004 01:54:37 -0000	2.32
@@ -491,7 +491,7 @@
 		push(0);
 		break;
 	case 2: // string
-		defineArray(0, 4, 0, 0);
+		defineArray(0, kStringArray, 0, 0);
 		retval = readVar(0);
 		writeArray(0, 0, 0, 0);
 		push(retval); // var ID string

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.261
retrieving revision 2.262
diff -u -d -r2.261 -r2.262
--- script_v8.cpp	1 Aug 2004 01:19:54 -0000	2.261
+++ script_v8.cpp	1 Aug 2004 01:54:37 -0000	2.262
@@ -545,9 +545,9 @@
 		b = _fileHandle.readUint32LE();
 		
 		if (b != 0)
-			defineArray(num, 5, b, a);
+			defineArray(num, kIntArray, b, a);
 		else
-			defineArray(num, 5, a, b);
+			defineArray(num, kIntArray, a, b);
 	}
 }
 
@@ -615,10 +615,10 @@
 	
 	switch (subOp) {
 	case 0x0A:		// SO_ARRAY_SCUMMVAR
-		defineArray(array, 5, 0, pop());
+		defineArray(array, kIntArray, 0, pop());
 		break;
 	case 0x0B:		// SO_ARRAY_STRING
-		defineArray(array, 4, 0, pop());
+		defineArray(array, kStringArray, 0, pop());
 		break;
 	case 0x0C:		// SO_ARRAY_UNDIM
 		nukeArray(array);
@@ -636,12 +636,12 @@
 	case 0x0A:		// SO_ARRAY_SCUMMVAR
 		b = pop();
 		a = pop();
-		defineArray(array, 5, a, b);
+		defineArray(array, kIntArray, a, b);
 		break;
 	case 0x0B:		// SO_ARRAY_STRING
 		b = pop();
 		a = pop();
-		defineArray(array, 4, a, b);
+		defineArray(array, kStringArray, a, b);
 		break;
 	case 0x0C:		// SO_ARRAY_UNDIM
 		nukeArray(array);
@@ -662,7 +662,7 @@
 	case 0x14:		// SO_ASSIGN_STRING
 		b = pop();
 		len = resStrLen(_scriptPointer);
-		ah = defineArray(array, 4, 0, len + 1);
+		ah = defineArray(array, kStringArray, 0, len + 1);
 		copyScriptString(ah->data + b);
 		break;
 	case 0x15:		// SO_ASSIGN_SCUMMVAR_LIST
@@ -670,7 +670,7 @@
 		len = getStackList(list, ARRAYSIZE(list));
 		d = readVar(array);
 		if (d == 0) {
-			defineArray(array, 5, 0, b + len);
+			defineArray(array, kIntArray, 0, b + len);
 		}
 		while (--len >= 0) {
 			writeArray(array, 0, b + len, list[len]);





More information about the Scummvm-git-logs mailing list