[Scummvm-cvs-logs] CVS: scummvm actor.h,1.16,1.17 actor.cpp,1.111,1.112

Max Horn fingolfin at users.sourceforge.net
Sun Aug 18 06:56:03 CEST 2002


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

Modified Files:
	actor.h actor.cpp 
Log Message:
Fix for #580762 (MI2: Guybrush facing wrong direction); some code cleanup

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- actor.h	4 Aug 2002 02:53:50 -0000	1.16
+++ actor.h	18 Aug 2002 13:55:30 -0000	1.17
@@ -124,7 +124,7 @@
 protected:
 	int calcMovementFactor(int newx, int newy);
 	int actorWalkStep();
-	int remapDirection(int dir);
+	int remapDirection(int dir, bool is_walking);
 	void setupActorScale();
 public:
 	void stopActorMoving();
@@ -133,7 +133,7 @@
 
 protected:
 	void setBox(int box);
-	int updateActorDirection();
+	int updateActorDirection(bool is_walking);
 
 public:
 	void setDirection(int direction);

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.cpp,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- actor.cpp	15 Aug 2002 22:54:32 -0000	1.111
+++ actor.cpp	18 Aug 2002 13:55:30 -0000	1.112
@@ -176,7 +176,7 @@
 	return actorWalkStep();
 }
 
-int Actor::remapDirection(int dir)
+int Actor::remapDirection(int dir, bool is_walking)
 {
 	int specdir;
 	byte flags;
@@ -214,12 +214,12 @@
 
 		switch (flags & 7) {
 		case 1:
-			if (moving & ~MF_TURN)		// Actor is walking
+			if (is_walking)	                                // Actor is walking
 				return flipX ? 90 : 270;
 			else											// Actor is standing/turning
 				return (dir == 90) ? 90 : 270;
 		case 2:
-			if (moving & ~MF_TURN)		// Actor is walking
+			if (is_walking)                                 // Actor is walking
 				return flipY ? 180 : 0;
 			else											// Actor is standing/turning
 				return (dir == 0) ? 0 : 180;
@@ -237,7 +237,7 @@
 	return normalizeAngle(dir) | 1024;
 }
 
-int Actor::updateActorDirection()
+int Actor::updateActorDirection(bool is_walking)
 {
 	int from, to;
 	int diff;
@@ -249,27 +249,25 @@
 	dirType = _vm->akos_hasManyDirections(this);
 
 	from = toSimpleDir(dirType, facing);
-	dir = remapDirection(newDirection);
+	dir = remapDirection(newDirection, is_walking);
 	shouldInterpolate = (dir & 1024);
 	to = toSimpleDir(dirType, dir & 1023);
-	diff = to - from;
 	num = numSimpleDirDirections(dirType);
 
 	if (shouldInterpolate) {
 		// Turn left or right, depending on which is shorter.
+		diff = to - from;
 		if (abs(diff) > (num >> 1))
 			diff = -diff;
 
-		if (diff == 0) {
-		} else if (diff > 0) {
-			from++;
-		} else {
-			from--;
+		if (diff > 0) {
+			to = from + 1;
+		} else if (diff < 0){
+			to = from - 1;
 		}
-	} else
-		from = to;
+	}
 
-	dir = fromSimpleDir(dirType, from % num);
+	dir = fromSimpleDir(dirType, (to + num) % num);
 
 	return dir;
 }
@@ -292,7 +290,7 @@
 	needRedraw = true;
 	needBgReset = true;
 
-	direction = updateActorDirection();
+	direction = updateActorDirection(true);
 	if (!(moving & MF_IN_LEG) || facing != direction) {
 		if (walkFrame != frame || facing != direction) {
 			startWalkAnim(walkFrame == frame ? 2 : 1, direction);
@@ -1168,7 +1166,7 @@
 		}
 
 		if (moving & MF_TURN) {
-			j = updateActorDirection();
+			j = updateActorDirection(false);
 			if (facing != j)
 				setDirection(j);
 			else
@@ -1279,7 +1277,7 @@
 	}
 
 	if (moving & MF_TURN) {
-		new_dir = updateActorDirection();
+		new_dir = updateActorDirection(false);
 		if (facing != new_dir) {
 			setDirection(new_dir);
 			return;





More information about the Scummvm-git-logs mailing list