From dc2341b643e0ec7537b01354c7e8b23be90c60db Mon Sep 17 00:00:00 2001 From: fredb Date: Sun, 19 Oct 2008 16:22:17 +0000 Subject: [PATCH] Revert to previous revision after an error during last commit --- src/AIModel/AIAircraft.cxx | 8 +++----- src/AIModel/AIAircraft.hxx | 2 +- src/Model/modelmgr.cxx | 34 +++++++++++++++++----------------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 3c1d1e4fb..c9f185bf0 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -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() { diff --git a/src/AIModel/AIAircraft.hxx b/src/AIModel/AIAircraft.hxx index 85fca1040..9722e3556 100644 --- a/src/AIModel/AIAircraft.hxx +++ b/src/AIModel/AIAircraft.hxx @@ -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(); diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 41eaa6cd2..2b547cf02 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -156,23 +156,23 @@ struct UpdateFunctor : public std::unary_function 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 -- 2.39.5