aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2011-12-08 20:37:54 +0100
committerWillem Jan Palenstijn2011-12-08 20:37:54 +0100
commitcd9a65f34058c838d5ed5900d8cc28e3a9692ecd (patch)
tree88ef0d522bb18e763fc96348579481147b8056d7
parent05fff73c66d70f2f8ce45b6784cf9089b7cd2f71 (diff)
downloadscummvm-rg350-cd9a65f34058c838d5ed5900d8cc28e3a9692ecd.tar.gz
scummvm-rg350-cd9a65f34058c838d5ed5900d8cc28e3a9692ecd.tar.bz2
scummvm-rg350-cd9a65f34058c838d5ed5900d8cc28e3a9692ecd.zip
DREAMWEB: Fix workoutFrames when walking off-screen
This triggered the paranoia asserts.
-rw-r--r--engines/dreamweb/pathfind.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index ee6ced7e4d..bd7412fc7d 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -280,20 +280,16 @@ void DreamBase::workoutFrames() {
byte tmp;
uint16 diffx, diffy;
- // FIXME: Paranoia asserts, to be removed after sufficient play
- // testing has happened. Background: The original code used to add
- // 32 to the four values listed in the asserts below. Which seems
- // nonsensical, as only the differences of the values matter, so the
- // +32 cancels out. Unless there is an overflow somewhere... So we
- // check for that here.
- assert(data.word(kLinestartx) < 0xFFFF - 32);
- assert(data.word(kLineendx) < 0xFFFF - 32);
- assert(data.word(kLinestarty) < 0xFFFF - 32);
- assert(data.word(kLineendy) < 0xFFFF - 32);
+ // We have to use signed arithmetic here because these values can
+ // be slightly negative when walking off-screen
+ int lineStartX = data.word(kLinestartx);
+ int lineStartY = data.word(kLinestarty);
+ int lineEndX = data.word(kLineendx);
+ int lineEndY = data.word(kLineendy);
- diffx = ABS(data.word(kLinestartx) - data.word(kLineendx));
- diffy = ABS(data.word(kLinestarty) - data.word(kLineendy));
+ diffx = ABS(lineStartX -lineEndX);
+ diffy = ABS(lineStartY - lineEndY);
if (diffx < diffy) {
tmp = 2;
@@ -306,9 +302,9 @@ void DreamBase::workoutFrames() {
tmp = 1;
}
- if (data.word(kLinestartx) >= data.word(kLineendx)) {
+ if (lineStartX >= lineEndX) {
// isinleft
- if (data.word(kLinestarty) < data.word(kLineendy)) {
+ if (lineStartY < lineEndY) {
if (tmp != 1)
tmp ^= 2;
tmp += 4;
@@ -318,7 +314,7 @@ void DreamBase::workoutFrames() {
}
} else {
// isinright
- if (data.word(kLinestarty) < data.word(kLineendy)) {
+ if (lineStartY < lineEndY) {
tmp += 2;
} else {
// botright