]> git.mxchange.org Git - flightgear.git/commitdiff
Revert to previous revision after an error during last commit
authorfredb <fredb>
Sun, 19 Oct 2008 16:22:17 +0000 (16:22 +0000)
committerfredb <fredb>
Sun, 19 Oct 2008 16:22:17 +0000 (16:22 +0000)
src/AIModel/AIAircraft.cxx
src/AIModel/AIAircraft.hxx
src/Model/modelmgr.cxx

index 3c1d1e4fb6ef4fef1e29f36acd9100ddcac0dce4..c9f185bf0c60920b8983273692afb369ac5e25e5 100644 (file)
@@ -145,8 +145,7 @@ void FGAIAircraft::setPerformance(const std::string& acclass) {
       FGAIAircraft::dt = dt;
 
      try {
-         if ( !updatePrimaryTargetValues() ) // target hdg, alt, speed
-             return;
+         updatePrimaryTargetValues(); // target hdg, alt, speed
      }
      catch (AI_OutOfSight) {
          return;
@@ -730,7 +729,7 @@ void FGAIAircraft::controlSpeed(FGAIFlightPlan::waypoint* curr, FGAIFlightPlan::
 /**
  * Update target values (heading, alt, speed) depending on flight plan or control properties
  */
-bool FGAIAircraft::updatePrimaryTargetValues() {
+void FGAIAircraft::updatePrimaryTargetValues() {
     if (fp)                      // AI object has a flightplan
     {
         //TODO make this a function of AIBase
@@ -759,7 +758,7 @@ bool FGAIAircraft::updatePrimaryTargetValues() {
         }
         timeElapsed = now - fp->getStartTime();
         if (! fp->isActive(now)) { 
-            return false;
+            throw FP_Inactive();
         }
     } else {
         // no flight plan, update target heading, speed, and altitude
@@ -790,7 +789,6 @@ bool FGAIAircraft::updatePrimaryTargetValues() {
 
         AccelTo( props->getDoubleValue("controls/flight/target-spd" ) );
     }
-    return true;
 }
 
 void FGAIAircraft::updatePosition() {
index 85fca1040733ea902747c7a9d6715516401ef8f6..9722e355693f323c462c381df082360f497fbe93 100644 (file)
@@ -117,7 +117,7 @@ private:
     void controlHeading(FGAIFlightPlan::waypoint* curr);
     void controlSpeed(FGAIFlightPlan::waypoint* curr,
                       FGAIFlightPlan::waypoint* next);
-    bool updatePrimaryTargetValues();
+    void updatePrimaryTargetValues();
     void updateSecondaryTargetValues();
     void updatePosition();
     void updateHeading();
index 41eaa6cd2fe0afde590bd68ce2d6e163e0d99536..2b547cf027486a0cfcefbad6f69f98329ada551c 100644 (file)
@@ -156,23 +156,23 @@ struct UpdateFunctor : public std::unary_function<FGModelMgr::Instance*, void>
         SGModelPlacement* model = instance->model;
         double lon, lat, elev, roll, pitch, heading;
 
-        // Optionally set position from properties
-        if (instance->lon_deg_node != 0)
-            lon =instance->lon_deg_node->getDoubleValue();
-        if (instance->lat_deg_node != 0)
-            lat = instance->lat_deg_node->getDoubleValue();
-        if (instance->elev_ft_node != 0)
-            elev = instance->elev_ft_node->getDoubleValue();
-
-        // Optionally set orientation from properties
-        if (instance->roll_deg_node != 0)
-            roll = instance->roll_deg_node->getDoubleValue();
-        if (instance->pitch_deg_node != 0)
-            pitch = instance->pitch_deg_node->getDoubleValue();
-        if (instance->heading_deg_node != 0)
-            heading = instance->heading_deg_node->getDoubleValue();
-        if ( osg::isNaN(lon) || osg::isNaN(lat) || osg::isNaN(elev) ||
-             osg::isNaN(roll) || osg::isNaN(pitch) || osg::isNaN(heading) ) {
+        try {
+            // Optionally set position from properties
+            if (instance->lon_deg_node != 0)
+                lon = testNan(instance->lon_deg_node->getDoubleValue());
+            if (instance->lat_deg_node != 0)
+                lat = testNan(instance->lat_deg_node->getDoubleValue());
+            if (instance->elev_ft_node != 0)
+                elev = testNan(instance->elev_ft_node->getDoubleValue());
+
+            // Optionally set orientation from properties
+            if (instance->roll_deg_node != 0)
+                roll = testNan(instance->roll_deg_node->getDoubleValue());
+            if (instance->pitch_deg_node != 0)
+                pitch = testNan(instance->pitch_deg_node->getDoubleValue());
+            if (instance->heading_deg_node != 0)
+                heading = testNan(instance->heading_deg_node->getDoubleValue());
+        } catch (const sg_range_exception& e) {
             const char *path = instance->node->getStringValue("path",
                                                               "unknown");
             SG_LOG(SG_GENERAL, SG_INFO, "Instance of model " << path