[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.111,1.112 boxes.cpp,1.33,1.34 actor.h,1.26,1.27 saveload.cpp,1.77,1.78 scumm.h,1.213,1.214

Max Horn fingolfin at users.sourceforge.net
Sun May 25 19:27:03 CEST 2003


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

Modified Files:
	actor.cpp boxes.cpp actor.h saveload.cpp scumm.h 
Log Message:
moved Actor SaveLoadEntry definition to actor.cpp; made findPathTowards/findPathTowardsOld members of Actor; cleanup

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- actor.cpp	24 May 2003 22:13:01 -0000	1.111
+++ actor.cpp	26 May 2003 02:26:13 -0000	1.112
@@ -27,6 +27,7 @@
 #include "charset.h"
 #include "costume.h"
 #include "resource.h"
+#include "saveload.h"
 #include "sound.h"
 #include "usage_bits.h"
 
@@ -592,7 +593,7 @@
 	}
 }
 
-int Actor::getActorXYPos(int &xPos, int &yPos) {
+int Actor::getActorXYPos(int &xPos, int &yPos) const {
 	if (!isInCurrentRoom())
 		return -1;
 
@@ -1308,7 +1309,7 @@
 
 		walkdata.curbox = box;
 		
-		if (_vm->findPathTowards(this, walkbox, box, walkdata.destbox, foundPathX, foundPathY))
+		if (findPathTowards(walkbox, box, walkdata.destbox, foundPathX, foundPathY))
 			break;
 
 		if (calcMovementFactor(foundPathX, foundPathY))
@@ -1389,7 +1390,7 @@
 
 		walkdata.curbox = next_box;
 
-		_vm->findPathTowardsOld(this, walkbox, next_box, walkdata.destbox, gateLoc);
+		findPathTowardsOld(walkbox, next_box, walkdata.destbox, gateLoc);
 		if (gateLoc[2].x == 32000 && gateLoc[3].x == 32000) {
 			break;
 		}
@@ -1521,3 +1522,84 @@
 }
 
 
+const SaveLoadEntry *Actor::getSaveLoadEntries() {
+	static const SaveLoadEntry actorEntries[] = {
+		MKLINE(Actor, x, sleInt16, VER_V8),
+		MKLINE(Actor, y, sleInt16, VER_V8),
+		MKLINE(Actor, top, sleInt16, VER_V8),
+		MKLINE(Actor, bottom, sleInt16, VER_V8),
+		MKLINE(Actor, elevation, sleInt16, VER_V8),
+		MKLINE(Actor, width, sleUint16, VER_V8),
+		MKLINE(Actor, facing, sleUint16, VER_V8),
+		MKLINE(Actor, costume, sleUint16, VER_V8),
+		MKLINE(Actor, room, sleByte, VER_V8),
+		MKLINE(Actor, talkColor, sleByte, VER_V8),
+		MKLINE(Actor, talkFrequency, sleInt16, VER_V16),
+		MKLINE(Actor, scalex, sleByte, VER_V8),
+		MKLINE(Actor, scaley, sleByte, VER_V8),
+		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, moving, sleByte, VER_V8),
+		MKLINE(Actor, ignoreBoxes, sleByte, VER_V8),
+		MKLINE(Actor, forceClip, sleByte, VER_V8),
+		MKLINE(Actor, initFrame, sleByte, VER_V8),
+		MKLINE(Actor, walkFrame, sleByte, VER_V8),
+		MKLINE(Actor, standFrame, sleByte, VER_V8),
+		MKLINE(Actor, talkStartFrame, sleByte, VER_V8),
+		MKLINE(Actor, talkStopFrame, sleByte, VER_V8),
+		MKLINE(Actor, speedx, sleUint16, VER_V8),
+		MKLINE(Actor, speedy, sleUint16, VER_V8),
+		MKLINE(Actor, cost.animCounter1, sleUint16, VER_V8),
+		MKLINE(Actor, cost.animCounter2, sleByte, VER_V8),
+	
+		// Actor palette grew from 64 to 256 bytes
+		MKARRAY_OLD(Actor, palette[0], sleByte, 64, VER_V8, VER_V9),
+		MKARRAY(Actor, palette[0], sleByte, 256, VER_V10),
+	
+		MK_OBSOLETE(Actor, mask, sleByte, VER_V8, VER_V9),
+		MKLINE(Actor, shadow_mode, sleByte, VER_V8),
+		MKLINE(Actor, visible, sleByte, VER_V8),
+		MKLINE(Actor, frame, sleByte, VER_V8),
+		MKLINE(Actor, animSpeed, sleByte, VER_V8),
+		MKLINE(Actor, animProgress, sleByte, VER_V8),
+		MKLINE(Actor, walkbox, sleByte, VER_V8),
+		MKLINE(Actor, needRedraw, sleByte, VER_V8),
+		MKLINE(Actor, needBgReset, sleByte, VER_V8),
+		MKLINE(Actor, costumeNeedsInit, sleByte, VER_V8),
+	
+		MKLINE(Actor, talkPosY, sleInt16, VER_V8),
+		MKLINE(Actor, talkPosX, sleInt16, VER_V8),
+		MKLINE(Actor, ignoreTurns, sleByte, VER_V8),
+	
+		MKLINE(Actor, layer, sleByte, VER_V8),
+	
+		MKLINE(Actor, talk_script, sleUint16, VER_V8),
+		MKLINE(Actor, walk_script, sleUint16, VER_V8),
+	
+		MKLINE(Actor, walkdata.destx, sleInt16, VER_V8),
+		MKLINE(Actor, walkdata.desty, sleInt16, VER_V8),
+		MKLINE(Actor, walkdata.destbox, sleByte, VER_V8),
+		MKLINE(Actor, walkdata.destdir, sleUint16, VER_V8),
+		MKLINE(Actor, walkdata.curbox, sleByte, VER_V8),
+		MKLINE(Actor, walkdata.x, sleInt16, VER_V8),
+		MKLINE(Actor, walkdata.y, sleInt16, VER_V8),
+		MKLINE(Actor, walkdata.newx, sleInt16, VER_V8),
+		MKLINE(Actor, walkdata.newy, sleInt16, VER_V8),
+		MKLINE(Actor, walkdata.deltaXFactor, sleInt32, VER_V8),
+		MKLINE(Actor, walkdata.deltaYFactor, sleInt32, VER_V8),
+		MKLINE(Actor, walkdata.xfrac, sleUint16, VER_V8),
+		MKLINE(Actor, walkdata.yfrac, sleUint16, VER_V8),
+	
+		MKARRAY(Actor, cost.active[0], sleByte, 16, VER_V8),
+		MKLINE(Actor, cost.stopped, sleUint16, VER_V8),
+		MKARRAY(Actor, cost.curpos[0], sleUint16, 16, VER_V8),
+		MKARRAY(Actor, cost.start[0], sleUint16, 16, VER_V8),
+		MKARRAY(Actor, cost.end[0], sleUint16, 16, VER_V8),
+		MKARRAY(Actor, cost.frame[0], sleUint16, 16, VER_V8),
+		MKEND()
+	};
+	
+	return actorEntries;
+}

Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/boxes.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- boxes.cpp	20 May 2003 20:42:27 -0000	1.33
+++ boxes.cpp	26 May 2003 02:26:13 -0000	1.34
@@ -86,7 +86,9 @@
 #define BOX_MATRIX_SIZE 2000
 
 
-PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node);
+static bool compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3);
+static ScummVM::Point closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y);
+static PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node);
 
 
 byte Scumm::getMaskFromBox(int box) {
@@ -397,7 +399,12 @@
 	return diffx + diffy;
 }
 
-ScummVM::Point Scumm::closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y) {
+
+bool compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3) {
+	return (Y2 - Y1) * (X3 - X1) <= (Y3 - Y1) * (X2 - X1);
+}
+
+ScummVM::Point closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y) {
 	int lydiff, lxdiff;
 	int32 dist, a, b, c;
 	int x2, y2;
@@ -611,7 +618,7 @@
  * Computes the next point actor a has to walk towards in a straight
  * line in order to get from box1 to box3 via box2.
  */
-bool Scumm::findPathTowards(Actor *a, byte box1nr, byte box2nr, byte box3nr, int16 &foundPathX, int16 &foundPathY) {
+bool Actor::findPathTowards(byte box1nr, byte box2nr, byte box3nr, int16 &foundPathX, int16 &foundPathY) {
 	BoxCoords box1;
 	BoxCoords box2;
 	ScummVM::Point tmp;
@@ -619,8 +626,8 @@
 	int flag;
 	int q, pos;
 
-	getBoxCoordinates(box1nr, &box1);
-	getBoxCoordinates(box2nr, &box2);
+	_vm->getBoxCoordinates(box1nr, &box1);
+	_vm->getBoxCoordinates(box2nr, &box2);
 
 	for (i = 0; i < 4; i++) {
 		for (j = 0; j < 4; j++) {
@@ -644,11 +651,11 @@
 					if (flag & 2)
 						SWAP(box2.ul.y, box2.ur.y);
 				} else {
-					pos = a->y;
+					pos = y;
 					if (box2nr == box3nr) {
-						int diffX = a->walkdata.destx - a->x;
-						int diffY = a->walkdata.desty - a->y;
-						int boxDiffX = box1.ul.x - a->x;
+						int diffX = walkdata.destx - x;
+						int diffY = walkdata.desty - y;
+						int boxDiffX = box1.ul.x - x;
 
 						if (diffX != 0) {
 							int t;
@@ -658,7 +665,7 @@
 							if (t == 0 && (diffY <= 0 || diffX <= 0)
 									&& (diffY >= 0 || diffX >= 0))
 								t = -1;
-							pos = a->y + t;
+							pos = y + t;
 						}
 					}
 
@@ -701,16 +708,16 @@
 				} else {
 
 					if (box2nr == box3nr) {
-						int diffX = a->walkdata.destx - a->x;
-						int diffY = a->walkdata.desty - a->y;
-						int boxDiffY = box1.ul.y - a->y;
+						int diffX = walkdata.destx - x;
+						int diffY = walkdata.desty - y;
+						int boxDiffY = box1.ul.y - y;
 
-						pos = a->x;
+						pos = x;
 						if (diffY != 0) {
 							pos += diffX * boxDiffY / diffY;
 						}
 					} else {
-						pos = a->x;
+						pos = x;
 					}
 
 					q = pos;
@@ -1053,24 +1060,24 @@
 	return (PathVertex *)addToBoxVertexHeap(sizeof(PathVertex));
 }
 
-void Scumm::findPathTowardsOld(Actor *actor, byte trap1, byte trap2, byte final_trap, ScummVM::Point gateLoc[5]) {
+void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, ScummVM::Point gateLoc[5]) {
 	ScummVM::Point pt;
 	ScummVM::Point gateA[2];
 	ScummVM::Point gateB[2];
 
-	getGates(trap1, trap2, gateA, gateB);
+	_vm->getGates(trap1, trap2, gateA, gateB);
 
-	gateLoc[1].x = actor->x;
-	gateLoc[1].y = actor->y;
+	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 = actor->walkdata.destx;
-		gateLoc[4].y = actor->walkdata.desty;
+		gateLoc[4].x = walkdata.destx;
+		gateLoc[4].y = walkdata.desty;
 
-		if (getMaskFromBox(trap1) == getMaskFromBox(trap2) || 1) {
+		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) !=
@@ -1200,6 +1207,3 @@
 	}
 }
 
-bool Scumm::compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3) {
-	return (Y2 - Y1) * (X3 - X1) <= (Y3 - Y1) * (X2 - X1);
-}

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- actor.h	25 May 2003 11:53:42 -0000	1.26
+++ actor.h	26 May 2003 02:26:13 -0000	1.27
@@ -67,6 +67,8 @@
 	}
 };
 
