aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/pathfind.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/dreamweb/pathfind.cpp')
-rw-r--r--engines/dreamweb/pathfind.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index 8d9d9a95bb..4f887db251 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -309,4 +309,45 @@ void DreamBase::workoutFrames() {
data.byte(kTurndirection) = 0;
}
+byte DreamBase::findFirstPath(byte x, byte y) {
+ PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0);
+
+ for (uint8 index = 0; index < 12; index++) {
+ if (paths[index].x1 == 0xff && paths[index].y1 == 0xff)
+ continue; // "nofirst"
+
+ if (x < paths[index].x1 || y < paths[index].y1)
+ continue; // "nofirst"
+
+ if (x >= paths[index].x2 || y >= paths[index].y2)
+ continue; // "nofirst"
+
+ return paths[index].on; // "gotfirst"
+ }
+
+ return 0;
+}
+
+byte DreamBase::findPathOfPoint(byte x, byte y) {
+ PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0);
+
+ for (uint8 index = 0; index < 12; index++) {
+ if (paths[index].on != 0xff)
+ continue; // "flunkedit"
+
+ if (paths[index].x1 == 0xff && paths[index].y1 == 0xff)
+ continue; // "flunkedit"
+
+ if (x < paths[index].x1 || y < paths[index].y1)
+ continue; // "flunkedit"
+
+ if (x >= paths[index].x2 || y >= paths[index].y2)
+ continue; // "flunkedit"
+
+ return index; // "gotvalidpath"
+ }
+
+ return 0xff;
+}
+
} // End of namespace DreamGen