diff options
author | Andrew Kurushin | 2005-01-06 14:32:14 +0000 |
---|---|---|
committer | Andrew Kurushin | 2005-01-06 14:32:14 +0000 |
commit | c9ce4667206b3349117f08570eb97a79035b9441 (patch) | |
tree | 00b19d3de25720e3b8649cdde2a5b7d28ab90920 /saga | |
parent | b62ae808c8236ca657844aa71bddb5fb9e1a4288 (diff) | |
download | scummvm-rg350-c9ce4667206b3349117f08570eb97a79035b9441.tar.gz scummvm-rg350-c9ce4667206b3349117f08570eb97a79035b9441.tar.bz2 scummvm-rg350-c9ce4667206b3349117f08570eb97a79035b9441.zip |
some actor walking fixes
svn-id: r16445
Diffstat (limited to 'saga')
-rw-r--r-- | saga/actor.cpp | 48 | ||||
-rw-r--r-- | saga/scene.cpp | 2 |
2 files changed, 32 insertions, 18 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index 3cd2414dfd..a562ea4088 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -65,7 +65,7 @@ int actorDirectectionsLUT[8] = { ACTOR_DIRECTION_LEFT, // kDirUpLeft }; -PathDirectionData pathDirectionLUT[8][4] = { +PathDirectionData pathDirectionLUT[8][3] = { {{0, 0, -1}, {7, -1, -1}, {4, 1, -1}}, {{1, 1, 0}, {4, 1, -1}, {5, 1, 1}}, {{2, 0, 1}, {5, 1, 1}, {6, -1, 1}}, @@ -1141,8 +1141,8 @@ bool Actor::actorWalkTo(uint16 actorId, const ActorLocation &toLocation) { anotherActorScreenPosition = anotherActor->screenPosition; - testBox.left = (anotherActorScreenPosition.x - collision.x) & ~1; - testBox.right = (anotherActorScreenPosition.x + collision.x) & ~1; + testBox.left = anotherActorScreenPosition.x - collision.x; + testBox.right = anotherActorScreenPosition.x + collision.x; testBox.top = anotherActorScreenPosition.y - collision.y; testBox.bottom = anotherActorScreenPosition.y + collision.y; testBox2 = testBox; @@ -1320,7 +1320,7 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point actor->addWalkStepPoint(toPoint); return; } - + for (iteratorPoint.y = 0; iteratorPoint.y < _yCellCount; iteratorPoint.y++) { for (iteratorPoint.x = 0; iteratorPoint.x < _xCellCount; iteratorPoint.x++) { maskType = _vm->_scene->getBGMaskType(iteratorPoint); @@ -1328,7 +1328,7 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point setPathCell(iteratorPoint, cellValue); } } - + for (i = 0; i < _barrierCount; i++) { intersect.left = MAX(_pathRect.left, _barrierList[i].left); intersect.top = MAX(_pathRect.top, _barrierList[i].top); @@ -1354,6 +1354,29 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point i = fillPathArray(fromPoint, toPoint, bestPoint); +#if 0 + { + Point iteratorPoint; + int cellValue; + FILE *fp = fopen("d:\\FINDPATH.DAT", "w"); + char c; + + fprintf(fp, "from = (%d,%d)\n", fromPoint.x, fromPoint.y); + fprintf(fp, "to = (%d,%d)\n", toPoint.x, toPoint.y); + fprintf(fp, "bestPoint = (%d,%d)\n", bestPoint.x, bestPoint.y); + + for (iteratorPoint.y = 0; iteratorPoint.y < _yCellCount; iteratorPoint.y++) { + for (iteratorPoint.x = 0; iteratorPoint.x < _xCellCount; iteratorPoint.x++) { + cellValue = getPathCell(iteratorPoint); + c = (cellValue < 0) ? ' ' : (cellValue == kPathCellBarrier) ? kPathCellBarrier : (cellValue < 8) ? "^>v<?jLP"[cellValue] : '.'; + putc(c, fp); + } + putc('\n', fp); + } + fclose(fp); + } +#endif + if (fromPoint == bestPoint) { actor->addWalkStepPoint(bestPoint); return; @@ -1449,7 +1472,7 @@ int Actor::fillPathArray(const Point &fromPoint, const Point &toPoint, Point &be do { pathDirection = pathDirectionIterator.operator->(); - for (directionCount = 0; directionCount < 4; directionCount++) { + for (directionCount = 0; directionCount < 3; directionCount++) { samplePathDirection = &pathDirectionLUT[pathDirection->direction][directionCount]; Point nextPoint; nextPoint.x = samplePathDirection->x + pathDirection->x; @@ -1465,8 +1488,7 @@ int Actor::fillPathArray(const Point &fromPoint, const Point &toPoint, Point &be pathDirection->direction = samplePathDirection->direction; ++pointCounter; if (nextPoint == toPoint) { - bestPoint.x = toPoint.x & ~1; - bestPoint.y = toPoint.y; + bestPoint = toPoint; return pointCounter; } currentRating = quickDistance(nextPoint, toPoint); @@ -1490,14 +1512,6 @@ void Actor::setActorPath(ActorData *actor, const Point &fromPoint, const Point & PathNode *node; int i, last; -/* pathFromPoint.x = fromPoint.x >> 1; - pathFromPoint.y = fromPoint.y - _vm->getPathYOffset(); - - pathToPoint.x = toPoint.x >> 1; - pathToPoint.y = toPoint.y - _vm->getPathYOffset();*/ - - - _pathList[0] = toPoint; nextPoint = toPoint; _pathListIndex = 0; @@ -1511,7 +1525,7 @@ void Actor::setActorPath(ActorData *actor, const Point &fromPoint, const Point & point++; direction = getPathCell(nextPoint); if ((direction < 0) || (direction > 8)) { - error("Actor::setActorPath error direction"); + error("Actor::setActorPath error direction 0x%X", direction); } nextPoint.x -= pathDirectionLUT2[direction][0]; nextPoint.y -= pathDirectionLUT2[direction][1]; diff --git a/saga/scene.cpp b/saga/scene.cpp index 9ce05c4da8..00849c894c 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -368,7 +368,7 @@ int Scene::getBGMaskType(const Point &testPoint) { if (!_bgMask.loaded) { return 0; } - offset = testPoint.x + testPoint.y * _vm->getDisplayWidth(); + offset = testPoint.x + testPoint.y * _bgMask.w; if (offset >= _bgMask.buf_len) { error("Scene::getBGMaskType offset 0x%X exceed bufferLength 0x%X", offset, _bgMask.buf_len); } |