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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sat Jul 26 07:56:40 CEST 2008


Revision: 33298
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33298&view=rev
Author:   peres001
Date:     2008-07-26 05:56:39 +0000 (Sat, 26 Jul 2008)

Log Message:
-----------
More cleanup.

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

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-07-26 05:37:52 UTC (rev 33297)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-07-26 05:56:39 UTC (rev 33298)
@@ -548,8 +548,8 @@
 }
 
 #if 0
-void dumpPath(PointList *list, const char* text) {
-	for (PointList::iterator it = list->begin(); it != list->end(); it++)
+void dumpPath(const PointList &list, const char* text) {
+	for (PointList::iterator it = list.begin(); it != list.end(); it++)
 		printf("node (%i, %i)\n", it->x, it->y);
 
 	return;
@@ -561,7 +561,7 @@
 		return;
 	}
 
-	_walkPath = _builder->buildPath(x, y);
+	_builder->buildPath(x, y);
 #if 0
 	dumpPath(_walkPath, _name);
 #endif
@@ -570,8 +570,7 @@
 		_engineFlags |= kEngineWalking;
 	} else {
 		// BRA can't walk yet!
-		delete _walkPath;
-		_walkPath = 0;
+		_walkPath.clear();
 	}
 }
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-07-26 05:37:52 UTC (rev 33297)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-07-26 05:56:39 UTC (rev 33298)
@@ -199,7 +199,7 @@
 	GfxObj			*_talk;
 	GfxObj			*_objs;
 	PathBuilder		*_builder;
-	PointList		*_walkPath;
+	PointList		_walkPath;
 
 	Character(Parallaction *vm);
 	~Character();

Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp	2008-07-26 05:37:52 UTC (rev 33297)
+++ scummvm/trunk/engines/parallaction/walk.cpp	2008-07-26 05:56:39 UTC (rev 33298)
@@ -148,9 +148,11 @@
 //
 //	x, y: mouse click (foot) coordinates
 //
