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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Feb 24 09:42:47 CET 2009


Revision: 38836
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38836&view=rev
Author:   peres001
Date:     2009-02-24 08:42:46 +0000 (Tue, 24 Feb 2009)

Log Message:
-----------
Changed interface to walk code, to better handle the differences between games. Moreover:
* merged PathBuilder_BR into PathWalker_BR
* implemented checkTrap routine for BRA

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/exec_br.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/input.cpp
    scummvm/trunk/engines/parallaction/objects.cpp
    scummvm/trunk/engines/parallaction/objects.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/parser.h
    scummvm/trunk/engines/parallaction/walk.cpp
    scummvm/trunk/engines/parallaction/walk.h

Modified: scummvm/trunk/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_br.cpp	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/exec_br.cpp	2009-02-24 08:42:46 UTC (rev 38836)
@@ -154,7 +154,7 @@
 
 
 DECLARE_COMMAND_OPCODE(move) {
-	_vm->_char.scheduleWalk(_ctxt.cmd->u._move.x, _ctxt.cmd->u._move.y);
+	_vm->scheduleWalk(_ctxt.cmd->u._move.x, _ctxt.cmd->u._move.y);
 	suspend();
 }
 

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2009-02-24 08:42:46 UTC (rev 38836)
@@ -175,7 +175,7 @@
 	int16 x = inst->_opA.getValue();
 	int16 y = inst->_opB.getValue();
 
-	_vm->_char.scheduleWalk(x, y);
+	_vm->scheduleWalk(x, y);
 }
 
 DECLARE_INSTRUCTION_OPCODE(endscript) {
@@ -286,7 +286,7 @@
 
 
 DECLARE_COMMAND_OPCODE(move) {
-	_vm->_char.scheduleWalk(_ctxt.cmd->u._move.x, _ctxt.cmd->u._move.y);
+	_vm->scheduleWalk(_ctxt.cmd->u._move.x, _ctxt.cmd->u._move.y);
 }
 
 

Modified: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/input.cpp	2009-02-24 08:42:46 UTC (rev 38836)
@@ -269,7 +269,7 @@
 void Input::walkTo(const Common::Point &dest) {
 	stopHovering();
 	setArrowCursor();
-	_vm->_char.scheduleWalk(dest.x, dest.y);
+	_vm->scheduleWalk(dest.x, dest.y);
 }
 
 bool Input::translateGameInput() {

Modified: scummvm/trunk/engines/parallaction/objects.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/objects.cpp	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/objects.cpp	2009-02-24 08:42:46 UTC (rev 38836)
@@ -112,6 +112,21 @@
 	_frame = f;
 }
 
+void Animation::getFoot(Common::Point &foot) {
+	Common::Rect rect;
+	gfxobj->getRect(_frame, rect);
+	foot.x = getX() + (rect.left + rect.width() / 2);
+	foot.y = getY() + (rect.top + rect.height());
+}
+
+void Animation::setFoot(const Common::Point &foot) {
+	Common::Rect rect;
+	gfxobj->getRect(_frame, rect);
+
+	setX(foot.x - (rect.left + rect.width() / 2));
+	setY(foot.y - (rect.top + rect.height()));
+}
+
 #define NUM_LOCALS	10
 char	_localNames[NUM_LOCALS][10];
 

Modified: scummvm/trunk/engines/parallaction/objects.h
===================================================================
--- scummvm/trunk/engines/parallaction/objects.h	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/objects.h	2009-02-24 08:42:46 UTC (rev 38836)
@@ -538,6 +538,9 @@
 
 	int16 getF() 			{ return _frame; }
 	void  setF(int16 value);
+
+	void getFoot(Common::Point &foot);
+	void setFoot(const Common::Point &foot);
 };
 
 class Table {

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2009-02-24 08:42:46 UTC (rev 38836)
@@ -38,6 +38,7 @@
 #include "parallaction/debug.h"
 #include "parallaction/saveload.h"
 #include "parallaction/sound.h"
+#include "parallaction/walk.h"
 
 
 
@@ -337,7 +338,7 @@
 
 	_programExec->runScripts(_location._programs.begin(), _location._programs.end());
 	_char._ani->resetZ();
-	_char._walker->walk();
+	updateWalkers();
 	updateZones();
 }
 
