diff options
author | Filippos Karapetis | 2009-11-14 17:53:30 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-11-14 17:53:30 +0000 |
commit | b6c46c752ccc5f5239d492c9b668ef89cd606f81 (patch) | |
tree | 198b4eb3152e3b80fbab9d0295fd1e0436227934 /engines/sci/engine/kmovement.cpp | |
parent | 7c73bc2965e7a90e7e7a2de012b66fd321349d31 (diff) | |
download | scummvm-rg350-b6c46c752ccc5f5239d492c9b668ef89cd606f81.tar.gz scummvm-rg350-b6c46c752ccc5f5239d492c9b668ef89cd606f81.tar.bz2 scummvm-rg350-b6c46c752ccc5f5239d492c9b668ef89cd606f81.zip |
Moved getAngle() inside kmovement.cpp, the only place where it's actually used
svn-id: r45903
Diffstat (limited to 'engines/sci/engine/kmovement.cpp')
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 7c8d070d10..935b3de8d4 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -340,7 +340,26 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { } extern void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv); -extern int get_angle(int xrel, int yrel); + +int getAngle(int xrel, int yrel) { + if ((xrel == 0) && (yrel == 0)) + return 0; + else { + int val = (int)(180.0 / PI * atan2((double)xrel, (double) - yrel)); + if (val < 0) + val += 360; + + // Take care of OB1 differences between SSCI and + // FSCI. SCI games sometimes check for equality with + // "round" angles + if (val % 45 == 44) + val++; + else if (val % 45 == 1) + val--; + + return val; + } +} reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { SegManager *segMan = s->_segMan; @@ -396,7 +415,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) { dx = destx - GET_SEL32V(segMan, client, x); dy = desty - GET_SEL32V(segMan, client, y); - angle = get_angle(dx, dy); + angle = getAngle(dx, dy); debugC(2, kDebugLevelBresen, "Movement (%d,%d), angle %d is %sblocked\n", dx, dy, angle, (s->r_acc.offset) ? " " : "not "); |