[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.171,1.172 actor.h,1.38,1.39 boxes.cpp,1.61,1.62

Max Horn fingolfin at users.sourceforge.net
Thu Sep 11 15:44:14 CEST 2003


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

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

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -d -r1.171 -r1.172
--- actor.cpp	11 Sep 2003 22:12:24 -0000	1.171
+++ actor.cpp	11 Sep 2003 22:26:44 -0000	1.172
@@ -58,7 +58,7 @@
 	memset(sound, 0, sizeof(sound));
 	memset(&cost, 0, sizeof(CostumeData));
 	memset(&walkdata, 0, sizeof(ActorWalkData));
-	walkdata.point3x = 32000;
+	walkdata.point3.x = 32000;
 
 	walkScript = 0;
 
@@ -137,7 +137,7 @@
 	speedy = newSpeedY;
 
 	if (moving) {
-		calcMovementFactor(walkdata.newx, walkdata.newy);
+		calcMovementFactor(walkdata.next);
 	}
 }
 
@@ -158,19 +158,16 @@
 	}
 }
 
-int Actor::calcMovementFactor(int newX, int newY) {
-	int actorX, actorY;
+int Actor::calcMovementFactor(ScummVM::Point next) {
+	ScummVM::Point actorPos(x, y);
 	int diffX, diffY;
 	int32 deltaXFactor, deltaYFactor;
 
-	actorX = x;
-	actorY = y;
-
-	if (actorX == newX && actorY == newY)
+	if (actorPos == next)
 		return 0;
 
-	diffX = newX - actorX;
-	diffY = newY - actorY;
+	diffX = next.x - actorPos.x;
+	diffY = next.y - actorPos.y;
 	deltaYFactor = speedy << 16;
 
 	if (diffY < 0)
@@ -196,10 +193,8 @@
 		}
 	}
 
-	walkdata.x = actorX;
-	walkdata.y = actorY;
-	walkdata.newx = newX;
-	walkdata.newy = newY;
+	walkdata.cur = actorPos;
+	walkdata.next = next;
 	walkdata.deltaXFactor = deltaXFactor;
 	walkdata.deltaYFactor = deltaYFactor;
 	walkdata.xfrac = 0;
@@ -367,10 +362,10 @@
 		setBox(walkdata.curbox);
 	}
 
-	distX = abs(walkdata.newx - walkdata.x);
-	distY = abs(walkdata.newy - walkdata.y);
+	distX = abs(walkdata.next.x - walkdata.cur.x);
+	distY = abs(walkdata.next.y - walkdata.cur.y);
 
-	if (abs(actorX - walkdata.x) >= distX && abs(actorY - walkdata.y) >= distY) {
+	if (abs(actorX - walkdata.cur.x) >= distX && abs(actorY - walkdata.cur.y) >= distY) {
 		moving &= ~MF_IN_LEG;
 		return 0;
 	}
@@ -383,12 +378,12 @@
 	walkdata.yfrac = (uint16)tmpY;
 	actorY = (tmpY >> 16);
 
-	if (abs(actorX - walkdata.x) > distX) {
-		actorX = walkdata.newx;
+	if (abs(actorX - walkdata.cur.x) > distX) {
+		actorX = walkdata.next.x;
 	}
 
-	if (abs(actorY - walkdata.y) > distY) {
-		actorY = walkdata.newy;
+	if (abs(actorY - walkdata.cur.y) > distY) {
+		actorY = walkdata.next.y;
 	}
 
 	x = actorX;
@@ -692,7 +687,7 @@
 
 	setBox(abr.box);
 
-	walkdata.destx = -1;
+	walkdata.dest.x = -1;
 
 	moving = 0;
 	cost.soundCounter = 0;
@@ -1266,7 +1261,7 @@
 		} else {
 			abr = adjustXYToBeInBox(abr.x, abr.y);
 		}
-		if (moving && walkdata.destdir == dir && walkdata.destx == abr.x && walkdata.desty == abr.y)
+		if (moving && walkdata.destdir == dir && walkdata.dest.x == abr.x && walkdata.dest.y == abr.y)
 			return;
 	}
 
@@ -1275,12 +1270,12 @@
 		return;
 	}
 