@@ -867,23 +868,10 @@
 	_ani->_flags = kFlagsActive | kFlagsNoName | kFlagsCharacter;
 	_ani->_type = kZoneYou;
 	strncpy(_ani->_name, "yourself", ZONENAME_LENGTH);
-
-	// TODO: move creation into Parallaction. Needs to make Character a pointer first.
-	if (_vm->getGameType() == GType_Nippon) {
-		_builder = new PathBuilder_NS(this);
-		_walker = new PathWalker_NS(this);
-	} else {
-		_builder = new PathBuilder_BR(this);
-		_walker = new PathWalker_BR(this);
-	}
 }
 
 Character::~Character() {
-	delete _builder;
-	_builder = 0;
 
-	delete _walker;
-	_walker = 0;
 }
 
 void Character::getFoot(Common::Point &foot) {
@@ -902,28 +890,7 @@
 	_ani->setY(foot.y - (rect.top + rect.height()));
 }
 
-#if 0
-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;
-}
-#endif
-
-void Character::scheduleWalk(int16 x, int16 y) {
-	if ((_ani->_flags & kFlagsRemove) || (_ani->_flags & kFlagsActive) == 0) {
-		return;
-	}
-
-	_builder->buildPath(x, y);
-#if 0
-	dumpPath(_walkPath, _name);
-#endif
-	_engineFlags |= kEngineWalking;
-}
-
-
 void Character::setName(const char *name) {
 	_name.bind(name);
 }

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2009-02-24 08:42:46 UTC (rev 38836)
@@ -40,7 +40,6 @@
 #include "parallaction/parser.h"
 #include "parallaction/objects.h"
 #include "parallaction/disk.h"
-#include "parallaction/walk.h"
 
 #define PATH_LEN	200
 
@@ -122,6 +121,9 @@
 class Input;
 class DialogueManager;
 class MenuInputHelper;
+class PathBuilder_NS;
+class PathWalker_NS;
+class PathWalker_BR;
 
 
 struct Location {
@@ -198,8 +200,6 @@
 	AnimationPtr	_ani;
 	GfxObj			*_head;
 	GfxObj			*_talk;
-	PathBuilder		*_builder;
-	PathWalker		*_walker;
 	PointList		_walkPath;
 
 	Character(Parallaction *vm);
@@ -207,7 +207,6 @@
 
 	void getFoot(Common::Point &foot);
 	void setFoot(const Common::Point &foot);
-	void scheduleWalk(int16 x, int16 y);
 
 protected:
 	CharacterName	_name;
@@ -367,6 +366,8 @@
 	virtual	void callFunction(uint index, void* parm) = 0;
 	virtual void runPendingZones() = 0;
 	virtual void cleanupGame() = 0;
+	virtual void updateWalkers() = 0;
+	virtual void scheduleWalk(int16 x, int16 y) = 0;
 	virtual DialogueManager *createDialogueManager(ZonePtr z) = 0;
 };
 
@@ -383,12 +384,14 @@
 	virtual Common::Error go();
 
 public:
-	virtual void 	parseLocation(const char *filename);
-	virtual void 	changeLocation(char *location);
-	virtual void 	changeCharacter(const char *name);
-	virtual void 	callFunction(uint index, void* parm);
-	virtual void 	runPendingZones();
-	virtual void 	cleanupGame();
+	virtual void parseLocation(const char *filename);
+	virtual void changeLocation(char *location);
+	virtual void changeCharacter(const char *name);
+	virtual void callFunction(uint index, void* parm);
+	virtual void runPendingZones();
+	virtual void cleanupGame();
+	virtual void updateWalkers();
+	virtual void scheduleWalk(int16 x, int16 y);
 
 	virtual DialogueManager *createDialogueManager(ZonePtr z);
 
@@ -429,6 +432,9 @@
 	static const Callable _dosCallables[25];
 	static const Callable _amigaCallables[25];
 
+	PathBuilder_NS		*_builder;
+	PathWalker_NS		*_walker;
+
 	// common callables
 	void _c_play_boogie(void*);
 	void _c_startIntro(void*);
@@ -483,6 +489,8 @@
 	virtual	void callFunction(uint index, void* parm);
 	virtual void runPendingZones();
 	virtual void cleanupGame();
