[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.150,1.151 script_v5.cpp,1.147,1.148 scummvm.cpp,2.323,2.324

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Tue Aug 12 12:40:05 CEST 2003


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

Modified Files:
	actor.cpp script_v5.cpp scummvm.cpp 
Log Message:
Allowed derefActor() and derefActorSafe() to treat actor 0 as a valid actor
since the original interpreters appear to have allowed it. This fixes bug
#786380 ("FOA - FISTS, script crash in Crete").

I do not know what the purpose of actor 0 was in the original. Either it's
a no-op, or it's used to store actor default values.

Note that in the FOA case the room-33-200 script will loop - at least with
the provided savegame - until you leave the room. However, this is quite
harmless.


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- actor.cpp	8 Aug 2003 11:32:40 -0000	1.150
+++ actor.cpp	12 Aug 2003 16:43:43 -0000	1.151
@@ -839,7 +839,9 @@
 }
 
 Actor *Scumm::derefActor(int id, const char *errmsg) const {
-	if (id < 1 || id >= _numActors || _actors[id].number != id) {
+	if (id == 0)
+		debug(3, "derefActor(0, \"%s\") in script %d, opcode 0x%x", errmsg, vm.slot[_curExecScript].number, _opcode);
+	if (id < 0 || id >= _numActors || _actors[id].number != id) {
 		if (errmsg)
 			error("Invalid actor %d in %s", id, errmsg);
 		else
@@ -849,7 +851,9 @@
 }
 
 Actor *Scumm::derefActorSafe(int id, const char *errmsg) const {
-	if (id < 1 || id >= _numActors || _actors[id].number != id) {
+	if (id == 0)
+		debug(3, "derefActorSafe(0, \"%s\") in script %d, opcode 0x%x", errmsg, vm.slot[_curExecScript].number, _opcode);
+	if (id < 0 || id >= _numActors || _actors[id].number != id) {
 		debug(2, "Invalid actor %d in %s (script %d, opcode 0x%x) - This is potentially a BIG problem.",
 			 id, errmsg, vm.slot[_curExecScript].number, _opcode);
 		return NULL;

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- script_v5.cpp	10 Aug 2003 20:50:50 -0000	1.147
+++ script_v5.cpp	12 Aug 2003 16:43:43 -0000	1.148
@@ -398,26 +398,9 @@
 	static const byte convertTable[20] =
 		{ 1, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20 };
 	int act = getVarOrDirectByte(0x80);
-	Actor *a;
+	Actor *a = derefActor(act, "o5_actorSet");
 	int i, j;
 
-	if (act == 0) {
-		// This case happens in Zak256 (and maybe elsewhere), to set the
-		// default talk color (9).
-		while ((_opcode = fetchScriptByte()) != 0xFF) {
-			if (_features & GF_SMALL_HEADER)
-				_opcode = (_opcode & 0xE0) | convertTable[(_opcode & 0x1F) - 1];
-				
-			if (_opcode== 12)
-				_string[0].color = getVarOrDirectByte(0x80);
-			else
-				error("o5_actorSet: Invalid sub opcode %d in actor 0 case", _opcode);
-		}
-		return;
-	}
-
-	a = derefActor(act, "o5_actorSet");
-
 	while ((_opcode = fetchScriptByte()) != 0xFF) {
 		if (_features & GF_SMALL_HEADER)
 			_opcode = (_opcode & 0xE0) | convertTable[(_opcode & 0x1F) - 1];
@@ -474,7 +457,15 @@
 			a->needRedraw = true;
 			break;
 		case 12:										/* talk color */
-			a->talkColor = getVarOrDirectByte(0x80);
+
+			// Zak256 (and possibly other games) uses actor 0 to
+			// indicate that it's the default talk color that is
+			// to be changed.
+
+			if (act == 0)
+				_string[0].color = getVarOrDirectByte(0x80);
+			else
+				a->talkColor = getVarOrDirectByte(0x80);
 			break;
 		case 13:										/* name */
 			loadPtrToResource(rtActorName, a->number, NULL);

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.323
retrieving revision 2.324
diff -u -d -r2.323 -r2.324
--- scummvm.cpp	12 Aug 2003 16:09:40 -0000	2.323
+++ scummvm.cpp	12 Aug 2003 16:43:43 -0000	2.324
@@ -923,7 +923,7 @@
 	// Allocate and Initialize actors
 	Actor::initActorClass(this);
 	_actors = new Actor[_numActors];
-	for (i = 1; i < _numActors; i++) {
+	for (i = 0; i < _numActors; i++) {
 		_actors[i].number = i;
 		_actors[i].initActor(1);
 	





More information about the Scummvm-git-logs mailing list