1
0
Fork 0

Use a real function to wrap isfinite differences.

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.
This commit is contained in:
James Turner 2013-12-22 11:18:48 +00:00
parent 43358a2418
commit 0940a33907
2 changed files with 10 additions and 15 deletions

View file

@ -33,16 +33,11 @@
#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 );

View file

@ -21,15 +21,15 @@
# 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");