aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2007-04-23 17:07:09 +0000
committerNicola Mettifogo2007-04-23 17:07:09 +0000
commit77afb85fcd6e9f92d6ca56623ddcbad4cae0e59a (patch)
tree3c1b108bd7ce5407e5bb3352b43e4a26feedbee1
parent63795bcdad588fcba7525bb2633176e4891c2d53 (diff)
downloadscummvm-rg350-77afb85fcd6e9f92d6ca56623ddcbad4cae0e59a.tar.gz
scummvm-rg350-77afb85fcd6e9f92d6ca56623ddcbad4cae0e59a.tar.bz2
scummvm-rg350-77afb85fcd6e9f92d6ca56623ddcbad4cae0e59a.zip
Fixed walking bug: random nodes aren't inserted in the walk path anymore.
svn-id: r26577
-rw-r--r--engines/parallaction/walk.cpp32
-rw-r--r--engines/parallaction/walk.h8
2 files changed, 27 insertions, 13 deletions
diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp
index a5f9a62ddf..a4f2a312c0 100644
--- a/engines/parallaction/walk.cpp
+++ b/engines/parallaction/walk.cpp
@@ -135,7 +135,15 @@ uint32 PathBuilder::buildSubPath(const Common::Point& pos, const Common::Point&
return v34;
}
+#if 0
+void printNodes(WalkNodeList *list, const char* text) {
+ printf("%s\n-------------------\n", text);
+ for (WalkNodeList::iterator it = list->begin(); it != list->end(); it++)
+ printf("node [%p] (%i, %i)\n", *it, (*it)->_x, (*it)->_y);
+ return;
+}
+#endif
//
// x, y: mouse click (foot) coordinates
//
@@ -163,10 +171,12 @@ WalkNodeList *PathBuilder::buildPath(uint16 x, uint16 y) {
// path is obstructed: look for alternative
_list = new WalkNodeList;
_list->push_back(v48);
+#if 0
+ printNodes(_list, "start");
+#endif
Common::Point stop(v48->_x, v48->_y);
Common::Point pos(_vm->_char._ani._left, _vm->_char._ani._top);
-
uint32 v34 = buildSubPath(pos, stop);
if (v38 != 0 && v34 > v38) {
// no alternative path (gap?)
@@ -175,14 +185,16 @@ WalkNodeList *PathBuilder::buildPath(uint16 x, uint16 y) {
return _list;
}
_list->insert(_list->begin(), _subPath.begin(), _subPath.end());
+#if 0
+ printNodes(_list, "first segment");
+#endif
(*_list->begin())->getPoint(stop);
-
buildSubPath(pos, stop);
_list->insert(_list->begin(), _subPath.begin(), _subPath.end());
-
- for (WalkNodeList::iterator it = _list->begin(); it != _list->end(); it++)
-// printf("node (%i, %i)\n", (*it)->_x, (*it)->_y);
+#if 0
+ printNodes(_list, "complete");
+#endif
delete v44;
return _list;
@@ -325,9 +337,11 @@ void jobWalk(void *parm, Job *j) {
WalkNodeList::iterator it = list->begin();
- if ((*it)->_x == pos.x && (*it)->_y == pos.y) {
- debugC(1, kDebugWalk, "jobWalk moving to next node (%i, %i)", (*it)->_x, (*it)->_y);
- it = list->erase(it);
+ if (it != list->end()) {
+ if ((*it)->_x == pos.x && (*it)->_y == pos.y) {
+ debugC(1, kDebugWalk, "jobWalk reached node (%i, %i)", (*it)->_x, (*it)->_y);
+ it = list->erase(it);
+ }
}
if (it == list->end()) {
debugC(1, kDebugWalk, "jobWalk reached last node");
@@ -425,7 +439,7 @@ void initWalk() {
WalkNode::WalkNode() : _x(0), _y(0) {
}
-WalkNode::WalkNode(int32 x, int32 y) : _x(x), _y(y) {
+WalkNode::WalkNode(int16 x, int16 y) : _x(x), _y(y) {
}
WalkNode::WalkNode(const WalkNode& w) : _x(w._x), _y(w._y) {
diff --git a/engines/parallaction/walk.h b/engines/parallaction/walk.h
index 8b8e189df7..b8c11b7a59 100644
--- a/engines/parallaction/walk.h
+++ b/engines/parallaction/walk.h
@@ -31,12 +31,12 @@ struct Animation;
struct Job;
struct WalkNode {
- int32 _x;
- int32 _y;
+ int16 _x;
+ int16 _y;
public:
WalkNode();
- WalkNode(int32 x, int32 y);
+ WalkNode(int16 x, int16 y);
WalkNode(const WalkNode& w);
void getPoint(Common::Point &p) const;
@@ -56,7 +56,7 @@ class PathBuilder {
Animation *_anim;
WalkNodeList *_list;
- WalkNodeList _subPath;
+ Common::List<WalkNode*> _subPath;
void correctPathPoint(Common::Point &to);
uint32 buildSubPath(const Common::Point& pos, const Common::Point& stop);