mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 05:32:45 +00:00
WINTERMUTE: Add a warning for off-by-one errors in normalizeAngle()
This commit is contained in:
parent
212cd5aa78
commit
71a9def71e
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user