+	virtual void updateWalkers();
+	virtual void scheduleWalk(int16 x, int16 y);
 
 	virtual DialogueManager *createDialogueManager(ZonePtr z);
 
@@ -529,6 +537,8 @@
 	const Callable *_callables;
 	static const Callable _dosCallables[6];
 
+	PathWalker_BR		*_walker;
+
 	// dos callables
 	void _c_blufade(void*);
 	void _c_resetpalette(void*);

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2009-02-24 08:42:46 UTC (rev 38836)
@@ -30,6 +30,7 @@
 #include "parallaction/input.h"
 #include "parallaction/saveload.h"
 #include "parallaction/sound.h"
+#include "parallaction/walk.h"
 
 namespace Parallaction {
 
@@ -84,6 +85,8 @@
 	_programExec = new ProgramExec_br(this);
 	_programExec->init();
 
+	_walker = new PathWalker_BR;
+
 	_part = -1;
 
 	_subtitle[0] = -1;
@@ -104,6 +107,8 @@
 
 	delete _locationParser;
 	delete _programParser;
+
+	delete _walker;
 }
 
 void Parallaction_br::callFunction(uint index, void* parm) {
@@ -392,6 +397,25 @@
 	}
 }
 
+void Parallaction_br::updateWalkers() {
+	_walker->walk();
+}
 
+void Parallaction_br::scheduleWalk(int16 x, int16 y) {
+	AnimationPtr a = _char._ani;
 
+	if ((a->_flags & kFlagsRemove) || (a->_flags & kFlagsActive) == 0) {
+		return;
+	}
+
+	_walker->setCharacterPath(a, x, y);
+#if 0
+	if (_follower && _userEvent) {
+		_walker->setFollowerPath(_follower, x, y);
+	}
+#endif
+	_engineFlags |= kEngineWalking;
+}
+
+
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2009-02-24 08:42:46 UTC (rev 38836)
@@ -31,6 +31,7 @@
 #include "parallaction/input.h"
 #include "parallaction/saveload.h"
 #include "parallaction/sound.h"
+#include "parallaction/walk.h"
 
 
 namespace Parallaction {
@@ -184,6 +185,9 @@
 	_programExec = new ProgramExec_ns(this);
 	_programExec->init();
 
+	_builder = new PathBuilder_NS(&_char);
+	_walker = new PathWalker_NS(&_char);
+
 	_sarcophagusDeltaX = 0;
 	_movingSarcophagus = false;
 	_freeSarcophagusSlotX = INITIAL_FREE_SARCOPHAGUS_SLOT_X;
@@ -211,6 +215,9 @@
 	freeLocation(true);
 
 	_location._animations.remove(_char._ani);
+
+	delete _builder;
+	delete _walker;
 }
 
 
@@ -485,4 +492,20 @@
 	_movingSarcophagus = false;
 }
 
-} // namespace Parallaction
+void Parallaction_ns::updateWalkers() {
+	_walker->walk();
+}
+
+
+void Parallaction_ns::scheduleWalk(int16 x, int16 y) {
+	AnimationPtr a = _char._ani;
+
+	if ((a->_flags & kFlagsRemove) || (a->_flags & kFlagsActive) == 0) {
+		return;
+	}
+
+	_builder->buildPath(x, y);
+	_engineFlags |= kEngineWalking;
+}
+
+}// namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/parser.h	2009-02-24 08:42:46 UTC (rev 38836)
@@ -29,7 +29,6 @@
 #include "common/stream.h"
 #include "common/stack.h"
 #include "parallaction/objects.h"
