[Scummvm-cvs-logs] SF.net SVN: scummvm: [26262] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Mar 20 21:46:10 CET 2007


Revision: 26262
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26262&view=rev
Author:   peres001
Date:     2007-03-20 13:46:09 -0700 (Tue, 20 Mar 2007)

Log Message:
-----------
replaced some x,y/left,top pairs with Common::Point

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/animation.cpp
    scummvm/trunk/engines/parallaction/location.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/walk.cpp
    scummvm/trunk/engines/parallaction/zone.h

Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp	2007-03-20 19:56:02 UTC (rev 26261)
+++ scummvm/trunk/engines/parallaction/animation.cpp	2007-03-20 20:46:09 UTC (rev 26262)
@@ -141,8 +141,8 @@
 		fillBuffers(script, true);
 	}
 
-	vD0->_oldLeft = -1000;
-	vD0->_oldTop = -1000;
+	vD0->_oldPos.x = -1000;
+	vD0->_oldPos.y = -1000;
 
 	vD0->_flags |= 0x1000000;
 
@@ -207,7 +207,7 @@
 
 		if (((v18->_flags & kFlagsActive) == 0) && (v18->_flags & kFlagsRemove))   {
 			v18->_flags &= ~kFlagsRemove;
-			v18->_oldLeft = -1000;
+			v18->_oldPos.x = -1000;
 		}
 
 		if ((v18->_flags & kFlagsActive) && (v18->_flags & kFlagsRemove))	{
@@ -233,12 +233,12 @@
 		if (((a->_flags & kFlagsActive) == 0) && ((a->_flags & kFlagsRemove) == 0)) continue;
 
 		Common::Rect r(a->width(), a->height());
-		r.moveTo(a->_oldLeft, a->_oldTop);
+		r.moveTo(a->_oldPos);
 		_vm->_gfx->restoreBackground(r);
 
 		if (arg_0) {
-			a->_oldLeft = a->_left;
-			a->_oldTop = a->_top;
+			a->_oldPos.x = a->_left;
+			a->_oldPos.y = a->_top;
 		}
 
 	}

Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp	2007-03-20 19:56:02 UTC (rev 26261)
+++ scummvm/trunk/engines/parallaction/location.cpp	2007-03-20 20:46:09 UTC (rev 26262)
@@ -385,8 +385,8 @@
 	_gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2);
 	debugC(1, kDebugLocation, "changeLocation: new location '%s' parsed", _saveData1);
 
