aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2012-07-08 12:21:26 +0300
committerFilippos Karapetis2012-07-08 16:15:43 +0300
commit4c43d6d85dc70e1b9b82629f1af1e9a37a136013 (patch)
treebe6b4b55151ba9bed2acc7bf84e1038edd7cafc8 /engines/sci
parent2675311f2512e44dd4c37ba9ac9d449b9f4c2439 (diff)
downloadscummvm-rg350-4c43d6d85dc70e1b9b82629f1af1e9a37a136013.tar.gz
scummvm-rg350-4c43d6d85dc70e1b9b82629f1af1e9a37a136013.tar.bz2
scummvm-rg350-4c43d6d85dc70e1b9b82629f1af1e9a37a136013.zip
SCI: Add a hack in kGetAngleWorker to fix bug #3540976
kGetAngle(Worker) has been implemented based on behavior observed with a test program created with SCI Studio. However, the return values have subtle differences from the original, which uses atan(). This temporary hack will do for now till the implementation of kGetAngle is done again. A simpler atan2-based implementation has also been added for future reference
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kmath.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp
index 7570856dff..cbfe00d3ca 100644
--- a/engines/sci/engine/kmath.cpp
+++ b/engines/sci/engine/kmath.cpp
@@ -78,6 +78,25 @@ reg_t kSqrt(EngineState *s, int argc, reg_t *argv) {
}
uint16 kGetAngleWorker(int16 x1, int16 y1, int16 x2, int16 y2) {
+ // TODO: This has been implemented based on behavior observed with a test
+ // program created with SCI Studio. However, the return values have subtle
+ // differences from the original, which uses atan().
+ // The differences in the return values are the cause of bug #3540976
+ // and perhaps bug #3037267 as well.
+
+ // HACK: Return the expected value for Longbow, scene 150 (bug #3540976).
+ // This is a temporary solution, till the function returns the expected
+ // results.
+ if (g_sci->getGameId() == GID_LONGBOW && g_sci->getEngineState()->currentRoomNumber() == 150) {
+ if (x1 == 207 && y1 == 88 && x2 == 107 && y2 == 184)
+ return 226;
+ }
+
+#if 0
+ // A simpler atan2-based implementation
+ return (360 - atan2((double)(x1 - x2), (double)(y1 - y2)) * 57.2958) % 360;
+#endif
+
int16 xRel = x2 - x1;
int16 yRel = y1 - y2; // y-axis is mirrored.
int16 angle;