[Scummvm-git-logs] scummvm master -> 71a9def71e8cd73dd4c93fd4f2bc0a096e0a79fb

bluegr bluegr at gmail.com
Sun Jul 14 13:29:06 CEST 2019


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
212cd5aa78 WINTERMUTE: Fixed normalizeAngle's output range from 0-360 to 0-359
71a9def71e WINTERMUTE: Add a warning for off-by-one errors in normalizeAngle()


Commit: 212cd5aa7864db1d805b4ef9b1736578a3e25b37
    https://github.com/scummvm/scummvm/commit/212cd5aa7864db1d805b4ef9b1736578a3e25b37
Author: kyranet (kyradiscord at gmail.com)
Date: 2019-07-14T13:57:18+03:00

Commit Message:
WINTERMUTE: Fixed normalizeAngle's output range from 0-360 to 0-359

WINTERMUTE: Enhanced BaseUtils::normalizeAngle to run the while if angle is greater than 359.

When normalizing an angle, we expect the number to be between 0 and
359 (since 360 is 0), this changes the util so 360 is transformed to 0.
The case for 359.8 (which this would make it -0.2) is covered by the following
while loop, which will increase it back to 359.8.

Changed paths:
    engines/wintermute/utils/utils.cpp


diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp
index dc6476d..5afb940 100644
--- a/engines/wintermute/utils/utils.cpp
+++ b/engines/wintermute/utils/utils.cpp
@@ -44,7 +44,7 @@ void BaseUtils::swap(int *a, int *b) {
 
 //////////////////////////////////////////////////////////////////////////
 float BaseUtils::normalizeAngle(float angle) {
-	while (angle > 360) {
+	while (angle > 359) {
 		angle -= 360;
 	}
 	while (angle < 0) {


Commit: 71a9def71e8cd73dd4c93fd4f2bc0a096e0a79fb
    https://github.com/scummvm/scummvm/commit/71a9def71e8cd73dd4c93fd4f2bc0a096e0a79fb
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2019-07-14T14:28:40+03:00

Commit Message:
WINTERMUTE: Add a warning for off-by-one errors in normalizeAngle()

Changed paths:
    engines/wintermute/utils/utils.cpp


diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp
index 5afb940..4fad599 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;
 	}





More information about the Scummvm-git-logs mailing list