-	walkdata.destx = abr.x;
-	walkdata.desty = abr.y;
+	walkdata.dest.x = abr.x;
+	walkdata.dest.y = abr.y;
 	walkdata.destbox = abr.box;
 	walkdata.destdir = dir;
 	moving = (moving & MF_IN_LEG) | MF_NEW_LEG;
-	walkdata.point3x = 32000;
+	walkdata.point3.x = 32000;
 
 	walkdata.curbox = walkbox;
 }
@@ -1323,7 +1318,7 @@
 
 void Actor::walkActor() {
 	int new_dir, next_box;
-	int16 foundPathX, foundPathY;
+	ScummVM::Point foundPath;
 
 	if (_vm->_version >= 7) {
 		// FIXME - this is kind of a hack right now but it fixes the
@@ -1388,17 +1383,17 @@
 
 		walkdata.curbox = next_box;
 		
-		if (findPathTowards(walkbox, next_box, walkdata.destbox, foundPathX, foundPathY))
+		if (findPathTowards(walkbox, next_box, walkdata.destbox, foundPath.x, foundPath.y))
 			break;
 
-		if (calcMovementFactor(foundPathX, foundPathY))
+		if (calcMovementFactor(foundPath))
 			return;
 
 		setBox(walkdata.curbox);
 	} while (1);
 
 	moving |= MF_LAST_LEG;
-	calcMovementFactor(walkdata.destx, walkdata.desty);
+	calcMovementFactor(walkdata.dest);
 }
 
 void Actor::walkActorOld() {
@@ -1427,12 +1422,12 @@
 			return;
 		}
 	
