aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-09-11 23:23:40 +0000
committerMax Horn2003-09-11 23:23:40 +0000
commit0161cd4bb896b626129d35206303905d8d2c414e (patch)
tree791a7e9e71e91c512497a496849ec411fc6457e8 /scumm
parent9e88df9e16bebd907e0f7afe22c09fc56a0696c9 (diff)
downloadscummvm-rg350-0161cd4bb896b626129d35206303905d8d2c414e.tar.gz
scummvm-rg350-0161cd4bb896b626129d35206303905d8d2c414e.tar.bz2
scummvm-rg350-0161cd4bb896b626129d35206303905d8d2c414e.zip
let getObjActToObjActDist round up when dividing the distance by 8 for V1/V2 games. This helps in fixing bug #774529, but might cause regressions...
svn-id: r10184
Diffstat (limited to 'scumm')
-rw-r--r--scumm/object.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/scumm/object.cpp b/scumm/object.cpp
index 0b22bf155a..16b563e6ae 100644
--- a/scumm/object.cpp
+++ b/scumm/object.cpp
@@ -265,8 +265,14 @@ void Scumm::getObjectXYPos(int object, int &x, int &y, int &dir) {
dir = oldDirToNewDir(od.actordir & 3);
}
+static int getDist(int x, int y, int x2, int y2) {
+ int a = ABS(y - y2);
+ int b = ABS(x - x2);
+ return MAX(a, b);
+}
+
int Scumm::getObjActToObjActDist(int a, int b) {
- int x, y, x2, y2;
+ int x, y, x2, y2, dist;
Actor *acta = NULL;
Actor *actb = NULL;
@@ -291,12 +297,13 @@ int Scumm::getObjActToObjActDist(int a, int b) {
y2 = r.y;
}
- y = abs(y - y2);
- x = abs(x - x2);
-
- if (y > x)
- x = y;
- return (_version <= 2) ? x / 8 : x;
+ // Now compute the distance between the two points
+ dist = getDist(x, y, x2, y2);
+ // For V1/V2 games, distances are measured in "charactes" instead of pixels,
+ // so we divide by 8, rounding up.
+ if (_version <= 2)
+ dist = (dist + 7) / 8;
+ return dist;
}
int Scumm::findObject(int x, int y) {
@@ -1292,14 +1299,6 @@ void Scumm::setObjectState(int obj, int state, int x, int y) {
putState(obj, state);
}
-static int getDist(int x, int y, int x2, int y2) {
- int a = abs(y - y2);
- int b = abs(x - x2);
- if (a > b)
- return a;
- return b;
-}
-
int Scumm::getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f) {
int i, j;
int x, y;