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.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index 986cdbeb8f..ff2659c235 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -24,10 +24,6 @@
namespace DreamGen {
-// Output of Bresenham
-Common::Point g_lineData[200];
-
-
void DreamGenContext::turnPathOn() {
turnPathOn(al);
}
@@ -105,8 +101,7 @@ void DreamGenContext::setWalk() {
}
void DreamGenContext::autoSetWalk() {
- al = data.byte(kManspath);
- if (data.byte(kFinaldest) == al)
+ if (data.byte(kFinaldest) == data.byte(kManspath))
return;
const RoomPaths *roomsPaths = getRoomsPaths();
checkDest(roomsPaths);
@@ -123,21 +118,19 @@ void DreamGenContext::autoSetWalk() {
data.byte(kLinepointer) = 0;
}
-void DreamGenContext::checkDest(const RoomPaths *roomsPaths) {
+void DreamBase::checkDest(const RoomPaths *roomsPaths) {
const PathSegment *segments = roomsPaths->segments;
- ah = data.byte(kManspath) << 4;
- al = data.byte(kDestination);
+ const uint8 tmp = data.byte(kManspath) << 4;
uint8 destination = data.byte(kDestination);
for (size_t i = 0; i < 24; ++i) {
- dh = segments[i].b0 & 0xf0;
- dl = segments[i].b0 & 0x0f;
- if (ax == dx) {
+ if ((segments[i].b0 & 0xf0) == tmp &&
+ (segments[i].b0 & 0x0f) == data.byte(kDestination)) {
data.byte(kDestination) = segments[i].b1 & 0x0f;
return;
}
- dl = (segments[i].b0 & 0xf0) >> 4;
- dh = (segments[i].b0 & 0x0f) << 4;
- if (ax == dx) {
+
+ if (((segments[i].b0 & 0x0f) << 4) == tmp &&
+ ((segments[i].b0 & 0xf0) >> 4) == data.byte(kDestination)) {
destination = segments[i].b1 & 0x0f;
}
}
@@ -162,7 +155,7 @@ bool DreamGenContext::checkIfPathIsOn(uint8 index) {
void DreamGenContext::bresenhams() {
workoutFrames();
- Common::Point *lineData = &g_lineData[0];
+ Common::Point *lineData = &_lineData[0];
int16 startX = (int16)data.word(kLinestartx);
int16 startY = (int16)data.word(kLinestarty);
int16 endX = (int16)data.word(kLineendx);