[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.143,1.144 actor.h,1.33,1.34 akos.cpp,1.83,1.84 costume.cpp,1.88,1.89 debugger.cpp,1.68,1.69 object.cpp,1.133,1.134 resource.cpp,1.113,1.114 script_v2.cpp,2.160,2.161 script_v5.cpp,1.136,1.137 script_v6.cpp,1.175,1.176 script_v8.cpp,2.187,2.188

Max Horn fingolfin at users.sourceforge.net
Thu Jul 24 10:45:02 CEST 2003


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

Modified Files:
	actor.cpp actor.h akos.cpp costume.cpp debugger.cpp object.cpp 
	resource.cpp script_v2.cpp script_v5.cpp script_v6.cpp 
	script_v8.cpp 
Log Message:
cleanup: encapsulate some more members of class Actor, and rename newDirection -> targetFacing (since it corresponds to the future value of 'facing'; the distinction between 'facing' and 'direction' is extremly fuzzy)

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- actor.cpp	22 Jul 2003 20:53:01 -0000	1.143
+++ actor.cpp	24 Jul 2003 17:44:00 -0000	1.144
@@ -51,11 +51,7 @@
 		x = 0;
 		y = 0;
 		facing = 180;
-		newDirection = 180;
-		talkFrequency = 256;
 	} else if (mode == 2) {
-		facing = 180;
-		newDirection = 180;
 	}
 
 	elevation = 0;
@@ -66,7 +62,7 @@
 	scaley = scalex = 0xFF;
 	charset = 0;
 	memset(sound, 0, sizeof(sound));
-	newDirection = 0;
+	targetFacing = facing;
 
 	stopActorMoving();
 
@@ -181,7 +177,7 @@
 	walkdata.xfrac = 0;
 	walkdata.yfrac = 0;
 
-	newDirection = _vm->getAngleFromPos(deltaXFactor, deltaYFactor);
+	targetFacing = _vm->getAngleFromPos(deltaXFactor, deltaYFactor);
 
 	return actorWalkStep();
 }
@@ -284,7 +280,7 @@
 	dirType = (_vm->_features & GF_NEW_COSTUMES) ? _vm->akos_hasManyDirections(this) : false;
 
 	from = toSimpleDir(dirType, facing);
-	dir = remapDirection(newDirection, is_walking);
+	dir = remapDirection(targetFacing, is_walking);
 
 	if (_vm->_features & GF_NEW_COSTUMES)
 		// Direction interpolation interfers with walk scripts in Dig; they perform
@@ -324,14 +320,14 @@
 	int tmpX, tmpY;
 	int actorX, actorY;
 	int distX, distY;
-	int direction;
+	int nextFacing;
 
 	needRedraw = true;
 
-	direction = updateActorDirection(true);
-	if (!(moving & MF_IN_LEG) || facing != direction) {
-		if (walkFrame != frame || facing != direction) {
-			startWalkAnim(1, direction);
+	nextFacing = updateActorDirection(true);
+	if (!(moving & MF_IN_LEG) || facing != nextFacing) {
+		if (walkFrame != frame || facing != nextFacing) {
+			startWalkAnim(1, nextFacing);
 		}
 		moving |= MF_IN_LEG;
 	}
@@ -536,14 +532,18 @@
 	int i;
 	uint16 vald;
 
+	// Do nothing if actor is already facing in the given direction
 	if (facing == direction)
 		return;
 
+	// Normalize the angle
 	facing = normalizeAngle(direction);
 
+	// If there is no costume set for this actor, we are finished
 	if (costume == 0)
 		return;
 
+	// Update the costume for the new direction (and mark the actor for redraw)
 	aMask = 0x8000;
 	for (i = 0; i < 16; i++, aMask >>= 1) {
 		vald = cost.frame[i];
@@ -736,7 +736,7 @@
 			moving = MF_TURN;
 		else
 			moving |= MF_TURN;
-		newDirection = newdir;
+		targetFacing = newdir;
 	}
 }
 
@@ -1575,7 +1575,7 @@
 		MKLINE(Actor, charset, sleByte, VER_V8),
 		MKARRAY(Actor, sound[0], sleByte, 8, VER_V8),
 		MKARRAY(Actor, animVariable[0], sleUint16, 8, VER_V8),
-		MKLINE(Actor, newDirection, sleUint16, VER_V8),
+		MKLINE(Actor, targetFacing, sleUint16, VER_V8),
 		MKLINE(Actor, moving, sleByte, VER_V8),
 		MKLINE(Actor, ignoreBoxes, sleByte, VER_V8),
 		MKLINE(Actor, forceClip, sleByte, VER_V8),

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- actor.h	2 Jul 2003 13:47:02 -0000	1.33
+++ actor.h	24 Jul 2003 17:44:00 -0000	1.34
@@ -86,14 +86,12 @@
 	int elevation;
 	uint width;
 	byte number;
-	uint16 facing;
 	uint16 costume;
 	byte room;
 	byte talkColor;
 	int talkFrequency;
 	byte scalex, scaley;
 	byte charset;
-	int16 newDirection;
 	byte moving;
 	bool ignoreBoxes;
 	byte forceClip;
@@ -101,10 +99,8 @@
 	bool needRedraw, needBgReset, visible;
 	byte shadow_mode;
 	bool flip;
-	uint speedx, speedy;
 	byte frame;
 	byte walkbox;
-	byte animProgress, animSpeed;
 	int16 talkPosX, talkPosY;
 	uint16 talkScript, walkScript;
 	bool ignoreTurns;	// TODO - we do not honor this flag at all currently!
@@ -113,6 +109,10 @@
 	CostumeData cost;
 	byte palette[256];
 protected:
+	uint16 facing;
+	uint16 targetFacing;
+	uint speedx, speedy;
+	byte animProgress, animSpeed;
 	bool costumeNeedsInit;
 	ActorWalkData walkdata;
 	int16 animVariable[16];
@@ -188,17 +188,26 @@
 		return room == _vm->_currentRoom;
 	}
 	
