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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Fri Jul 25 18:01:25 CEST 2008


Revision: 33289
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33289&view=rev
Author:   peres001
Date:     2008-07-25 16:01:25 +0000 (Fri, 25 Jul 2008)

Log Message:
-----------
* Changed walk code to use Common::Point instead of the clumsy WalkNode.
* Changed walk code to use object copy instead of managing pointers.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parser.h
    scummvm/trunk/engines/parallaction/parser_ns.cpp
    scummvm/trunk/engines/parallaction/walk.cpp
    scummvm/trunk/engines/parallaction/walk.h

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-07-25 12:59:46 UTC (rev 33288)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-07-25 16:01:25 UTC (rev 33289)
@@ -177,7 +177,7 @@
 	char		_soundFile[50];
 
 	// NS specific
-	WalkNodeList	_walkNodes;
+	PointList	_walkNodes;
 	char _slideText[2][MAX_TOKEN_LEN];
 
 	// BRA specific
@@ -199,7 +199,7 @@
 	GfxObj			*_talk;
 	GfxObj			*_objs;
 	PathBuilder		_builder;
-	WalkNodeList	*_walkPath;
+	PointList		*_walkPath;
 
 	Character(Parallaction *vm);
 	void getFoot(Common::Point &foot);
@@ -259,7 +259,6 @@
 	void		resumeJobs();
 
 	void		finalizeWalk(Character &character);
-	int16		selectWalkFrame(Character &character, const Common::Point& pos, const WalkNodePtr to);
 	void		clipMove(Common::Point& pos, const Common::Point& to);
 
 	ZonePtr		findZone(const char *name);

Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h	2008-07-25 12:59:46 UTC (rev 33288)
+++ scummvm/trunk/engines/parallaction/parser.h	2008-07-25 16:01:25 UTC (rev 33289)
@@ -193,7 +193,7 @@
 
 	void		parseZone(ZoneList &list, char *name);
 	void		parseZoneTypeBlock(ZonePtr z);
-	void		parseWalkNodes(WalkNodeList &list);
+	void		parseWalkNodes(PointList &list);
 	void		parseAnimation(AnimationList &list, char *name);
 	void		parseCommands(CommandList&);
 	void		parseCommandFlags();

Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-07-25 12:59:46 UTC (rev 33288)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-07-25 16:01:25 UTC (rev 33289)
@@ -1124,20 +1124,14 @@
 	resolveCommandForwards();
 }
 
