diff options
author | Filippos Karapetis | 2019-07-14 14:28:40 +0300 |
---|---|---|
committer | Filippos Karapetis | 2019-07-14 14:28:40 +0300 |
commit | 71a9def71e8cd73dd4c93fd4f2bc0a096e0a79fb (patch) | |
tree | 87d93b580c666cac9532657b6268896c1228ca89 /engines | |
parent | 212cd5aa7864db1d805b4ef9b1736578a3e25b37 (diff) | |
download | scummvm-rg350-71a9def71e8cd73dd4c93fd4f2bc0a096e0a79fb.tar.gz scummvm-rg350-71a9def71e8cd73dd4c93fd4f2bc0a096e0a79fb.tar.bz2 scummvm-rg350-71a9def71e8cd73dd4c93fd4f2bc0a096e0a79fb.zip |
WINTERMUTE: Add a warning for off-by-one errors in normalizeAngle()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wintermute/utils/utils.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 5afb940cfc..4fad599a2e 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -44,9 +44,22 @@ void BaseUtils::swap(int *a, int *b) { ////////////////////////////////////////////////////////////////////////// float BaseUtils::normalizeAngle(float angle) { + float origAngle = angle; + + // The original WME engine checked against 360 here, which is an off-by one + // error, as when normalizing an angle, we expect the number to be between 0 + // and 359 (since 360 is 0). This check has been fixed in ScummVM to 359. If + // the resulting angle is negative, it will be corrected in the while loop + // below. while (angle > 359) { angle -= 360; } + + // Report cases where the above off-by-one error might occur + if (origAngle > 360 && angle < 0) { + warning("BaseUtils::normalizeAngle: off-by-one error detected while normalizing angle %f to %f", origAngle, angle); + } + while (angle < 0) { angle += 360; } |