diff options
author | Andrew Kurushin | 2005-01-04 18:54:29 +0000 |
---|---|---|
committer | Andrew Kurushin | 2005-01-04 18:54:29 +0000 |
commit | b514251efe5855fb80d37791f69a7fcbbbcf4390 (patch) | |
tree | ddf75f8fe9662d0179b0b935f025aec3b547afb4 | |
parent | dee9b3bd870843d197678b8f6bc44b46561c5778 (diff) | |
download | scummvm-rg350-b514251efe5855fb80d37791f69a7fcbbbcf4390.tar.gz scummvm-rg350-b514251efe5855fb80d37791f69a7fcbbbcf4390.tar.bz2 scummvm-rg350-b514251efe5855fb80d37791f69a7fcbbbcf4390.zip |
- some walking addition
svn-id: r16426
-rw-r--r-- | saga/actor.cpp | 24 | ||||
-rw-r--r-- | saga/actor.h | 14 | ||||
-rw-r--r-- | saga/scene.cpp | 2 |
3 files changed, 30 insertions, 10 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index 5f14b79a98..d6a9474761 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -151,7 +151,7 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { _pathRect.left = 0; _pathRect.right = _vm->getDisplayWidth(); _pathRect.top = _vm->getPathYOffset(); - _pathRect.bottom = _vm->getStatusYOffset() - _vm->getPathYOffset(); + _pathRect.bottom = _vm->getStatusYOffset(); // Get actor resource file context _actorContext = _vm->getFileContext(GAME_RESOURCEFILE, 0); @@ -1191,6 +1191,10 @@ bool Actor::actorWalkTo(uint16 actorId, const ActorLocation &toLocation) { actor->walkStepIndex = 2; } + if (actor->walkStepsCount == 0) { + actor->walkStepsCount = 2; + } + if (extraEndNode) { actor->walkPath[actor->walkStepsCount - 2] = pointTo.x / (ACTOR_LMULT * 2); actor->walkPath[actor->walkStepsCount - 1] = pointTo.y / ACTOR_LMULT; @@ -1345,14 +1349,15 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point intersect.top = MAX(_pathRect.top, _barrierList[i].top); intersect.right = MIN(_pathRect.right, _barrierList[i].right); intersect.bottom = MIN(_pathRect.bottom, _barrierList[i].bottom); - + + int16 w = intersect.width() >> 1; intersect.left >>= 1; intersect.top -= _vm->getPathYOffset(); - intersect.right >>= 1; + intersect.right = intersect.left + w; intersect.bottom -= _vm->getPathYOffset(); for (iteratorPoint.y = intersect.top; iteratorPoint.y < intersect.bottom; iteratorPoint.y++) { - for (iteratorPoint.x = 0; iteratorPoint.x < _xCellCount; iteratorPoint.x++) { + for (iteratorPoint.x = intersect.left; iteratorPoint.x < intersect.right; iteratorPoint.x++) { setPathCell(iteratorPoint, kPathCellBarrier); } } @@ -1428,8 +1433,11 @@ bool Actor::scanPathLine(const Point &point1, const Point &point2) { iteratorPoint.x = point.x >> 1; iteratorPoint.y = point.y - _vm->getPathYOffset(); - if (getPathCell(iteratorPoint) == kPathCellBarrier) - return false; + if (validPathCellPoint(iteratorPoint)) { + if (getPathCell(iteratorPoint) == kPathCellBarrier) { + return false; + } + } } return true; } @@ -1467,7 +1475,9 @@ int Actor::fillPathArray(const Point &fromPoint, const Point &toPoint, Point &be pathDirection->y = pathFromPoint.y; pathDirection->direction = startDirection; } - setPathCell(pathFromPoint, 0); + if (validPathCellPoint(pathFromPoint)) { + setPathCell(pathFromPoint, 0); + } pathDirectionIterator = pathDirectionList.begin(); diff --git a/saga/actor.h b/saga/actor.h index 0f8313018e..e799635575 100644 --- a/saga/actor.h +++ b/saga/actor.h @@ -157,7 +157,7 @@ struct ActorLocation { } void delta(const ActorLocation &location, ActorLocation &result) { result.x = x - location.x; - result.y = x - location.y; + result.y = y - location.y; result.z = z - location.z; } void add(const ActorLocation &location) { @@ -298,10 +298,20 @@ private: void findActorPath(ActorData *actor, const Point &fromPoint, const Point &toPoint); void handleSpeech(int msec); void handleActions(int msec, bool setup); - void setPathCell(const Point &testPoint, int value) { + bool validPathCellPoint(const Point &testPoint) { + return !((testPoint.x < 0) || (testPoint.x >= _xCellCount) || + (testPoint.y < 0) || (testPoint.y >= _yCellCount)); + } + void setPathCell(const Point &testPoint, int value) { + if (!validPathCellPoint(testPoint)) { + error("Actor::setPathCell wrong point"); + } _pathCell[testPoint.x + testPoint.y * _xCellCount] = value; } int getPathCell(const Point &testPoint) { + if (!validPathCellPoint(testPoint)) { + error("Actor::getPathCell wrong point"); + } return _pathCell[testPoint.x + testPoint.y * _xCellCount]; } bool scanPathLine(const Point &point1, const Point &point2); diff --git a/saga/scene.cpp b/saga/scene.cpp index 9ad1e17e43..1e7722ea3f 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -502,7 +502,7 @@ int Scene::getDoorState(int doorNumber) { } void Scene::initDoorsState() { - memcpy(_sceneDoors, initSceneDoors, SCENE_DOORS_MAX); + memcpy(_sceneDoors, initSceneDoors, sizeof (_sceneDoors) ); } int Scene::getInfo(SCENE_INFO *si) { |