diff options
author | D G Turner | 2012-07-16 01:24:40 +0100 |
---|---|---|
committer | D G Turner | 2012-07-16 01:24:40 +0100 |
commit | e73dffa57cbe65ffb10af4f2a5b47f644269caab (patch) | |
tree | 191c3e8e2ebdf81dec58d4006a98ca20a688120b /engines/sci/engine/kmath.cpp | |
parent | 9669b73ca811af9672215748e92acb3f77805b75 (diff) | |
parent | 1fffbe40ceb82bec77479c56176abeff0d2bd5e5 (diff) | |
download | scummvm-rg350-e73dffa57cbe65ffb10af4f2a5b47f644269caab.tar.gz scummvm-rg350-e73dffa57cbe65ffb10af4f2a5b47f644269caab.tar.bz2 scummvm-rg350-e73dffa57cbe65ffb10af4f2a5b47f644269caab.zip |
Merge branch 'master' into teenagentRefactor
Conflicts:
engines/teenagent/resources.cpp
Diffstat (limited to 'engines/sci/engine/kmath.cpp')
-rw-r--r-- | engines/sci/engine/kmath.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp index 7570856dff..a643fbe37a 100644 --- a/engines/sci/engine/kmath.cpp +++ b/engines/sci/engine/kmath.cpp @@ -77,7 +77,35 @@ reg_t kSqrt(EngineState *s, int argc, reg_t *argv) { return make_reg(0, (int16) sqrt((float) ABS(argv[0].toSint16()))); } +/** + * Returns the angle (in degrees) between the two points determined by (x1, y1) + * and (x2, y2). The angle ranges from 0 to 359 degrees. + * What this function does is pretty simple but apparently the original is not + * 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 + int16 xRel = x2 - x1; int16 yRel = y1 - y2; // y-axis is mirrored. int16 angle; |