[Scummvm-cvs-logs] CVS: scummvm/scumm object.cpp,1.113,1.114 script_v2.cpp,2.129,2.130 script_v5.cpp,1.106,1.107 scumm.h,1.231,1.232 string.cpp,1.126,1.127

Max Horn fingolfin at users.sourceforge.net
Sat May 31 05:30:04 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv29132

Modified Files:
	object.cpp script_v2.cpp script_v5.cpp scumm.h string.cpp 
Log Message:
some setObjectName changes. I'd really like to switch V2-V5 to use rtObjectName resources, too

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- object.cpp	31 May 2003 11:57:17 -0000	1.113
+++ object.cpp	31 May 2003 12:17:57 -0000	1.114
@@ -881,7 +881,7 @@
 	_drawObjectQueNr = 0;
 }
 
-byte *Scumm::getObjOrActorName(int obj) {
+const byte *Scumm::getObjOrActorName(int obj) {
 	byte *objptr;
 	int i;
 
@@ -915,50 +915,7 @@
 		return (objptr + offset);
 	}
 
-#if 0
 	return findResourceData(MKID('OBNA'), objptr);
-#else
-	// FIXME: we can't use findResourceData anymore, because it returns const
-	// data, while this function *must* return a non-const pointer. That is so
-	// because in o2_setObjectName / o5_setObjectName we directly modify this
-	// data. Now, we could add a non-const version of findResourceData, too
-	// (C++ makes that easy); but this here is really the *only* place in all
-	// of ScummVM where it wold be needed! That seems kind of a waste...
-	//
-	// So for now, I duplicate some code from findResourceData / findResource
-	// here. However, a much nicer solution might be (with stress on "might")
-	// to use the same technique as in V6 games: that is, use a seperate
-	// resource for changed names. That would be the cleanest solution, but
-	// might proof to be infeasible, as it might lead to unforseen regressions.
-	
-	uint32 tag = MKID('OBNA');
-	byte *searchin = objptr;
-	uint32 curpos, totalsize, size;
-
-	assert(searchin);
-
-	searchin += 4;
-	totalsize = READ_BE_UINT32_UNALIGNED(searchin);
-	curpos = 8;
-	searchin += 4;
-
-	while (curpos < totalsize) {
-		if (READ_UINT32_UNALIGNED(searchin) == tag)
-			return searchin + _resourceHeaderSize;
-
-		size = READ_BE_UINT32_UNALIGNED(searchin + 4);
-		if ((int32)size <= 0) {
-			error("(%c%c%c%c) Not found in %d... illegal block len %d",
-						tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size);
-			return NULL;
-		}
-
-		curpos += size;
-		searchin += size;
-	}
-
-	return NULL;
-#endif
 }
 
 uint32 Scumm::getOBCDOffs(int object) {

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.129
retrieving revision 2.130
diff -u -d -r2.129 -r2.130
--- script_v2.cpp	30 May 2003 14:06:28 -0000	2.129
+++ script_v2.cpp	31 May 2003 12:17:57 -0000	2.130
@@ -1316,9 +1316,18 @@
 	if (obj < _numActors)
 		error("Can't set actor %d name with new-name-of", obj);
 
-	name = getObjOrActorName(obj);
-	if (name == NULL)
-		return;	// Silently abort
+	// TODO: Would be nice if we used rtObjectName resource for pre-V6
+	// games, too. The only problem with that which I can see is that this
+	// would break savegames. I.e. it would require yet another change to
+	// the save/load system.
+
+	// FIXME: This is rather nasty code.
+	// Find the object name in the OBCD resource.
+	byte *objptr;
+	objptr = getOBCDFromObject(obj);
+	if (objptr == NULL)
+		return;	// Silently fail for now
+	name = objptr + *(objptr + 14);
 
 	while(name[size++])
 		;

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- script_v5.cpp	30 May 2003 22:22:51 -0000	1.106
+++ script_v5.cpp	31 May 2003 12:17:57 -0000	1.107
@@ -1879,33 +1879,81 @@
 	if (obj < _numActors)
 		error("Can't set actor %d name with new-name-of", obj);
 
-	if (!getOBCDFromObject(obj)) {
+	// TODO: Would be nice if we used rtObjectName resource for pre-V6
+	// games, too. The only problem with that which I can see is that this
+	// would break savegames. I.e. it would require yet another change to
+	// the save/load system.
+
+	byte *objptr;
+	objptr = getOBCDFromObject(obj);
+	if (objptr == NULL) {
 		// FIXME: Bug 587553. This is an odd one and looks more like
 		// an actual bug in the original script. Usually we would error
 		warning("Can't find OBCD to rename object %d to %s", obj, work);
 		return;
 	}
 
-	name = getObjOrActorName(obj);
-	if (name == NULL)
-		return;	// Silently abort
-
 	if (_features & GF_SMALL_HEADER) {
-		// FIXME this is hack to make MonkeyVGA work. needed at least for the german
-		// version but possibly for others as well. There is no apparent other
-		// way to determine the available space that works in all cases...
-		byte *objptr;
 		byte offset = 0;
 
-		objptr = getOBCDFromObject(obj);
 		if (_features & GF_OLD_BUNDLE)
 			offset = *(objptr + 16);
 		else
 			offset = READ_LE_UINT16(objptr + 18);
+
 		size = READ_LE_UINT16(objptr) - offset;
+		name = objptr + offset;
 	} else {
+		name = 0;
+#if 0
+		name = findResourceData(MKID('OBNA'), objptr);
+#else
+		// FIXME: we can't use findResourceData anymore, because it returns const
+		// data, while this function *must* return a non-const pointer. That is so
+		// because in o2_setObjectName / o5_setObjectName we directly modify this
+		// data. Now, we could add a non-const version of findResourceData, too
+		// (C++ makes that easy); but this here is really the *only* place in all
+		// of ScummVM where it wold be needed! That seems kind of a waste...
+		//
+		// So for now, I duplicate some code from findResourceData / findResource
+		// here. However, a much nicer solution might be (with stress on "might")
+		// to use the same technique as in V6 games: that is, use a seperate
+		// resource for changed names. That would be the cleanest solution, but
+		// might proof to be infeasible, as it might lead to unforseen regressions.
+		
+		uint32 tag = MKID('OBNA');
+		byte *searchin = objptr;
+		uint32 curpos, totalsize;
+	
+		assert(searchin);
+	
+		searchin += 4;
+		totalsize = READ_BE_UINT32_UNALIGNED(searchin);
+		curpos = 8;
+		searchin += 4;
+	
+		while (curpos < totalsize) {
+			if (READ_UINT32_UNALIGNED(searchin) == tag) {
+				name = searchin + _resourceHeaderSize;
+				break;
+			}
+	
+			size = READ_BE_UINT32_UNALIGNED(searchin + 4);
+			if ((int32)size <= 0) {
+				error("(%c%c%c%c) Not found in %d... illegal block len %d",
+							tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size);
+			}
+	
+			curpos += size;
+			searchin += size;
+		}
+#endif
 		size = getResourceDataSize(name);
 	}
+	
+	if (name == 0)
+		return;		// Silently bail out
+	
 
 	if (i >= size) {
 		warning("New name of object %d too long (old *%s* new *%s*)", obj, name, work);

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.231
retrieving revision 1.232
diff -u -d -r1.231 -r1.232
--- scumm.h	31 May 2003 11:57:17 -0000	1.231
+++ scumm.h	31 May 2003 12:17:57 -0000	1.232
@@ -683,7 +683,7 @@
 	int getObjectOrActorXY(int object, int &x, int &y);	// Used in actor.cpp, hence public
 protected:
 	int getObjActToObjActDist(int a, int b); // Not sure how to handle
-	byte *getObjOrActorName(int obj);		 // these three..
+	const byte *getObjOrActorName(int obj);		 // these three..
 
 	void addObjectToDrawQue(int object);
 	void clearDrawObjectQueue();

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- string.cpp	30 May 2003 23:32:02 -0000	1.126
+++ string.cpp	31 May 2003 12:17:58 -0000	1.127
@@ -675,7 +675,7 @@
 void Scumm::addNameToStack(int var)
 {
 	int num;
-	byte *ptr = 0;
+	const byte *ptr = 0;
 
 	num = readVar(var);
 	if (num)





More information about the Scummvm-git-logs mailing list