+class SaveLoadEntry;
+
 class Actor {
 
 public:
@@ -102,12 +104,13 @@
 	uint16 talk_script, walk_script;
 	bool ignoreTurns;	// TODO - we do not honor this flag at all currently!
 	int8 layer;
-	ActorWalkData walkdata;
-	int16 animVariable[16];
 	uint16 sound[8];
 	CostumeData cost;
 	byte palette[256];
 protected:
+	ActorWalkData walkdata;
+	int16 animVariable[16];
+
 	static Scumm *_vm;
 
 public:
@@ -173,17 +176,17 @@
 
 	void animateActor(int anim);
 
-	bool isInCurrentRoom() {
+	bool isInCurrentRoom() const {
 		return room == _vm->_currentRoom;
 	}
 	
-	int getActorXYPos(int &x, int &y);
+	int getActorXYPos(int &x, int &y) const ;
 
-	int getRoom() {
+	int getRoom() const {
 		return room;
 	}
 
-	int getAnimVar(byte var) {
+	int getAnimVar(byte var) const {
 		return animVariable[var];
 	}
 	void setAnimVar(byte var, int value) {
@@ -192,10 +195,16 @@
 	
 	void classChanged(int cls, bool value);
 	
+	// Used by the save/load syste:
+	static const SaveLoadEntry *getSaveLoadEntries();
+	
 protected:
 	bool isInClass(int cls);
 	
 	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]);
 };
 
 #endif

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- saveload.cpp	23 May 2003 03:34:18 -0000	1.77
+++ saveload.cpp	26 May 2003 02:26:13 -0000	1.78
@@ -272,83 +272,7 @@
 		MKEND()
 	};
 
-	const SaveLoadEntry actorEntries[] = {
-		MKLINE(Actor, x, sleInt16, VER_V8),
-		MKLINE(Actor, y, sleInt16, VER_V8),
-		MKLINE(Actor, top, sleInt16, VER_V8),
-		MKLINE(Actor, bottom, sleInt16, VER_V8),
-		MKLINE(Actor, elevation, sleInt16, VER_V8),
-		MKLINE(Actor, width, sleUint16, VER_V8),
-		MKLINE(Actor, facing, sleUint16, VER_V8),
-		MKLINE(Actor, costume, sleUint16, VER_V8),
-		MKLINE(Actor, room, sleByte, VER_V8),
-		MKLINE(Actor, talkColor, sleByte, VER_V8),
-		MKLINE(Actor, talkFrequency, sleInt16, VER_V16),
-		MKLINE(Actor, scalex, sleByte, VER_V8),
-		MKLINE(Actor, scaley, sleByte, VER_V8),
-		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, moving, sleByte, VER_V8),
-		MKLINE(Actor, ignoreBoxes, sleByte, VER_V8),
-		MKLINE(Actor, forceClip, sleByte, VER_V8),
-		MKLINE(Actor, initFrame, sleByte, VER_V8),
-		MKLINE(Actor, walkFrame, sleByte, VER_V8),
-		MKLINE(Actor, standFrame, sleByte, VER_V8),
-		MKLINE(Actor, talkStartFrame, sleByte, VER_V8),
-		MKLINE(Actor, talkStopFrame, sleByte, VER_V8),
-		MKLINE(Actor, speedx, sleUint16, VER_V8),
-		MKLINE(Actor, speedy, sleUint16, VER_V8),
-		MKLINE(Actor, cost.animCounter1, sleUint16, VER_V8),
-		MKLINE(Actor, cost.animCounter2, sleByte, VER_V8),
-
-		// Actor palette grew from 64 to 256 bytes
-		MKARRAY_OLD(Actor, palette[0], sleByte, 64, VER_V8, VER_V9),
-		MKARRAY(Actor, palette[0], sleByte, 256, VER_V10),
-
-		MK_OBSOLETE(Actor, mask, sleByte, VER_V8, VER_V9),
-		MKLINE(Actor, shadow_mode, sleByte, VER_V8),
-		MKLINE(Actor, visible, sleByte, VER_V8),
-		MKLINE(Actor, frame, sleByte, VER_V8),
-		MKLINE(Actor, animSpeed, sleByte, VER_V8),
-		MKLINE(Actor, animProgress, sleByte, VER_V8),
-		MKLINE(Actor, walkbox, sleByte, VER_V8),
-		MKLINE(Actor, needRedraw, sleByte, VER_V8),
-		MKLINE(Actor, needBgReset, sleByte, VER_V8),
-		MKLINE(Actor, costumeNeedsInit, sleByte, VER_V8),
-
-		MKLINE(Actor, talkPosY, sleInt16, VER_V8),
-		MKLINE(Actor, talkPosX, sleInt16, VER_V8),
-		MKLINE(Actor, ignoreTurns, sleByte, VER_V8),
-
-		MKLINE(Actor, layer, sleByte, VER_V8),
-
-		MKLINE(Actor, talk_script, sleUint16, VER_V8),
-		MKLINE(Actor, walk_script, sleUint16, VER_V8),
-
-		MKLINE(Actor, walkdata.destx, sleInt16, VER_V8),
-		MKLINE(Actor, walkdata.desty, sleInt16, VER_V8),
-		MKLINE(Actor, walkdata.destbox, sleByte, VER_V8),
-		MKLINE(Actor, walkdata.destdir, sleUint16, VER_V8),
-		MKLINE(Actor, walkdata.curbox, sleByte, VER_V8),
-		MKLINE(Actor, walkdata.x, sleInt16, VER_V8),
-		MKLINE(Actor, walkdata.y, sleInt16, VER_V8),
-		MKLINE(Actor, walkdata.newx, sleInt16, VER_V8),
-		MKLINE(Actor, walkdata.newy, sleInt16, VER_V8),
-		MKLINE(Actor, walkdata.deltaXFactor, sleInt32, VER_V8),
-		MKLINE(Actor, walkdata.deltaYFactor, sleInt32, VER_V8),
-		MKLINE(Actor, walkdata.xfrac, sleUint16, VER_V8),
-		MKLINE(Actor, walkdata.yfrac, sleUint16, VER_V8),
-
-		MKARRAY(Actor, cost.active[0], sleByte, 16, VER_V8),
-		MKLINE(Actor, cost.stopped, sleUint16, VER_V8),
-		MKARRAY(Actor, cost.curpos[0], sleUint16, 16, VER_V8),
-		MKARRAY(Actor, cost.start[0], sleUint16, 16, VER_V8),
-		MKARRAY(Actor, cost.end[0], sleUint16, 16, VER_V8),
-		MKARRAY(Actor, cost.frame[0], sleUint16, 16, VER_V8),
-		MKEND()
-	};
+	const SaveLoadEntry *actorEntries = Actor::getSaveLoadEntries();
 
 	const SaveLoadEntry verbEntries[] = {
 		MKLINE(VerbSlot, x, sleInt16, VER_V8),

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -d -r1.213 -r1.214
--- scumm.h	25 May 2003 20:38:44 -0000	1.213
+++ scumm.h	26 May 2003 02:26:13 -0000	1.214
@@ -993,8 +993,6 @@
 	byte getNumBoxes();
 	byte *getBoxMatrixBaseAddr();
 	int getPathToDestBox(byte from, byte to);
-	bool findPathTowards(Actor *a, byte box, byte box2, byte box3, int16 &foundPathX, int16 &foundPathY);
-	void findPathTowardsOld(Actor *a, byte box, byte box2, byte box3, ScummVM::Point gateLoc[5]);
 	void getGates(int trap1, int trap2, ScummVM::Point gateA[2], ScummVM::Point gateB[2]);
 	bool inBoxQuickReject(int box, int x, int y, int threshold);
 	AdjustBoxResult getClosestPtOnBox(int box, int x, int y);
@@ -1005,7 +1003,6 @@
 
 	bool checkXYInBoxBounds(int box, int x, int y);
 	uint distanceFromPt(int x, int y, int ptx, int pty);
-	ScummVM::Point closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y);
 	void getBoxCoordinates(int boxnum, BoxCoords *bc);
 	byte getMaskFromBox(int box);
 	Box *getBoxBaseAddr(int box);
@@ -1027,7 +1024,6 @@
 
 	void createBoxMatrix();
 	void addToBoxMatrix(byte b);
-	bool compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3);
 	PathNode *unkMatrixProc2(PathVertex *vtx, int i);
 	void *addToBoxVertexHeap(int size);
 	PathVertex *addPathVertex();





More information about the Scummvm-git-logs mailing list