[Scummvm-git-logs] scummvm master -> d6dabdc1aec8b8ca10cdf74df60c48b645882f0f

Strangerke Strangerke at scummvm.org
Tue Jun 8 22:30:28 UTC 2021


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

Summary:
d6dabdc1ae TRECISION: Add a safeguard to avoid a unlikely divide by 0


Commit: d6dabdc1aec8b8ca10cdf74df60c48b645882f0f
    https://github.com/scummvm/scummvm/commit/d6dabdc1aec8b8ca10cdf74df60c48b645882f0f
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2021-06-08T23:30:12+01:00

Commit Message:
TRECISION: Add a safeguard to avoid a unlikely divide by 0

Changed paths:
    engines/trecision/3d.cpp


diff --git a/engines/trecision/3d.cpp b/engines/trecision/3d.cpp
index 433405adb1..83cb76ffca 100644
--- a/engines/trecision/3d.cpp
+++ b/engines/trecision/3d.cpp
@@ -1757,7 +1757,12 @@ void PathFinding3D::buildFramelist() {
 	}
 
 	// how far is it from the destination?
-	float approx = (len - curLen - EPSILON) / (a - 2);
+	int divider = a - 2;
+	if (divider == 0)
+		// Safeguard, should never be useful... but if it is, it'll avoid a divide by 0 error.
+		divider = 1;
+	
+	float approx = (len - curLen - EPSILON) / (float)divider;
 	float theta = 0.0f;
 	// Adjust all the steps so it arrives exactly where clicked
 	for (b = 1; b < a; ++b) {




More information about the Scummvm-git-logs mailing list