[Scummvm-cvs-logs] SF.net SVN: scummvm: [26577] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Mon Apr 23 19:07:10 CEST 2007
Revision: 26577
http://scummvm.svn.sourceforge.net/scummvm/?rev=26577&view=rev
Author: peres001
Date: 2007-04-23 10:07:09 -0700 (Mon, 23 Apr 2007)
Log Message:
-----------
Fixed walking bug: random nodes aren't inserted in the walk path anymore.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/walk.cpp
scummvm/trunk/engines/parallaction/walk.h
Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp 2007-04-23 14:01:20 UTC (rev 26576)
+++ scummvm/trunk/engines/parallaction/walk.cpp 2007-04-23 17:07:09 UTC (rev 26577)
@@ -135,7 +135,15 @@
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 @@
// 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,15 +185,17 @@
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());
+#if 0
+ printNodes(_list, "complete");
+#endif
- for (WalkNodeList::iterator it = _list->begin(); it != _list->end(); it++)
-// printf("node (%i, %i)\n", (*it)->_x, (*it)->_y);
-
delete v44;
return _list;
}
@@ -325,9 +337,11 @@
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 @@
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) {
Modified: scummvm/trunk/engines/parallaction/walk.h
===================================================================
--- scummvm/trunk/engines/parallaction/walk.h 2007-04-23 14:01:20 UTC (rev 26576)
+++ scummvm/trunk/engines/parallaction/walk.h 2007-04-23 17:07:09 UTC (rev 26577)
@@ -31,12 +31,12 @@
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 @@
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);
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