]> git.mxchange.org Git - flightgear.git/commitdiff
Use a real function to wrap isfinite differences.
authorJames Turner <zakalawe@mac.com>
Sun, 22 Dec 2013 11:18:48 +0000 (11:18 +0000)
committerJames Turner <zakalawe@mac.com>
Sun, 22 Dec 2013 11:18:48 +0000 (11:18 +0000)
Don't worry about compiler ability to inline the macro for the moment;
use a real function to ensure lookup is stable on different compilers.

src/AIModel/AIAircraft.cxx
src/AIModel/AIShip.cxx

index 39642d76ed1bba72a5911336caa7116b985923ab..f05a5891774686baaec485c2de71e62fdbe27c05 100644 (file)
 #include <simgear/structure/exception.hxx>
 
 #include <string>
-#include <math.h>
-#include <time.h>
-
-#ifdef _MSC_VER
-#  include <float.h>
-#  define isfinite(x) _finite(x)
-#else
-#  define isfinite(x) std::isfinite(x)
-#endif
+#include <cmath>
+#include <ctime>
 
+// defined in AIShip.cxx
+extern double fgIsFinite(double x);
 
 #include "AIAircraft.hxx"
 #include "performancedata.hxx"
@@ -945,7 +940,7 @@ void FGAIAircraft::controlHeading(FGAIWaypoint* curr) {
         SG_NORMALIZE_RANGE(calc_bearing, 0.0, 360.0);
     }
 
-    if (isfinite(calc_bearing)) {
+    if (fgIsFinite(calc_bearing)) {
         double hdg_error = calc_bearing - tgt_heading;
         if (fabs(hdg_error) > 0.01) {
             TurnTo( calc_bearing );
index 5d94dd28402570ceb8e80d5634c23ef8beb719bf..d82c3963db4b708a5e0097f3f5a0d50a82d1e5fc 100644 (file)
 #  include <config.h>
 #endif
 
+#include <cmath>
+
 #ifdef _MSC_VER
 #  include <float.h>
-#  define isfinite(x) _finite(x)
+    double fgIsFinite(double x) { return _finite(x); }
 #else
-#  define isfinite(x) std::isfinite(x)
+    double fgIsFinite(double x) { return std::isfinite(x); }
 #endif
 
-#include <math.h>
-
 #include <simgear/sg_inlines.h>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/timing/sg_time.hxx>
@@ -792,7 +792,7 @@ void FGAIShip::ProcessFlightPlan(double dt) {
     //   now revise the required course for the next way point
     _course = getCourse(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr->getLatitude(), curr->getLongitude());
 
-    if (isfinite(_course))
+    if (fgIsFinite(_course))
         TurnTo(_course);
     else
         SG_LOG(SG_AI, SG_ALERT, "AIShip: Bearing or Range is not a finite number");