]> git.mxchange.org Git - simgear.git/commitdiff
Fixed a problem that could lead to a 'near infinite' loop if bogus input
authorcurt <curt>
Tue, 12 Feb 2002 15:21:14 +0000 (15:21 +0000)
committercurt <curt>
Tue, 12 Feb 2002 15:21:14 +0000 (15:21 +0000)
values are provided.

simgear/sky/cloud.cxx

index 8a69e3150fca822aef0da067fec832127d0f77a2..47be63501ec27b9b818b8f9d43a27519d6f78a9b 100644 (file)
@@ -204,12 +204,29 @@ bool SGCloudLayer::reposition( sgVec3 p, sgVec3 up, double lon, double lat,
        base = tl->get( 0 );
 
        base[0] += xoff;
        base = tl->get( 0 );
 
        base[0] += xoff;
-       while ( base[0] > 1.0 ) { base[0] -= 1.0; }
-       while ( base[0] < 0.0 ) { base[0] += 1.0; }
+
+       // the while loops can lead to *long* pauses if base[0] comes
+       // with a bogus value.
+        // while ( base[0] > 1.0 ) { base[0] -= 1.0; }
+       // while ( base[0] < 0.0 ) { base[0] += 1.0; }
+        if ( base[0] > -10.0 && base[0] < 10.0 ) {
+            base[0] -= (int)base[0];
+        } else {
+            base[0] = 0.0;
+            cout << "Error: base = " << base[0] << "," << base[1] << endl;
+        }
 
        base[1] += yoff;
 
        base[1] += yoff;
-       while ( base[1] > 1.0 ) { base[1] -= 1.0; }
-       while ( base[1] < 0.0 ) { base[1] += 1.0; }
+       // the while loops can lead to *long* pauses if base[0] comes
+       // with a bogus value.
+       // while ( base[1] > 1.0 ) { base[1] -= 1.0; }
+       // while ( base[1] < 0.0 ) { base[1] += 1.0; }
+        if ( base[1] > -10.0 && base[1] < 10.0 ) {
+            base[1] -= (int)base[1];
+        } else {
+            base[1] = 0.0;
+            cout << "Error: base = " << base[0] << "," << base[1] << endl;
+        }
 
        // cout << "base = " << base[0] << "," << base[1] << endl;
 
 
        // cout << "base = " << base[0] << "," << base[1] << endl;