aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/pathfinder.cpp
diff options
context:
space:
mode:
authorEric Fry2018-05-11 21:27:52 +1000
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit7c46d891c6acc414e69c5cf624f45b7b297fe584 (patch)
treedc42fac50ada455f9df19ec698535b08ea6d7840 /engines/illusions/pathfinder.cpp
parent6e09cd7e0899052a927bb65ba13219a4cd53c814 (diff)
downloadscummvm-rg350-7c46d891c6acc414e69c5cf624f45b7b297fe584.tar.gz
scummvm-rg350-7c46d891c6acc414e69c5cf624f45b7b297fe584.tar.bz2
scummvm-rg350-7c46d891c6acc414e69c5cf624f45b7b297fe584.zip
ILLUSIONS: Print walk rectangle point on background to aid in debugging
Comment and rename some code in pathfinder to aid in understanding
Diffstat (limited to 'engines/illusions/pathfinder.cpp')
-rw-r--r--engines/illusions/pathfinder.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/engines/illusions/pathfinder.cpp b/engines/illusions/pathfinder.cpp
index ac4f53df45..1e781e64ea 100644
--- a/engines/illusions/pathfinder.cpp
+++ b/engines/illusions/pathfinder.cpp
@@ -261,12 +261,17 @@ void PathFinder::findDeltaPt(Common::Point pt, Common::Point &outDeltaPt) {
}
}
}
-
-bool PathFinder::testRect(PathLine &line, PathLine &rect) {
+/**
+ * returns true if line is contained within rect.
+ */
+bool PathFinder::isLineWithinRectangle(PathLine &line, PathLine &rect) {
return line.p0.x <= rect.p1.x && line.p1.x >= rect.p0.x &&
line.p0.y <= rect.p1.y && line.p1.y >= rect.p0.y;
}
+/**
+ * flip line coordinates so it starts top left and finishes bottom right
+ */
void PathFinder::swapLine(PathLine &line, PathLine &outLine) {
if (line.p1.x <= line.p0.x) {
outLine.p1.x = line.p0.x;
@@ -289,7 +294,7 @@ int PathFinder::calcLineStatus(PathLine &sourceLine, PathLine &destRect, Common:
swapLine(sourceLine, sourceLine1);
swapLine(destRect, destRect1);
- if (!testRect(sourceLine1, destRect1))
+ if (!isLineWithinRectangle(sourceLine1, destRect1))
return 3;
int sourceDeltaX = sourceLine.p1.x - sourceLine.p0.x;