-PointList *PathBuilder_NS::buildPath(uint16 x, uint16 y) {
+void PathBuilder_NS::buildPath(uint16 x, uint16 y) {
 	debugC(1, kDebugWalk, "PathBuilder::buildPath to (%i, %i)", x, y);
 
+	_ch->_walkPath.clear();
+
 	Common::Point to(x, y);
 	correctPathPoint(to);
 	debugC(1, kDebugWalk, "found closest path point at (%i, %i)", to.x, to.y);
@@ -162,43 +164,32 @@
 	if (v38 == 1) {
 		// destination directly reachable
 		debugC(1, kDebugWalk, "direct move to (%i, %i)", to.x, to.y);
-
-		_list = new PointList;
-		_list->push_back(v48);
-		return _list;
+		_ch->_walkPath.push_back(v48);
+		return;
 	}
 
 	// path is obstructed: look for alternative
-	_list = new PointList;
-	_list->push_back(v48);
+	_ch->_walkPath.push_back(v48);
 #if 0
 	printNodes(_list, "start");
 #endif
 
-	Common::Point stop(v48.x, v48.y);
 	Common::Point pos;
 	_ch->getFoot(pos);
 
-	uint32 v34 = buildSubPath(pos, stop);
+	uint32 v34 = buildSubPath(pos, v48);
 	if (v38 != 0 && v34 > v38) {
 		// no alternative path (gap?)
-		_list->clear();
-		_list->push_back(v44);
-		return _list;
+		_ch->_walkPath.clear();
+		_ch->_walkPath.push_back(v44);
+		return;
 	}
-	_list->insert(_list->begin(), _subPath.begin(), _subPath.end());
-#if 0
-	printNodes(_list, "first segment");
-#endif
+	_ch->_walkPath.insert(_ch->_walkPath.begin(), _subPath.begin(), _subPath.end());
 
-	stop = *_list->begin();
-	buildSubPath(pos, stop);
-	_list->insert(_list->begin(), _subPath.begin(), _subPath.end());
-#if 0
-	printNodes(_list, "complete");
-#endif
+	buildSubPath(pos, *_ch->_walkPath.begin());
+	_ch->_walkPath.insert(_ch->_walkPath.begin(), _subPath.begin(), _subPath.end());
 
-	return _list;
+	return;
 }
 
 
@@ -318,8 +309,7 @@
 	character.getFoot(foot);
 	checkDoor(foot);
 
-	delete character._walkPath;
-	character._walkPath = 0;
+	character._walkPath.clear();
 }
 
 void Parallaction_ns::walk(Character &character) {
@@ -331,17 +321,17 @@
 	character.getFoot(curPos);
 
 	// update target, if previous was reached
-	PointList::iterator it = character._walkPath->begin();
-	if (it != character._walkPath->end()) {
+	PointList::iterator it = character._walkPath.begin();
+	if (it != character._walkPath.end()) {
 		if (*it == curPos) {
 			debugC(1, kDebugWalk, "walk reached node (%i, %i)", (*it).x, (*it).y);
-			it = character._walkPath->erase(it);
+			it = character._walkPath.erase(it);
 		}
 	}
 
 	// advance character towards the target
 	Common::Point targetPos;
-	if (it == character._walkPath->end()) {
+	if (it == character._walkPath.end()) {
 		debugC(1, kDebugWalk, "walk reached last node");
 		finalizeWalk(character);
 		targetPos = curPos;
@@ -397,54 +387,53 @@
 	return true;
 }
 
-PointList* PathBuilder_BR::buildPath(uint16 x, uint16 y) {
+void PathBuilder_BR::buildPath(uint16 x, uint16 y) {
 	Common::Point foot;
 	_ch->getFoot(foot);
 
 	debugC(1, kDebugWalk, "buildPath: from (%i, %i) to (%i, %i)", foot.x, foot.y, x, y);
+	_ch->_walkPath.clear();
 
-	PointList *list = new PointList;
-
 	// look for easy path first
 	Common::Point dest(x, y);
 	if (directPathExists(foot, dest)) {
-		list->push_back(dest);
+		_ch->_walkPath.push_back(dest);
 		debugC(3, kDebugWalk, "buildPath: direct path found");
-		return list;
+		return;
 	}
 
 	// look for short circuit cases
 	ZonePtr z0 = _vm->hitZone(kZonePath, x, y);
 	if (z0 == nullZonePtr) {
-		list->push_back(dest);
+		_ch->_walkPath.push_back(dest);
 		debugC(3, kDebugWalk, "buildPath: corner case 0");
-		return list;
+		return;
 	}
 	ZonePtr z1 = _vm->hitZone(kZonePath, foot.x, foot.y);
 	if (z1 == nullZonePtr || z1 == z0) {
-		list->push_back(dest);
+		_ch->_walkPath.push_back(dest);
 		debugC(3, kDebugWalk, "buildPath: corner case 1");
-		return list;
+		return;
 	}
 
 	// build complex path
 	int id = atoi(z0->_name);
 
 	if (z1->u.path->_lists[id].empty()) {
-		list->clear();
+		_ch->_walkPath.clear();
 		debugC(3, kDebugWalk, "buildPath: no path");
-		return list;
+		return;
 	}
 
 	PointList::iterator b = z1->u.path->_lists[id].begin();
 	PointList::iterator e = z1->u.path->_lists[id].end();
 	for ( ; b != e; b++) {
-		list->push_front(*b);
+		_ch->_walkPath.push_front(*b);
 	}
-	list->push_back(dest);
+	_ch->_walkPath.push_back(dest);
 	debugC(3, kDebugWalk, "buildPath: complex path");
 
-	return list;
+	return;
 }
 
 PathBuilder_BR::PathBuilder_BR(Character *ch) : PathBuilder(ch) {

Modified: scummvm/trunk/engines/parallaction/walk.h
===================================================================
--- scummvm/trunk/engines/parallaction/walk.h	2008-07-26 05:37:52 UTC (rev 33297)
+++ scummvm/trunk/engines/parallaction/walk.h	2008-07-26 05:56:39 UTC (rev 33298)
@@ -45,7 +45,7 @@
 	PathBuilder(Character *ch) : _ch(ch) { }
 	virtual ~PathBuilder() { }
 
-	virtual PointList* buildPath(uint16 x, uint16 y) = 0;
+	virtual void buildPath(uint16 x, uint16 y) = 0;
 };
 
 
@@ -60,7 +60,7 @@
 
 public:
 	PathBuilder_NS(Character *ch);
-	PointList* buildPath(uint16 x, uint16 y);
+	void buildPath(uint16 x, uint16 y);
 };
 
 
@@ -70,7 +70,7 @@
 
 public:
 	PathBuilder_BR(Character *ch);
-	PointList* buildPath(uint16 x, uint16 y);
+	void 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