Ticket #5793: ihnm-pathfinder-workaround.txt

File ihnm-pathfinder-workaround.txt, 2.6 KB (added by eriktorbjorn, 12 years ago)

Workaround patch against current Git

Line 
1diff --git a/engines/saga/actor_path.cpp b/engines/saga/actor_path.cpp
2index 0fb072b..d0f1cf2 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,47 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point
14 _debugPointsCount = 0;
15 #endif
16
17+ // WORKAROUND for bug #3360396. Path finding in IHNM is a bit buggy
18+ // compared to the original, which occasionally leads to the player
19+ // leaving the room instead of interacting with an object. So far, no
20+ // one has figured out how to fix this properly. As a temporary [*]
21+ // solution, we try to fix this on a case-by-case basis.
22+ //
23+ // The workaround is to assume that the player wants to stay in the
24+ // room, unless he or she explicitly clicked on an exit zone.
25+ //
26+ // [*] And there is nothing more permanent than a temporary solution...
27+
28+ bool pathFindingWorkaround = false;
29+
30+ if (_vm->getGameId() == GID_IHNM) {
31+ int chapter = _vm->_scene->currentChapterNumber();
32+ int scene = _vm->_scene->currentSceneNumber();
33+
34+ // Ellen, in the room with the monitors.
35+ if (chapter == 3 && scene == 54)
36+ pathFindingWorkaround = true;
37+
38+ // Nimdok in the recovery room
39+ if (chapter == 4 && scene == 71)
40+ pathFindingWorkaround = true;
41+ }
42+
43+ int hitZoneIndex;
44+ const HitZone *hitZone;
45+ bool restrictToRoom = false;
46+
47+ if (pathFindingWorkaround) {
48+ restrictToRoom = true;
49+ hitZoneIndex = _vm->_scene->_actionMap->hitTest(toPoint);
50+ if (hitZoneIndex != -1) {
51+ hitZone = _vm->_scene->_actionMap->getHitZone(hitZoneIndex);
52+ if (hitZone->getFlags() & kHitZoneExit) {
53+ restrictToRoom = false;
54+ }
55+ }
56+ }
57+
58 actor->_walkStepsCount = 0;
59 if (fromPoint == toPoint) {
60 actor->addWalkStepPoint(toPoint);
61@@ -110,6 +152,15 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point
62 if (_vm->_scene->validBGMaskPoint(iteratorPoint)) {
63 maskType = _vm->_scene->getBGMaskType(iteratorPoint);
64 setPathCell(iteratorPoint, _vm->_scene->getDoorState(maskType) ? kPathCellBarrier : kPathCellEmpty);
65+ if (restrictToRoom) {
66+ hitZoneIndex = _vm->_scene->_actionMap->hitTest(iteratorPoint);
67+ if (hitZoneIndex != -1) {
68+ hitZone = _vm->_scene->_actionMap->getHitZone(hitZoneIndex);
69+ if (hitZone->getFlags() & kHitZoneExit) {
70+ setPathCell(iteratorPoint, kPathCellBarrier);
71+ }
72+ }
73+ }
74 } else {
75 setPathCell(iteratorPoint, kPathCellBarrier);
76 }