Ticket #5793: saga-pathfind.txt

File saga-pathfind.txt, 1.5 KB (added by eriktorbjorn, 13 years ago)

Proof-of-concept patch against current Git

Line 
1diff --git a/engines/saga/actor_path.cpp b/engines/saga/actor_path.cpp
2index 3e10aba..60f35c7 100644
3--- a/engines/saga/actor_path.cpp
4+++ b/engines/saga/actor_path.cpp
5@@ -23,6 +23,7 @@
6 #include "saga/saga.h"
7
8 #include "saga/actor.h"
9+#include "saga/objectmap.h"
10 #include "saga/scene.h"
11
12 namespace Saga {
13@@ -99,6 +100,18 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point
14 _debugPointsCount = 0;
15 #endif
16
17+ int hitZoneIndex;
18+ const HitZone *hitZone;
19+ bool walkToExit = false;
20+
21+ hitZoneIndex = _vm->_scene->_actionMap->hitTest(toPoint);
22+ if (hitZoneIndex != -1) {
23+ hitZone = _vm->_scene->_actionMap->getHitZone(hitZoneIndex);
24+ if (hitZone->getFlags() & kHitZoneExit) {
25+ walkToExit = true;
26+ }
27+ }
28+
29 actor->_walkStepsCount = 0;
30 if (fromPoint == toPoint) {
31 actor->addWalkStepPoint(toPoint);
32@@ -110,6 +123,15 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point
33 if (_vm->_scene->validBGMaskPoint(iteratorPoint)) {
34 maskType = _vm->_scene->getBGMaskType(iteratorPoint);
35 setPathCell(iteratorPoint, _vm->_scene->getDoorState(maskType) ? kPathCellBarrier : kPathCellEmpty);
36+ if (!walkToExit) {
37+ hitZoneIndex = _vm->_scene->_actionMap->hitTest(iteratorPoint);
38+ if (hitZoneIndex != -1) {
39+ hitZone = _vm->_scene->_actionMap->getHitZone(hitZoneIndex);
40+ if (hitZone->getFlags() & kHitZoneExit) {
41+ setPathCell(iteratorPoint, kPathCellBarrier);
42+ }
43+ }
44+ }
45 } else {
46 setPathCell(iteratorPoint, kPathCellBarrier);
47 }