[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.169,1.170 actor.h,1.37,1.38 boxes.cpp,1.60,1.61 script_v6.cpp,1.186,1.187 script_v8.cpp,2.193,2.194

Max Horn fingolfin at users.sourceforge.net
Thu Sep 11 15:23:37 CEST 2003


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

Modified Files:
	actor.cpp actor.h boxes.cpp script_v6.cpp script_v8.cpp 
Log Message:
cleanup

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -d -r1.169 -r1.170
--- actor.cpp	11 Sep 2003 13:40:22 -0000	1.169
+++ actor.cpp	11 Sep 2003 22:00:33 -0000	1.170
@@ -86,7 +86,8 @@
 	memset(sound, 0, sizeof(sound));
 	targetFacing = facing;
 
-	stopActorMoving();
+	_vm->stopScript(walkScript);
+	moving = 0;
 
 	shadow_mode = 0;
 	layer = 0;
@@ -122,8 +123,10 @@
 }
 
 void Actor::stopActorMoving() {
-	_vm->stopScript(walkScript);
+	if (walkScript)
+		_vm->stopScript(walkScript);
 	moving = 0;
+	startAnimActor(standFrame);
 }
 
 void Actor::setActorWalkSpeed(uint newSpeedX, uint newSpeedY) {
@@ -505,7 +508,6 @@
 	switch (cmd) {
 	case 2:				// stop walking
 		stopActorMoving();
-		startAnimActor(standFrame);
 		break;
 	case 3:				// change direction immediatly
 		moving &= ~MF_TURN;
@@ -696,7 +698,7 @@
 	cost.soundCounter = 0;
 
 	if (_vm->_features & GF_NEW_COSTUMES) {
-		stopActorMoving();
+		_vm->stopScript(walkScript);
 	}
 
 	if (walkbox != kInvalidBox) {
@@ -1320,7 +1322,7 @@
 }
 
 void Actor::walkActor() {
-	int new_dir, box;
+	int new_dir, next_box;
 	int16 foundPathX, foundPathY;
 
 	if (_vm->_version >= 7) {
@@ -1377,16 +1379,16 @@
 		if (walkbox == walkdata.destbox)
 			break;
 
-		box = _vm->getPathToDestBox(walkbox, walkdata.destbox);
-		if (box < 0) {
+		next_box = _vm->getPathToDestBox(walkbox, walkdata.destbox);
+		if (next_box < 0) {
 			walkdata.destbox = walkbox;
 			moving |= MF_LAST_LEG;
 			return;
 		}
 
-		walkdata.curbox = box;
+		walkdata.curbox = next_box;
 		
-		if (findPathTowards(walkbox, box, walkdata.destbox, foundPathX, foundPathY))
+		if (findPathTowards(walkbox, next_box, walkdata.destbox, foundPathX, foundPathY))
 			break;
 
 		if (calcMovementFactor(foundPathX, foundPathY))
@@ -1400,7 +1402,7 @@
 }
 
 void Actor::walkActorOld() {
-	ScummVM::Point gateLoc[5];	// Gate locations
+	ScummVM::Point p2, p3;	// Gate locations
 	int new_dir, next_box;
 
 	if (!moving)
@@ -1433,7 +1435,7 @@
 			walkdata.point3x = 32000;
 		}
 	
-		walkbox = walkdata.curbox;
+		setBox(walkdata.curbox);
 		moving &= MF_IN_LEG;
 	}
 
@@ -1441,7 +1443,7 @@
 		moving &= ~MF_NEW_LEG;
 
 		if (walkbox == kInvalidBox) {
-			walkbox = walkdata.destbox;
+			setBox(walkdata.destbox);
 			walkdata.curbox = walkdata.destbox;
 			break;
 		}
@@ -1461,23 +1463,30 @@
 			break;
 		}
 
-
 		walkdata.curbox = next_box;
-
-		findPathTowardsOld(walkbox, next_box, walkdata.destbox, gateLoc);
-		if (gateLoc[2].x == 32000 && gateLoc[3].x == 32000) {
+		
+/*
+		if (_vm->_version <= 2) {
+			_vm->getClosestPtOnBox(walkdata.curbox, x, y, p2.x, p2.y);
+			_vm->getClosestPtOnBox(walkbox, p2.x, p2.y, p3.x, p3.y);
+		} else {
+*/
+		findPathTowardsOld(walkbox, next_box, walkdata.destbox, p2, p3);
+		if (p2.x == 32000 && p3.x == 32000) {
 			break;
 		}
 
-		if (gateLoc[2].x != 32000) {
-			if (calcMovementFactor(gateLoc[2].x, gateLoc[2].y)) {
-				walkdata.point3x = gateLoc[3].x; 
-				walkdata.point3y = gateLoc[3].y;
+		if (p2.x != 32000) {
+			if (calcMovementFactor(p2.x, p2.y)) {
+				walkdata.point3x = p3.x; 
+				walkdata.point3y = p3.y;
 				return;
 			}
 		}
-
-		if (calcMovementFactor(gateLoc[3].x, gateLoc[3].y))
+/*
+		}
+*/
+		if (calcMovementFactor(p3.x, p3.y))
 			return;
 
 		walkbox = walkdata.destbox;

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- actor.h	9 Sep 2003 19:30:25 -0000	1.37
+++ actor.h	11 Sep 2003 22:00:34 -0000	1.38
@@ -204,7 +204,7 @@
 	bool isPlayer();
 
 	bool findPathTowards(byte box, byte box2, byte box3, int16 &foundPathX, int16 &foundPathY);
-	void findPathTowardsOld(byte box, byte box2, byte box3, ScummVM::Point gateLoc[5]);
+	void findPathTowardsOld(byte box, byte box2, byte box3, ScummVM::Point &p2, ScummVM::Point &p3);
 };
 
 #endif

Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/boxes.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- boxes.cpp	11 Sep 2003 10:32:14 -0000	1.60
+++ boxes.cpp	11 Sep 2003 22:00:34 -0000	1.61
@@ -264,7 +264,7 @@
 	 * 
 	 * Some typical graphs look like these:
 	 *       ---         ---     ---
-	 *       /         ---           \ 
+	 *      /         ---           \ 
 	 *  ___/       ---               \___
 	 * 
 	 * The method used here is to compute the slope of secants fixed at the
@@ -1142,47 +1142,47 @@
 	return result;
 }
 
-void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, ScummVM::Point gateLoc[5]) {
+void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, ScummVM::Point &p2, ScummVM::Point &p3) {
 	ScummVM::Point pt;
 	ScummVM::Point gateA[2];
 	ScummVM::Point gateB[2];
 
 	_vm->getGates(trap1, trap2, gateA, gateB);
 
-	gateLoc[1].x = x;
-	gateLoc[1].y = y;
-	gateLoc[2].x = 32000;
-	gateLoc[3].x = 32000;
-	gateLoc[4].x = 32000;
-
-	if (trap2 == final_trap) {		/* next = final box? */
-		gateLoc[4].x = walkdata.destx;
-		gateLoc[4].y = walkdata.desty;
+	p2.x = 32000;
+	p3.x = 32000;
 
-		if (_vm->getMaskFromBox(trap1) == _vm->getMaskFromBox(trap2) || 1) {
-			if (compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateA[0].x, gateA[0].y) !=
-					compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateB[0].x, gateB[0].y) &&
-					compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateA[1].x, gateA[1].y) !=
-					compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateB[1].x, gateB[1].y)) {
-				return;								/* same zplane and between both gates? */
-			}
+	// next box (trap2) = final box?
+	if (trap2 == final_trap) {
+		// Is the actor (x,y) between both gates?
+		if (compareSlope(x, y, walkdata.destx, walkdata.desty, gateA[0].x, gateA[0].y) !=
+				compareSlope(x, y, walkdata.destx, walkdata.desty, gateB[0].x, gateB[0].y) &&
+				compareSlope(x, y, walkdata.destx, walkdata.desty, gateA[1].x, gateA[1].y) !=
+				compareSlope(x, y, walkdata.destx, walkdata.desty, gateB[1].x, gateB[1].y)) {
+			return;
 		}
 	}
 
-	pt = closestPtOnLine(gateA[1].x, gateA[1].y, gateB[1].x, gateB[1].y, gateLoc[1].x, gateLoc[1].y);
-	gateLoc[3].x = pt.x;
-	gateLoc[3].y = pt.y;
+	pt = closestPtOnLine(gateA[1].x, gateA[1].y, gateB[1].x, gateB[1].y, x, y);
+	p3.x = pt.x;
+	p3.y = pt.y;
 
-	if (compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[3].x, gateLoc[3].y, gateA[0].x, gateA[0].y) ==
-			compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[3].x, gateLoc[3].y, gateB[0].x, gateB[0].y)) {
-		closestPtOnLine(gateA[0].x, gateA[0].y, gateB[0].x, gateB[0].y, gateLoc[1].x, gateLoc[1].y);
-		gateLoc[2].x = pt.x;				/* if point 2 between gates, ignore! */
-		gateLoc[2].y = pt.y;
+	if (compareSlope(x, y, p3.x, p3.y, gateA[0].x, gateA[0].y) ==
+			compareSlope(x, y, p3.x, p3.y, gateB[0].x, gateB[0].y)) {
+		closestPtOnLine(gateA[0].x, gateA[0].y, gateB[0].x, gateB[0].y, x, y);
+		p2.x = pt.x;				/* if point 2 between gates, ignore! */
+		p2.y = pt.y;
 	}
-
-	return;
 }
 