-	int getActorXYPos(int &x, int &y) const ;
+	int getActorXYPos(int &x, int &y) const;
 
 	int getRoom() const {
 		return room;
 	}
+	
+	int getFacing() const {
+		return facing;
+	}
 
 	int getAnimVar(byte var) const {
 		return animVariable[var];
 	}
 	void setAnimVar(byte var, int value) {
 		animVariable[var] = value;
+	}
+	
+	void setAnimSpeed(byte newAnimSpeed) {
+		animSpeed = newAnimSpeed;
+		animProgress = 0;
 	}
 	
 	void classChanged(int cls, bool value);

Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- akos.cpp	26 Jun 2003 22:50:01 -0000	1.83
+++ akos.cpp	24 Jul 2003 17:44:00 -0000	1.84
@@ -125,9 +125,9 @@
 
 int Scumm::akos_frameToAnim(Actor *a, int frame) {
 	if (akos_hasManyDirections(a))
-		return toSimpleDir(1, a->facing) + frame * 8;
+		return toSimpleDir(1, a->getFacing()) + frame * 8;
 	else
-		return newDirToOldDir(a->facing) + frame * 4;
+		return newDirToOldDir(a->getFacing()) + frame * 4;
 }
 
 void Scumm::akos_decodeData(Actor *a, int frame, uint usemask) {
@@ -243,7 +243,7 @@
 }
 
 void AkosRenderer::setFacing(Actor *a) {
-	_mirror = (newDirToOldDir(a->facing) != 0 || akhd->flags & 1);
+	_mirror = (newDirToOldDir(a->getFacing()) != 0 || akhd->flags & 1);
 	if (a->flip)
 		_mirror = !_mirror;
 }

Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- costume.cpp	19 Jul 2003 20:10:40 -0000	1.88
+++ costume.cpp	24 Jul 2003 17:44:00 -0000	1.89
@@ -641,7 +641,7 @@
 }
 
 int Scumm::cost_frameToAnim(Actor *a, int frame) {
-	return newDirToOldDir(a->facing) + frame * 4;
+	return newDirToOldDir(a->getFacing()) + frame * 4;
 }
 
 void Scumm::cost_decodeData(Actor *a, int frame, uint usemask) {
@@ -746,7 +746,7 @@
 }
 
 void CostumeRenderer::setFacing(Actor *a) {
-	_mirror = newDirToOldDir(a->facing) != 0 || _loaded._mirror;
+	_mirror = newDirToOldDir(a->getFacing()) != 0 || _loaded._mirror;
 }
 
 void CostumeRenderer::setCostume(int costume) {

Index: debugger.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/debugger.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- debugger.cpp	21 Jul 2003 22:25:49 -0000	1.68
+++ debugger.cpp	24 Jul 2003 17:44:00 -0000	1.69
@@ -596,18 +596,18 @@
 	int i;
 	Actor *a;
 
-	Debug_Printf("+--------------------------------------------------------------------+\n");
-	Debug_Printf("|# |room|  x |  y |elev|cos|width|box|mov| zp|frame|scale|spd|dir|cls|\n");
-	Debug_Printf("+--+----+----+----+----+---+-----+---+---+---+-----+-----+---+---+---+\n");
+	Debug_Printf("+----------------------------------------------------------------+\n");
+	Debug_Printf("|# |room|  x |  y |elev|cos|width|box|mov| zp|frame|scale|dir|cls|\n");
+	Debug_Printf("+--+----+----+----+----+---+-----+---+---+---+-----+-----+---+---+\n");
 	for (i = 1; i < _s->_numActors; i++) {
 		a = &_s->_actors[i];
 		if (a->visible)
-			Debug_Printf("|%2d|%4d|%4d|%4d|%4d|%3d|%5d|%3d|%3d|%3d|%5d|%5d|%3d|%3d|$%02x|\n",
+			Debug_Printf("|%2d|%4d|%4d|%4d|%4d|%3d|%5d|%3d|%3d|%3d|%5d|%5d|%3d|$%02x|\n",
 						 a->number, a->room, a->x, a->y, a->elevation, a->costume,
 						 a->width, a->walkbox, a->moving, a->forceClip, a->frame,
-						 a->scalex, a->speedx, a->facing, int(_s->_classData[a->number]&0xFF));
+						 a->scalex, a->getFacing(), int(_s->_classData[a->number]&0xFF));
 	}
-	Debug_Printf("+--------------------------------------------------------------------+\n");
+	Debug_Printf("+----------------------------------------------------------------+\n");
 	return true;
 }
 

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -d -r1.133 -r1.134
--- object.cpp	30 Jun 2003 22:22:04 -0000	1.133
+++ object.cpp	24 Jul 2003 17:44:00 -0000	1.134
@@ -1241,7 +1241,7 @@
 int Scumm::getObjNewDir(int obj) {
 	int dir;
 	if (obj < _numActors) {
-		dir = derefActor(obj, "getObjNewDir")->facing;
+		dir = derefActor(obj, "getObjNewDir")->getFacing();
 	} else {
 		int x, y;
 		getObjectXYPos(obj, x, y, dir);

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- resource.cpp	22 Jul 2003 16:34:52 -0000	1.113
+++ resource.cpp	24 Jul 2003 17:44:00 -0000	1.114
@@ -705,7 +705,6 @@
 				(char)((basetag >> 16) & 0xff),
 				(char)((basetag >> 8) & 0xff), (char)(basetag & 0xff), total_size);
 
-	//if (_gameId == GID_SAMNMAX || _features & GF_AFTER_V7) {
 	if (basetag == MKID('MIDI') || basetag == MKID('iMUS')) {
 		_fileHandle.seek(-8, SEEK_CUR);
 		_fileHandle.read(createResource(type, idx, total_size + 8), total_size + 8);

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.160
retrieving revision 2.161
diff -u -d -r2.160 -r2.161
--- script_v2.cpp	23 Jul 2003 14:36:18 -0000	2.160
+++ script_v2.cpp	24 Jul 2003 17:44:00 -0000	2.161
@@ -1340,12 +1340,8 @@
 
 void Scumm_v2::o2_chainScript() {
 	int data = getVarOrDirectByte(0x80);
-	int cur = _currentScript;
-
-	vm.slot[cur].number = 0;
-	vm.slot[cur].status = 0;
+	stopScript(vm.slot[_currentScript].number);
 	_currentScript = 0xFF;
-
 	runScript(data, 0, 0, 0);
 }
 

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -d -r1.136 -r1.137
--- script_v5.cpp	23 Jul 2003 05:17:21 -0000	1.136
+++ script_v5.cpp	24 Jul 2003 17:44:00 -0000	1.137
@@ -524,8 +524,7 @@
 			break;
 
 		case 22:										/* animspeed */
-			a->animSpeed = getVarOrDirectByte(0x80);
-			a->animProgress = 0;
+			a->setAnimSpeed(getVarOrDirectByte(0x80));
 			break;
 		case 23:										/* shadow mode */
 			a->shadow_mode = getVarOrDirectByte(0x80);
@@ -942,7 +941,7 @@
 	getResultPos();
 	int act = getVarOrDirectByte(0x80);
 	Actor *a = derefActor(act, "o5_getActorFacing");
-	setResult(newDirToOldDir(a->facing));
+	setResult(newDirToOldDir(a->getFacing()));
 }
 
 void Scumm_v5::o5_getActorMoving() {

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- script_v6.cpp	22 Jul 2003 16:05:40 -0000	1.175
+++ script_v6.cpp	24 Jul 2003 17:44:00 -0000	1.176
@@ -1717,8 +1717,7 @@
 			a->putActor(a->x, a->y, a->room);
 		break;
 	case 97:
-		a->animSpeed = pop();
-		a->animProgress = 0;
+		a->setAnimSpeed(pop());
 		break;
 	case 98:
 		a->shadow_mode = pop();

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.187
retrieving revision 2.188
diff -u -d -r2.187 -r2.188
--- script_v8.cpp	16 Jul 2003 20:50:26 -0000	2.187
+++ script_v8.cpp	24 Jul 2003 17:44:00 -0000	2.188
@@ -959,8 +959,7 @@
 		a->standFrame = pop();
 		break;
 	case 0x6C:		// SO_ACTOR_ANIMATION_SPEED Set speed of animation
-		a->animSpeed = pop();
-		a->animProgress = 0;
+		a->setAnimSpeed(pop());
 		break;
 	case 0x6D:		// SO_ACTOR_DEFAULT
 		// FIXME - is this right? Or maybe a->initActor(2) ?





More information about the Scummvm-git-logs mailing list