aboutsummaryrefslogtreecommitdiff
path: root/engines/cge/walk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/cge/walk.cpp')
-rw-r--r--engines/cge/walk.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp
index ccbb0e5532..95cc92afd4 100644
--- a/engines/cge/walk.cpp
+++ b/engines/cge/walk.cpp
@@ -57,7 +57,6 @@ Cluster XZ(int x, int y) {
return Cluster(x / kMapGridX, (y - kMapTop) / kMapGridZ);
}
-
Cluster XZ(Couple xy) {
signed char x, y;
xy.split(x, y);
@@ -68,7 +67,6 @@ Walk::Walk(CGEEngine *vm, BitmapPtr *shpl)
: Sprite(vm, shpl), _dir(kDirNone), _tracePtr(-1), _level(0), _target(-1, -1), _findLevel(-1), _vm(vm) {
}
-
void Walk::tick() {
if (_flags._hide)
return;
@@ -76,9 +74,8 @@ void Walk::tick() {
_here = XZ(_x + _w / 2, _y + _h);
if (_dir != kDirNone) {
- Sprite *spr;
_sys->funTouch();
- for (spr = _vga->_showQ->first(); spr; spr = spr->_next) {
+ for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) {
if (distance(spr) < 2) {
if (!spr->_flags._near) {
_vm->feedSnail(spr, kNear);
@@ -103,8 +100,10 @@ void Walk::tick() {
turn(d);
}
}
+
step();
- if ((_dir == kDirWest && _x <= 0) ||
+
+ if ((_dir == kDirWest && _x <= 0) ||
(_dir == kDirEast && _x + _w >= kScrWidth) ||
(_dir == kDirSouth && _y + _w >= kWorldHeight - 2)) {
park();
@@ -115,7 +114,6 @@ void Walk::tick() {
}
}
-
int Walk::distance(Sprite *spr) {
int dx = spr->_x - (_x + _w - kWalkSide);
if (dx < 0)
@@ -136,7 +134,6 @@ int Walk::distance(Sprite *spr) {
return dz - 1;
}
-
void Walk::turn(Dir d) {
Dir dir = (_dir == kDirNone) ? kDirSouth : _dir;
if (d != _dir) {
@@ -145,7 +142,6 @@ void Walk::turn(Dir d) {
}
}
-
void Walk::park() {
if (_time == 0)
_time++;
@@ -157,7 +153,6 @@ void Walk::park() {
}
}
-
void Walk::findWay(Cluster c) {
if (c == _here)
return;
@@ -171,13 +166,13 @@ void Walk::findWay(Cluster c) {
if (find1Way(Cluster(x, z)))
break;
}
+
_tracePtr = (_findLevel > kMaxFindLevel) ? -1 : (_findLevel - 1);
if (_tracePtr < 0)
noWay();
_time = 1;
}
-
void Walk::findWay(Sprite *spr) {
if (!spr || spr == this)
return;
@@ -194,12 +189,10 @@ void Walk::findWay(Sprite *spr) {
: (z - 1))));
}
-
bool Walk::lower(Sprite *spr) {
return (spr->_y > _y + (_h * 3) / 5);
}
-
void Walk::reach(Sprite *spr, int mode) {
if (spr) {
_hero->findWay(spr);
@@ -230,7 +223,6 @@ bool Cluster::chkBar() const {
}
bool Walk::find1Way(Cluster c) {
- Cluster start = c;
const Cluster tab[4] = { Cluster(-1, 0), Cluster(1, 0), Cluster(0, -1), Cluster(0, 1)};
const int tabLen = 4;
@@ -251,6 +243,7 @@ bool Walk::find1Way(Cluster c) {
return false;
// Loop through each direction
+ Cluster start = c;
for (int i = 0; i < tabLen; i++) {
// Reset to starting position
c = start;