aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2012-08-21 03:28:34 +0300
committerFilippos Karapetis2012-08-21 03:32:18 +0300
commit9568b78babdbdf350fd6c47b261c3f21902c31fc (patch)
treee98f4251170498deb390a5d6535010a6b90c3b3c /engines/sci
parent5df8c99768205ad6e2380dbc7cbc838e4ab5cc85 (diff)
downloadscummvm-rg350-9568b78babdbdf350fd6c47b261c3f21902c31fc.tar.gz
scummvm-rg350-9568b78babdbdf350fd6c47b261c3f21902c31fc.tar.bz2
scummvm-rg350-9568b78babdbdf350fd6c47b261c3f21902c31fc.zip
SCI: Use a simpler atan implementation for kGetAngle in SCI1 and newer games
SCI1 games (QFG2 and newer) use a simpler and more accurate atan implementation for kGetAngle. This properly fixes bug #3540976.
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kmath.cpp25
1 files changed, 4 insertions, 21 deletions
diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp
index a643fbe37a..4b8fadbb84 100644
--- a/engines/sci/engine/kmath.cpp
+++ b/engines/sci/engine/kmath.cpp
@@ -84,27 +84,10 @@ reg_t kSqrt(EngineState *s, int argc, reg_t *argv) {
* accurate.
*/
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 custom implementation of atan().
- // The differences in the return values are the cause of bug #3540976
- // and perhaps bug #3037267 as well.
- // The results of this function match the expected results of SCI0, but not
- // SCI1 (hence the bug in Longbow). We need to find the point in history
- // when this function was changed.
-
- // 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 (int16)(360 - atan2((double)(x1 - x2), (double)(y1 - y2)) * 57.2958) % 360;
-#endif
+ // SCI1 games (QFG2 and newer) use a simple atan implementation. SCI0 games
+ // use a somewhat less accurate calculation (below).
+ if (getSciVersion() >= SCI_VERSION_1_EGA_ONLY)
+ return (int16)(360 - atan2((double)(x1 - x2), (double)(y1 - y2)) * 57.2958) % 360;
int16 xRel = x2 - x1;
int16 yRel = y1 - y2; // y-axis is mirrored.