-void LocationParser_ns::parseWalkNodes(WalkNodeList &list) {
+void LocationParser_ns::parseWalkNodes(PointList &list) {
 	debugC(5, kDebugParser, "parseWalkNodes()");
 
 	_script->readLineToken(true);
 	while (scumm_stricmp(_tokens[0], "ENDNODES")) {
 
 		if (!scumm_stricmp(_tokens[0], "COORD")) {
-
-			WalkNodePtr v4(new WalkNode(
-				atoi(_tokens[1]),
-				atoi(_tokens[2])
-			));
-
-			list.push_front(v4);
+			list.push_front(Common::Point(atoi(_tokens[1]), atoi(_tokens[2])));
 		}
 
 		_script->readLineToken(true);
@@ -1397,7 +1391,7 @@
 	list.push_front(z);
 
 	_parser->pushTables(&_locationZoneParsers, _locationZoneStmt);
-	
+
 	return;
 }
 

Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp	2008-07-25 12:59:46 UTC (rev 33288)
+++ scummvm/trunk/engines/parallaction/walk.cpp	2008-07-25 16:01:25 UTC (rev 33289)
@@ -97,16 +97,15 @@
 
 	while (true) {
 
-		WalkNodeList::iterator nearest = _vm->_location._walkNodes.end();
-		WalkNodeList::iterator locNode = _vm->_location._walkNodes.begin();
+		PointList::iterator nearest = _vm->_location._walkNodes.end();
+		PointList::iterator locNode = _vm->_location._walkNodes.begin();
 
 		// scans location path nodes searching for the nearest Node
 		// which can't be farther than the target position
 		// otherwise no _closest_node is selected
 		while (locNode != _vm->_location._walkNodes.end()) {
 
-			Common::Point v8;
-			(*locNode)->getPoint(v8);
+			Common::Point v8 = *locNode;
 			v2C = v8.sqrDist(stop);
 			v28 = v8.sqrDist(v20);
 
@@ -120,10 +119,10 @@
 
 		if (nearest == _vm->_location._walkNodes.end()) break;
 
-		(*nearest)->getPoint(v20);
+		v20 = *nearest;
 		v34 = v30 = v20.sqrDist(stop);
 
-		_subPath.push_back(WalkNodePtr(new WalkNode(**nearest)));
+		_subPath.push_back(*nearest);
 	}
 
 	return v34;
@@ -141,34 +140,34 @@
 //
 //	x, y: mouse click (foot) coordinates
 //
-WalkNodeList *PathBuilder::buildPath(uint16 x, uint16 y) {
+PointList *PathBuilder::buildPath(uint16 x, uint16 y) {
 	debugC(1, kDebugWalk, "PathBuilder::buildPath to (%i, %i)", x, y);
 
 	Common::Point to(x, y);
 	correctPathPoint(to);
 	debugC(1, kDebugWalk, "found closest path point at (%i, %i)", to.x, to.y);
 
-	WalkNodePtr v48(new WalkNode(to.x, to.y));
-	WalkNodePtr v44 = v48;
+	Common::Point v48(to);
+	Common::Point v44(to);
 
 	uint16 v38 = walkFunc1(to.x, to.y, v44);
 	if (v38 == 1) {
 		// destination directly reachable
 		debugC(1, kDebugWalk, "direct move to (%i, %i)", to.x, to.y);
 
-		_list = new WalkNodeList;
+		_list = new PointList;
 		_list->push_back(v48);
 		return _list;
 	}
 
 	// path is obstructed: look for alternative
-	_list = new WalkNodeList;
+	_list = new PointList;
 	_list->push_back(v48);
 #if 0
 	printNodes(_list, "start");
 #endif
 
-	Common::Point stop(v48->_x, v48->_y);
+	Common::Point stop(v48.x, v48.y);
 	Common::Point pos;
 	_vm->_char.getFoot(pos);
 
@@ -184,7 +183,7 @@
 	printNodes(_list, "first segment");
 #endif
 
-	(*_list->begin())->getPoint(stop);
+	stop = *_list->begin();
 	buildSubPath(pos, stop);
 	_list->insert(_list->begin(), _subPath.begin(), _subPath.end());
 #if 0
@@ -202,7 +201,7 @@
 //	1 : Point reachable in a straight line
 //	other values: square distance to target (point not reachable in a straight line)
 //
-uint16 PathBuilder::walkFunc1(int16 x, int16 y, WalkNodePtr Node) {
+uint16 PathBuilder::walkFunc1(int16 x, int16 y, Common::Point& node) {
 
 	Common::Point arg(x, y);
 
@@ -239,9 +238,7 @@
 				v8 = foot;
 			}
 
-			Node->_x = v4.x;
-			Node->_y = v4.y;
-
+			node = v4;
 			return (x - v4.x) * (x - v4.x) + (y - v4.y) * (y - v4.y);
 		}
 
@@ -326,10 +323,10 @@
 	character.getFoot(curPos);
 
 	// update target, if previous was reached
-	WalkNodeList::iterator it = character._walkPath->begin();
+	PointList::iterator it = character._walkPath->begin();
 	if (it != character._walkPath->end()) {
-		if ((*it)->_x == curPos.x && (*it)->_y == curPos.y) {
-			debugC(1, kDebugWalk, "walk reached node (%i, %i)", (*it)->_x, (*it)->_y);
+		if ((*it).x == curPos.x && (*it).y == curPos.y) {
+			debugC(1, kDebugWalk, "walk reached node (%i, %i)", (*it).x, (*it).y);
 			it = character._walkPath->erase(it);
 		}
 	}
@@ -341,11 +338,9 @@
 		finalizeWalk(character);
 		targetPos = curPos;
 	} else {
-		if (*it) {
-			// targetPos is saved to help setting character direction
-			targetPos.x = (*it)->_x;
-			targetPos.y = (*it)->_y;
-		}
+		// targetPos is saved to help setting character direction
+		targetPos.x = (*it).x;
+		targetPos.y = (*it).y;
 
 		Common::Point newPos(curPos);
 		clipMove(newPos, targetPos);
@@ -368,20 +363,7 @@
 }
 
 
-WalkNode::WalkNode() : _x(0), _y(0) {
-}
 
-WalkNode::WalkNode(int16 x, int16 y) : _x(x), _y(y) {
-}
-
-WalkNode::WalkNode(const WalkNode& w) : _x(w._x), _y(w._y) {
-}
-
-void WalkNode::getPoint(Common::Point &p) const {
-	p.x = _x;
-	p.y = _y;
-}
-
 PathBuilder::PathBuilder(AnimationPtr anim) : _anim(anim), _list(0) {
 }
 

Modified: scummvm/trunk/engines/parallaction/walk.h
===================================================================
--- scummvm/trunk/engines/parallaction/walk.h	2008-07-25 12:59:46 UTC (rev 33288)
+++ scummvm/trunk/engines/parallaction/walk.h	2008-07-25 16:01:25 UTC (rev 33289)
@@ -33,36 +33,23 @@
 
 struct Animation;
 
-struct WalkNode {
-	int16	_x;
-	int16	_y;
+typedef Common::List<Common::Point> PointList;
 
-public:
-	WalkNode();
-	WalkNode(int16 x, int16 y);
-	WalkNode(const WalkNode& w);
 
-	void getPoint(Common::Point &p) const;
-};
-
-typedef Common::SharedPtr<WalkNode> WalkNodePtr;
-typedef Common::List<WalkNodePtr> WalkNodeList;
-
-
 class PathBuilder {
 
 	AnimationPtr	_anim;
 
-	WalkNodeList	*_list;
-	WalkNodeList	_subPath;
+	PointList	*_list;
+	PointList	_subPath;
 
 	void correctPathPoint(Common::Point &to);
 	uint32 buildSubPath(const Common::Point& pos, const Common::Point& stop);
-	uint16 walkFunc1(int16 x, int16 y, WalkNodePtr Node);
+	uint16 walkFunc1(int16 x, int16 y, Common::Point& Node);
 
 public:
 	PathBuilder(AnimationPtr anim);
-	WalkNodeList* buildPath(uint16 x, uint16 y);
+	PointList* buildPath(uint16 x, uint16 y);
 
 };
 


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