-		if (walkdata.point3x != 32000) {
-			if (calcMovementFactor(walkdata.point3x, walkdata.point3y)) {
-				walkdata.point3x = 32000;
+		if (walkdata.point3.x != 32000) {
+			if (calcMovementFactor(walkdata.point3)) {
+				walkdata.point3.x = 32000;
 				return;
 			}
-			walkdata.point3x = 32000;
+			walkdata.point3.x = 32000;
 		}
 	
 		setBox(walkdata.curbox);
@@ -1477,23 +1472,22 @@
 		}
 
 		if (p2.x != 32000) {
-			if (calcMovementFactor(p2.x, p2.y)) {
-				walkdata.point3x = p3.x; 
-				walkdata.point3y = p3.y;
+			if (calcMovementFactor(p2)) {
+				walkdata.point3 = p3;
 				return;
 			}
 		}
 /*
 		}
 */
-		if (calcMovementFactor(p3.x, p3.y))
+		if (calcMovementFactor(p3))
 			return;
 
 		setBox(walkdata.curbox);
 	} while (1);
 
 	moving |= MF_LAST_LEG;
-	calcMovementFactor(walkdata.destx, walkdata.desty);
+	calcMovementFactor(walkdata.dest);
 }
 
 byte *Actor::getActorName() {
@@ -1642,15 +1636,15 @@
 		MKLINE(Actor, talkScript, sleUint16, VER(8)),
 		MKLINE(Actor, walkScript, sleUint16, VER(8)),
 	
-		MKLINE(Actor, walkdata.destx, sleInt16, VER(8)),
-		MKLINE(Actor, walkdata.desty, sleInt16, VER(8)),
+		MKLINE(Actor, walkdata.dest.x, sleInt16, VER(8)),
+		MKLINE(Actor, walkdata.dest.y, sleInt16, VER(8)),
 		MKLINE(Actor, walkdata.destbox, sleByte, VER(8)),
 		MKLINE(Actor, walkdata.destdir, sleUint16, VER(8)),
 		MKLINE(Actor, walkdata.curbox, sleByte, VER(8)),
-		MKLINE(Actor, walkdata.x, sleInt16, VER(8)),
-		MKLINE(Actor, walkdata.y, sleInt16, VER(8)),
-		MKLINE(Actor, walkdata.newx, sleInt16, VER(8)),
-		MKLINE(Actor, walkdata.newy, sleInt16, VER(8)),
+		MKLINE(Actor, walkdata.cur.x, sleInt16, VER(8)),
+		MKLINE(Actor, walkdata.cur.y, sleInt16, VER(8)),
+		MKLINE(Actor, walkdata.next.x, sleInt16, VER(8)),
+		MKLINE(Actor, walkdata.next.y, sleInt16, VER(8)),
 		MKLINE(Actor, walkdata.deltaXFactor, sleInt32, VER(8)),
 		MKLINE(Actor, walkdata.deltaYFactor, sleInt32, VER(8)),
 		MKLINE(Actor, walkdata.xfrac, sleUint16, VER(8)),

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- actor.h	11 Sep 2003 22:00:34 -0000	1.38
+++ actor.h	11 Sep 2003 22:26:44 -0000	1.39
@@ -37,15 +37,15 @@
 };
 
 struct ActorWalkData {
-	int16 destx, desty;						// Final destination
+	ScummVM::Point dest;						// Final destination
 	byte destbox;
 	int16 destdir;
+	ScummVM::Point cur;										// Current position
 	byte curbox;
-	int16 x, y;										// Current position
-	int16 newx, newy;							// Next position on our way to the destination
+	ScummVM::Point next;							// Next position on our way to the destination
+	ScummVM::Point point3;
 	int32 deltaXFactor, deltaYFactor;
 	uint16 xfrac, yfrac;
-	int point3x, point3y;
 };
 
 struct CostumeData {
@@ -132,7 +132,7 @@
 	void putActor(int x, int y, byte room);
 	void setActorWalkSpeed(uint newSpeedX, uint newSpeedY);
 protected:
-	int calcMovementFactor(int newx, int newy);
+	int calcMovementFactor(ScummVM::Point next);
 	int actorWalkStep();
 	int remapDirection(int dir, bool is_walking);
 	void setupActorScale();

Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/boxes.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- boxes.cpp	11 Sep 2003 22:00:34 -0000	1.61
+++ boxes.cpp	11 Sep 2003 22:26:44 -0000	1.62
@@ -804,8 +804,8 @@
 				} else {
 					pos = y;
 					if (box2nr == box3nr) {
-						int diffX = walkdata.destx - x;
-						int diffY = walkdata.desty - y;
+						int diffX = walkdata.dest.x - x;
+						int diffY = walkdata.dest.y - y;
 						int boxDiffX = box1.ul.x - x;
 
 						if (diffX != 0) {
@@ -859,8 +859,8 @@
 				} else {
 
 					if (box2nr == box3nr) {
-						int diffX = walkdata.destx - x;
-						int diffY = walkdata.desty - y;
+						int diffX = walkdata.dest.x - x;
+						int diffY = walkdata.dest.y - y;
 						int boxDiffY = box1.ul.y - y;
 
 						pos = x;
@@ -1155,10 +1155,10 @@
 	// 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)) {
+		if (compareSlope(x, y, walkdata.dest.x, walkdata.dest.y, gateA[0].x, gateA[0].y) !=
+				compareSlope(x, y, walkdata.dest.x, walkdata.dest.y, gateB[0].x, gateB[0].y) &&
+				compareSlope(x, y, walkdata.dest.x, walkdata.dest.y, gateA[1].x, gateA[1].y) !=
+				compareSlope(x, y, walkdata.dest.x, walkdata.dest.y, gateB[1].x, gateB[1].y)) {
 			return;
 		}
 	}





More information about the Scummvm-git-logs mailing list