+/**
+ * Compute the "gate" between two boxes. The gate is a pair of two lines which
+ * both start on box 'trap1' and end on 'trap2'. For both lines, one of its
+ * end points is the corner point of one of the two boxes. The other end point
+ * is a point on the other point closest to first end point.
+ * This way the lines bound a 'corridor' between the two boxes, through which
+ * the actor has to walk to get from trap1 to trap2.
+ */
 void Scumm::getGates(int trap1, int trap2, ScummVM::Point gateA[2], ScummVM::Point gateB[2]) {
 	int i, j;
 	int dist[8];
@@ -1190,29 +1190,29 @@
 	int closest[3];
 	int box[3];
 	BoxCoords coords;
-	ScummVM::Point Clo[8];
-	ScummVM::Point poly[8];
+	ScummVM::Point closestPoint[8];
+	ScummVM::Point boxCorner[8];
 	int line1, line2;
 
 	// For all corner coordinates of the first box, compute the point closest 
 	// to them on the second box (and also compute the distance of these points).
 	getBoxCoordinates(trap1, &coords);
-	poly[0] = coords.ul;
-	poly[1] = coords.ur;
-	poly[2] = coords.lr;
-	poly[3] = coords.ll;
+	boxCorner[0] = coords.ul;
+	boxCorner[1] = coords.ur;
+	boxCorner[2] = coords.lr;
+	boxCorner[3] = coords.ll;
 	for (i = 0; i < 4; i++) {
-		dist[i] = getClosestPtOnBox(trap2, poly[i].x, poly[i].y, Clo[i].x, Clo[i].y);
+		dist[i] = getClosestPtOnBox(trap2, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
 	}
 
 	// Now do the same but with the roles of the first and second box swapped.
 	getBoxCoordinates(trap2, &coords);
-	poly[4] = coords.ul;
-	poly[5] = coords.ur;
-	poly[6] = coords.lr;
-	poly[7] = coords.ll;
+	boxCorner[4] = coords.ul;
+	boxCorner[5] = coords.ur;
+	boxCorner[6] = coords.lr;
+	boxCorner[7] = coords.ll;
 	for (i = 4; i < 8; i++) {
-		dist[i] = getClosestPtOnBox(trap1, poly[i].x, poly[i].y, Clo[i].x, Clo[i].y);
+		dist[i] = getClosestPtOnBox(trap1, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
 	}
 
 	// Find the three closest "close" points between the two boxes.
@@ -1230,28 +1230,26 @@
 	}
 
 
-	// Finally, compute the "gate". That's a pair of two points that are
-	// in the same box (actually, on the border of that box), which both have
-	// "minimal" distance to the other box in a certain sense.
+	// Finally, compute the actual "gate".
 
 	if (box[0] == box[1] && abs(minDist[0] - minDist[1]) < 4) {
 		line1 = closest[0];
 		line2 = closest[1];
 
-	} else if (box[0] == box[1] && minDist[0] == minDist[1]) {	/* parallel */
+	} else if (box[0] == box[1] && minDist[0] == minDist[1]) {	// parallel
 		line1 = closest[0];
 		line2 = closest[1];
-	} else if (box[0] == box[2] && minDist[0] == minDist[2]) {	/* parallel */
+	} else if (box[0] == box[2] && minDist[0] == minDist[2]) {	// parallel
 		line1 = closest[0];
 		line2 = closest[2];
-	} else if (box[1] == box[2] && minDist[1] == minDist[2]) {	/* parallel */
+	} else if (box[1] == box[2] && minDist[1] == minDist[2]) {	// parallel
 		line1 = closest[1];
 		line2 = closest[2];
 
 	} else if (box[0] == box[2] && abs(minDist[0] - minDist[2]) < 4) {
 		line1 = closest[0];
 		line2 = closest[2];
-	} else if (abs(minDist[0] - minDist[2]) < 4) {	/* if 1 close to 3 then use 2-3 */
+	} else if (abs(minDist[0] - minDist[2]) < 4) {
 		line1 = closest[1];
 		line2 = closest[2];
 	} else if (abs(minDist[0] - minDist[1]) < 4) {
@@ -1263,20 +1261,20 @@
 	}
 
 	// Set the gate
-	if (line1 < 4) {							/* from box 1 to box 2 */
-		gateA[0] = poly[line1];
-		gateA[1] = Clo[line1];
+	if (line1 < 4) {
+		gateA[0] = boxCorner[line1];
+		gateA[1] = closestPoint[line1];
 	} else {
-		gateA[1] = poly[line1];
-		gateA[0] = Clo[line1];
+		gateA[1] = boxCorner[line1];
+		gateA[0] = closestPoint[line1];
 	}
 
-	if (line2 < 4) {							/* from box */
-		gateB[0] = poly[line2];
-		gateB[1] = Clo[line2];
+	if (line2 < 4) {
+		gateB[0] = boxCorner[line2];
+		gateB[1] = closestPoint[line2];
 	} else {
-		gateB[1] = poly[line2];
-		gateB[0] = Clo[line2];
+		gateB[1] = boxCorner[line2];
+		gateB[0] = closestPoint[line2];
 	}
 }
 

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -d -r1.186 -r1.187
--- script_v6.cpp	11 Sep 2003 10:32:14 -0000	1.186
+++ script_v6.cpp	11 Sep 2003 22:00:35 -0000	1.187
@@ -1160,8 +1160,6 @@
 	if (VAR_WALKTO_OBJ != 0xFF)
 		VAR(VAR_WALKTO_OBJ) = 0;
 
-	/* startScene maybe modifies VAR_EGO, i hope not */
-
 	if (_version == 6) {
 		setCameraAt(a->x, a->y);
 		setCameraFollows(a);
@@ -1782,7 +1780,6 @@
 		break;
 	case 229:										/* stand */
 		a->stopActorMoving();
-		a->startAnimActor(a->standFrame);
 		break;
 	case 230:										/* set direction */
 		a->moving &= ~MF_TURN;

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.193
retrieving revision 2.194
diff -u -d -r2.193 -r2.194
--- script_v8.cpp	11 Sep 2003 10:32:14 -0000	2.193
+++ script_v8.cpp	11 Sep 2003 22:00:36 -0000	2.194
@@ -1039,7 +1039,6 @@
 		break;
 	case 0x80:		// SO_ACTOR_STOP
 		a->stopActorMoving();
-		a->startAnimActor(a->standFrame);
 		break;
 	case 0x81:		// SO_ACTOR_FACE Make actor face angle
 		a->moving &= ~MF_TURN;





More information about the Scummvm-git-logs mailing list