-	_vm->_char._ani._oldLeft = -1000;
-	_vm->_char._ani._oldTop = -1000;
+	_vm->_char._ani._oldPos.x = -1000;
+	_vm->_char._ani._oldPos.y = -1000;
 
 	_vm->_char._ani.field_50 = 0;
 	if (_location._startPosition.x != -1000) {

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-03-20 19:56:02 UTC (rev 26261)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-03-20 20:46:09 UTC (rev 26262)
@@ -260,8 +260,8 @@
 		_ani._left = 150;
 		_ani._top = 100;
 		_ani._z = 10;
-		_ani._oldLeft = -1000;
-		_ani._oldTop = -1000;
+		_ani._oldPos.x = -1000;
+		_ani._oldPos.y = -1000;
 		_ani._frame = 0;
 		_ani._flags = kFlagsActive | kFlagsNoName;
 		_ani._type = kZoneYou;

Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp	2007-03-20 19:56:02 UTC (rev 26261)
+++ scummvm/trunk/engines/parallaction/walk.cpp	2007-03-20 20:46:09 UTC (rev 26262)
@@ -134,25 +134,27 @@
 
 	WalkNode	v58;
 
-	int16 _si = v48->_x;						// _si, _di: target top left coordinates
-	int16 _di = v48->_y;
+	Common::Point stop(v48->_x, v48->_y);
 	addNode(&v58, v48);
 
 	WalkNode *_closest_node = NULL;
 
 	int32 v30, v34, v2C, v28;
 
+	Common::Point pos(_vm->_char._ani._left, _vm->_char._ani._top);
+
 	byte _closest_node_found = 1;
 	bool emptyList = true;
 
+	Common::Point v8;
+
 	do {
 
 		v48 = &v58;
 
-		Common::Point v20(_vm->_char._ani._left, _vm->_char._ani._top);
-		Common::Point v8(_si - _vm->_char._ani._left, _di - _vm->_char._ani._top);
+		Common::Point v20(pos);
 
-		v34 = v30 = dotProduct(v8, v8);				// square distance from current position and target
+		v34 = v30 = pos.sqrDist(stop);				// square distance from current position and target
 
 		while (_closest_node_found != 0) {
 
@@ -163,13 +165,10 @@
 			// which can't be farther than the target position
 			// otherwise no _closest_node is selected
 			while (location_node != NULL) {
-				v8.x = location_node->_x - _si;
-				v8.y = location_node->_y - _di;
-				v2C = dotProduct(v8, v8); 			// square distance from Node to target position
 
-				v8.x = location_node->_x - v20.x;
-				v8.y = location_node->_y - v20.y;
-				v28 = dotProduct(v8, v8); 			// square distance from Node to current position
+				location_node->getPoint(v8);
+				v2C = v8.sqrDist(stop);
+				v28 = v8.sqrDist(v20);
 
 				if (v2C < v34 && v28 < v30) {
 					_closest_node_found = 1;
@@ -185,11 +184,8 @@
 			WalkNode *_newnode = new WalkNode(*_closest_node);
 			_newnode->getPoint(v20);
 
-			Common::Point tmp(_si - v20.x, _di - v20.y);
+			v34 = v30 = v20.sqrDist(stop);
 
-			v34 = v30 = dotProduct(tmp, tmp);
-
-
 			debugC(1, kDebugWalk, "adding walk node (%i, %i) to path", _newnode->_x, _newnode->_y);
 
 			addNode(v48, _newnode);
@@ -204,8 +200,7 @@
 			debugC(1, kDebugWalk, "can't find a path node: rejecting partial path");
 			return v44;
 		} else {
-			_si = ((WalkNode*)(v58._next))->_x;
-			_di = ((WalkNode*)(v58._next))->_y;
+			((WalkNode*)(v58._next))->getPoint(stop);
 			emptyList = false;
 			_closest_node_found = 1;
 		}
@@ -373,8 +368,7 @@
 
 	Common::Point pos(_vm->_char._ani._left, _vm->_char._ani._top);
 
-	_vm->_char._ani._oldLeft = pos.x;
-	_vm->_char._ani._oldTop = pos.y;
+	_vm->_char._ani._oldPos = pos;
 
 	node = getNextPathNode(pos, node);
 	if (node == NULL) {
@@ -394,7 +388,7 @@
 	_vm->_char._ani._left = pos.x;
 	_vm->_char._ani._top = pos.y;
 
-	if ((pos.x == _vm->_char._ani._oldLeft) && (pos.y == _vm->_char._ani._oldTop)) {
+	if (pos == _vm->_char._ani._oldPos) {
 		j->_finished = 1;
 		checkDoor();
 		freeNodeList(node);

Modified: scummvm/trunk/engines/parallaction/zone.h
===================================================================
--- scummvm/trunk/engines/parallaction/zone.h	2007-03-20 19:56:02 UTC (rev 26261)
+++ scummvm/trunk/engines/parallaction/zone.h	2007-03-20 20:46:09 UTC (rev 26262)
@@ -219,11 +219,11 @@
 		_bottom += y;
 	}
 
-	uint16 width() const {
+	virtual uint16 width() const {
 		return _right - _left;
 	}
 
-	uint16 height() const {
+	virtual uint16 height() const {
 		return _bottom - _top;
 	}
 };
@@ -294,8 +294,8 @@
 
 
 struct Animation : public Zone  {
-	int16		_oldLeft;
-	int16		_oldTop;
+
+	Common::Point	_oldPos;
 	Program 	*_program;
 	Cnv 		*_cnv;
 	int16		_frame;
@@ -309,19 +309,18 @@
 	uint16		field_5E;		// unused
 
 	Animation() {
-		_oldLeft = _oldTop = 0;
 		_cnv = NULL;
 		_program = NULL;
 		_frame = 0;
 		_z = 0;
 	}
 
-	uint16 width() const {
+	virtual uint16 width() const {
 		if (!_cnv) return 0;
 		return _cnv->_width;
 	}
 
-	uint16 height() const {
+	virtual uint16 height() const {
 		if (!_cnv) return 0;
 		return _cnv->_height;
 	}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list