-#include "parallaction/walk.h"
 
 namespace Parallaction {
 

Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/walk.cpp	2009-02-24 08:42:46 UTC (rev 38836)
@@ -24,6 +24,7 @@
  */
 
 #include "parallaction/parallaction.h"
+#include "parallaction/walk.h"
 
 namespace Parallaction {
 
@@ -343,7 +344,7 @@
 }
 
 
-bool PathBuilder_BR::directPathExists(const Common::Point &from, const Common::Point &to) {
+bool PathWalker_BR::directPathExists(const Common::Point &from, const Common::Point &to) {
 
 	Common::Point copy(from);
 	Common::Point p(copy);
@@ -365,17 +366,37 @@
 	return true;
 }
 
-void PathBuilder_BR::buildPath(uint16 x, uint16 y) {
+void PathWalker_BR::setCharacterPath(AnimationPtr a, uint16 x, uint16 y) {
+	_character._a = a;
+	_ch = _character;
+	buildPath(x, y);
+	_character._active = true;
+}
+
+void PathWalker_BR::setFollowerPath(AnimationPtr a, uint16 x, uint16 y) {
+	_follower._a = a;
+	_ch = _follower;
+	buildPath(x, y);
+	_follower._active = true;
+}
+
+void PathWalker_BR::stopFollower() {
+	_follower._a.reset();
+	_follower._active = false;
+}
+
+
+void PathWalker_BR::buildPath(uint16 x, uint16 y) {
 	Common::Point foot;
-	_ch->getFoot(foot);
+	_ch._a->getFoot(foot);
 
 	debugC(1, kDebugWalk, "buildPath: from (%i, %i) to (%i, %i)", foot.x, foot.y, x, y);
-	_ch->_walkPath.clear();
+	_ch._walkPath.clear();
 
 	// look for easy path first
 	Common::Point dest(x, y);
 	if (directPathExists(foot, dest)) {
-		_ch->_walkPath.push_back(dest);
+		_ch._walkPath.push_back(dest);
 		debugC(3, kDebugWalk, "buildPath: direct path found");
 		return;
 	}
@@ -383,13 +404,13 @@
 	// look for short circuit cases
 	ZonePtr z0 = _vm->hitZone(kZonePath, x, y);
 	if (!z0) {
-		_ch->_walkPath.push_back(dest);
+		_ch._walkPath.push_back(dest);
 		debugC(3, kDebugWalk, "buildPath: corner case 0");
 		return;
 	}
 	ZonePtr z1 = _vm->hitZone(kZonePath, foot.x, foot.y);
 	if (!z1 || z1 == z0) {
-		_ch->_walkPath.push_back(dest);
+		_ch._walkPath.push_back(dest);
 		debugC(3, kDebugWalk, "buildPath: corner case 1");
 		return;
 	}
@@ -398,7 +419,7 @@
 	int id = atoi(z0->_name);
 
 	if (z1->u.path->_lists[id].empty()) {
-		_ch->_walkPath.clear();
+		_ch._walkPath.clear();
 		debugC(3, kDebugWalk, "buildPath: no path");
 		return;
 	}
@@ -406,24 +427,20 @@
 	PointList::iterator b = z1->u.path->_lists[id].begin();
 	PointList::iterator e = z1->u.path->_lists[id].end();
 	for ( ; b != e; b++) {
-		_ch->_walkPath.push_front(*b);
+		_ch._walkPath.push_front(*b);
 	}
-	_ch->_walkPath.push_back(dest);
+	_ch._walkPath.push_back(dest);
 	debugC(3, kDebugWalk, "buildPath: complex path");
-
-	return;
 }
 
-PathBuilder_BR::PathBuilder_BR(Character *ch) : PathBuilder(ch) {
-}
 
 void PathWalker_BR::finalizeWalk() {
 	_engineFlags &= ~kEngineWalking;
-	_first = true;
-	_fieldC = 1;
+	_ch._first = true;
+	_ch._fieldC = 1;
 
 	Common::Point foot;
-	_ch->getFoot(foot);
+	_ch._a->getFoot(foot);
 
 	ZonePtr z = _vm->hitZone(kZoneDoor, foot.x, foot.y);
 	if (z && ((z->_flags & kFlagsClosed) == 0)) {
@@ -454,14 +471,14 @@
 	// a merge between the two Path managers is the right solution
 	if (_engineFlags & FINAL_WALK_FRAME) {	// this flag is set in readInput()
 		_engineFlags &= ~FINAL_WALK_FRAME;
-		_char.ani->_frame = _moveToF; 	// from readInput()...
+		_ch._a->_frame = _moveToF; 	// from readInput()...
 	} else {
-		_char.ani->_frame = _dirFrame;	// from walk()
+		_ch._a->_frame = _dirFrame;	// from walk()
 	}
-	_char.setFoot(foot);
+	_ch._a->setFoot(foot);
 #endif
 
-	_ch->_ani->setF(_dirFrame);	// temporary solution
+	_ch._a->setF(_ch._dirFrame);	// temporary solution
 
 #if 0
 	// TODO: support scrolling ;)
@@ -474,12 +491,52 @@
 	return;
 }
 
-
 void PathWalker_BR::walk() {
 	if ((_engineFlags & kEngineWalking) == 0) {
 		return;
 	}
 
+	bool finalize = doWalk(_character);
+	doWalk(_follower);
+
+	if (finalize) {
+		finalizeWalk();
+	}
+}
+
+void PathWalker_BR::checkTrap(const Common::Point &p) {
+	ZonePtr z = _vm->hitZone(kZoneTrap, p.x, p.y);
+
+	if (z && z != _vm->_zoneTrap) {
+		if (z->_flags & kFlagsIsAnimation) {
+			z->_flags |= kFlagsActing;
+		} else {
+			_vm->setLocationFlags(kFlagsExit);
+			_vm->_cmdExec->run(z->_commands, z);
+			_vm->clearLocationFlags(kFlagsExit);
+		}
+	}
+
+	if (_vm->_zoneTrap && _vm->_zoneTrap != z) {
+		if (_vm->_zoneTrap->_flags & kFlagsIsAnimation) {
+			_vm->_zoneTrap->_flags &= ~kFlagsActing;
+		} else {
+			_vm->setLocationFlags(kFlagsEnter);
+			_vm->_cmdExec->run(_vm->_zoneTrap->_commands, _vm->_zoneTrap);
+			_vm->clearLocationFlags(kFlagsEnter);
+		}
+	}
+
+	_vm->_zoneTrap = z;
+}
+
+bool PathWalker_BR::doWalk(State &s) {
+	if (!s._active) {
+		return false;
+	}
+
+	_ch = s;
+
 #if 0
 	// TODO: support delays in walking. This requires extending Input::walkIo().
 	if (ch._walkDelay > 0) {
@@ -490,118 +547,118 @@
 			Script *script = findScript(_ch._ani->_scriptName);
 			script->_nextCommand = script->firstCommand;
 		}
-		return;
+		return false;
 	}
 #endif
 
-	if (_fieldC == 0) {
-		_ch->_walkPath.erase(_ch->_walkPath.begin());
+	if (_ch._fieldC == 0) {
+		_ch._walkPath.erase(_ch._walkPath.begin());
 
-		if (_ch->_walkPath.empty()) {
-			finalizeWalk();
+		if (_ch._walkPath.empty()) {
 			debugC(3, kDebugWalk, "PathWalker_BR::walk, case 0");
-			return;
+			return true;
 		} else {
 			debugC(3, kDebugWalk, "PathWalker_BR::walk, moving to next node");
 		}
 	}
 
-	_ch->getFoot(_startFoot);
+	_ch._a->getFoot(_ch._startFoot);
 
-	uint scale = _vm->_location.getScale(_startFoot.y);
+	uint scale = _vm->_location.getScale(_ch._startFoot.y);
 	int xStep = (scale * 16) / 100 + 1;
 	int yStep = (scale * 10) / 100 + 1;
 
 	debugC(9, kDebugWalk, "calculated step: (%i, %i)", xStep, yStep);
 
-	_fieldC = 0;
-	_step++;
-	_step %= 8;
+	_ch._fieldC = 0;
+	_ch._step++;
+	_ch._step %= 8;
 
 	int maxX = _vm->_gfx->_backgroundInfo->width;
 	int minX = 0;
 	int maxY = _vm->_gfx->_backgroundInfo->height;
 	int minY = 0;
 
-	int walkFrame = _step;
-	_dirFrame = 0;
-	Common::Point newpos(_startFoot), delta;
+	int walkFrame = _ch._step;
+	_ch._dirFrame = 0;
+	Common::Point newpos(_ch._startFoot), delta;
 
-	Common::Point p(*_ch->_walkPath.begin());
+	Common::Point p(*_ch._walkPath.begin());
 
-	if (_startFoot.y < p.y && _startFoot.y < maxY && IS_PATH_CLEAR(_startFoot.x, yStep + _startFoot.y)) {
-		if (yStep + _startFoot.y <= p.y) {
-			_fieldC = 1;
+	if (_ch._startFoot.y < p.y && _ch._startFoot.y < maxY && IS_PATH_CLEAR(_ch._startFoot.x, yStep + _ch._startFoot.y)) {
+		if (yStep + _ch._startFoot.y <= p.y) {
+			_ch._fieldC = 1;
 			delta.y = yStep;
-			newpos.y = yStep + _startFoot.y;
+			newpos.y = yStep + _ch._startFoot.y;
 		} else {
-			delta.y = p.y - _startFoot.y;
+			delta.y = p.y - _ch._startFoot.y;
 			newpos.y = p.y;
 		}
-		_dirFrame = 9;
+		_ch._dirFrame = 9;
 	} else
-	if (_startFoot.y > p.y && _startFoot.y > minY && IS_PATH_CLEAR(_startFoot.x, _startFoot.y - yStep)) {
-		if (_startFoot.y - yStep >= p.y) {
-			_fieldC = 1;
+	if (_ch._startFoot.y > p.y && _ch._startFoot.y > minY && IS_PATH_CLEAR(_ch._startFoot.x, _ch._startFoot.y - yStep)) {
+		if (_ch._startFoot.y - yStep >= p.y) {
+			_ch._fieldC = 1;
 			delta.y = yStep;
-			newpos.y = _startFoot.y - yStep;
+			newpos.y = _ch._startFoot.y - yStep;
 		} else {
-			delta.y = _startFoot.y - p.y;
+			delta.y = _ch._startFoot.y - p.y;
 			newpos.y = p.y;
 		}
-		_dirFrame = 0;
+		_ch._dirFrame = 0;
 	}
 
-	if (_startFoot.x < p.x && _startFoot.x < maxX && IS_PATH_CLEAR(_startFoot.x + xStep, _startFoot.y)) {
-		if (_startFoot.x + xStep <= p.x) {
-			_fieldC = 1;
+	if (_ch._startFoot.x < p.x && _ch._startFoot.x < maxX && IS_PATH_CLEAR(_ch._startFoot.x + xStep, _ch._startFoot.y)) {
+		if (_ch._startFoot.x + xStep <= p.x) {
+			_ch._fieldC = 1;
 			delta.x = xStep;
-			newpos.x = xStep + _startFoot.x;
+			newpos.x = xStep + _ch._startFoot.x;
 		} else {
-			delta.x = p.x - _startFoot.x;
+			delta.x = p.x - _ch._startFoot.x;
 			newpos.x = p.x;
 		}
 		if (delta.y < delta.x) {
-			_dirFrame = 18;	// right
+			_ch._dirFrame = 18;	// right
 		}
 	} else
-	if (_startFoot.x > p.x && _startFoot.x > minX && IS_PATH_CLEAR(_startFoot.x - xStep, _startFoot.y)) {
-		if (_startFoot.x - xStep >= p.x) {
-			_fieldC = 1;
+	if (_ch._startFoot.x > p.x && _ch._startFoot.x > minX && IS_PATH_CLEAR(_ch._startFoot.x - xStep, _ch._startFoot.y)) {
+		if (_ch._startFoot.x - xStep >= p.x) {
+			_ch._fieldC = 1;
 			delta.x = xStep;
-			newpos.x = _startFoot.x - xStep;
+			newpos.x = _ch._startFoot.x - xStep;
 		} else {
-			delta.x = _startFoot.x - p.x;
+			delta.x = _ch._startFoot.x - p.x;
 			newpos.x = p.x;
 		}
 		if (delta.y < delta.x) {
-			_dirFrame = 27;	// left
+			_ch._dirFrame = 27;	// left
 		}
 	}
 
-	debugC(9, kDebugWalk, "foot (%i, %i) dest (%i, %i) deltas = %i/%i ", _startFoot.x, _startFoot.y, p.x, p.y, delta.x, delta.y);
+	debugC(9, kDebugWalk, "foot (%i, %i) dest (%i, %i) deltas = %i/%i ", _ch._startFoot.x, _ch._startFoot.y, p.x, p.y, delta.x, delta.y);
 
-	if (_fieldC) {
-		debugC(9, kDebugWalk, "PathWalker_BR::walk, foot moved from (%i, %i) to (%i, %i)", _startFoot.x, _startFoot.y, newpos.x, newpos.y);
-		_ch->_ani->setF(walkFrame + _dirFrame + 1);
-		_startFoot.x = newpos.x;
-		_startFoot.y = newpos.y;
-		_ch->setFoot(_startFoot);
-		_ch->_ani->setZ(newpos.y);
+	if (_ch._fieldC) {
+		debugC(9, kDebugWalk, "PathWalker_BR::walk, foot moved from (%i, %i) to (%i, %i)", _ch._startFoot.x, _ch._startFoot.y, newpos.x, newpos.y);
+		_ch._a->setF(walkFrame + _ch._dirFrame + 1);
+		_ch._startFoot.x = newpos.x;
+		_ch._startFoot.y = newpos.y;
+		_ch._a->setFoot(_ch._startFoot);
+		_ch._a->setZ(newpos.y);
 	}
 
-	if (_fieldC || !_ch->_walkPath.empty()) {
-//		checkTrap();
+	if (_ch._fieldC || !_ch._walkPath.empty()) {
+		Common::Point p;
+		_ch._a->getFoot(p);
+		checkTrap(p);
 		debugC(3, kDebugWalk, "PathWalker_BR::walk, case 1");
-		return;
+		return false;
 	}
 
 	debugC(3, kDebugWalk, "PathWalker_BR::walk, case 2");
-	finalizeWalk();
-	return;
+	return true;
 }
 
-PathWalker_BR::PathWalker_BR(Character *ch) : PathWalker(ch), _fieldC(1), _first(true) {
+PathWalker_BR::PathWalker_BR() : _ch(_character) {
 
 }
 

Modified: scummvm/trunk/engines/parallaction/walk.h
===================================================================
--- scummvm/trunk/engines/parallaction/walk.h	2009-02-24 06:00:10 UTC (rev 38835)
+++ scummvm/trunk/engines/parallaction/walk.h	2009-02-24 08:42:46 UTC (rev 38836)
@@ -48,7 +48,17 @@
 	virtual void buildPath(uint16 x, uint16 y) = 0;
 };
 
+class PathWalker {
+protected:
+	Character	*_ch;
+public:
+	PathWalker(Character *ch) : _ch(ch) { }
+	virtual ~PathWalker() { }
+	virtual void walk() = 0;
+};
 
+
+
 class PathBuilder_NS : public PathBuilder {
 
 	PointList	_subPath;
@@ -62,25 +72,6 @@
 	void buildPath(uint16 x, uint16 y);
 };
 
-
-class PathBuilder_BR : public PathBuilder {
-
-	bool directPathExists(const Common::Point &from, const Common::Point &to);
-
-public:
-	PathBuilder_BR(Character *ch);
-	void buildPath(uint16 x, uint16 y);
-};
-
-class PathWalker {
-protected:
-	Character	*_ch;
-public:
-	PathWalker(Character *ch) : _ch(ch) { }
-	virtual ~PathWalker() { }
-	virtual void walk() = 0;
-};
-
 class PathWalker_NS : public PathWalker {
 
 
@@ -94,21 +85,39 @@
 };
 
 
-class PathWalker_BR : public PathWalker {
+class PathWalker_BR {
 
+	struct State {
+		bool			_active;
+		AnimationPtr	_a;
+		int				_walkDelay;
+		int				_fieldC;
+		Common::Point 	_startFoot;
+		bool			_first;
+		int				_step;
+		int				_dirFrame;
+		PointList		_walkPath;
+	};
 
-	int			_walkDelay;
-	int			_fieldC;
-	Common::Point _startFoot;
-	bool		_first;
-	int			_step;
+	State _character;
+	State _follower;
 
-	int			_dirFrame;
+	State &_ch;
 
 	void finalizeWalk();
+	bool directPathExists(const Common::Point &from, const Common::Point &to);
+	void buildPath(uint16 x, uint16 y);
+	bool doWalk(State &s);
+	void checkTrap(const Common::Point &p);
 
 public:
-	PathWalker_BR(Character *ch);
+	PathWalker_BR();
+	~PathWalker_BR() { }
+
+	void setCharacterPath(AnimationPtr a, uint16 x, uint16 y);
+	void setFollowerPath(AnimationPtr a, uint16 x, uint16 y);
+	void stopFollower();
+
 	void walk();
 };
 


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