From: ThorstenB Date: Thu, 12 Apr 2012 17:38:32 +0000 (+0200) Subject: Don't call "exit" when reporting an error. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ffe7149b81a71ff9cc508035d08e43d56080f866;p=flightgear.git Don't call "exit" when reporting an error. Add some more guards for missing way points. Comment out some unused variables. --- diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index eea17d927..408dfb4a1 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -275,6 +275,12 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) { curr = fp->getCurrentWaypoint(); next = fp->getNextWaypoint(); } + if (!curr) + { + // Oops! FIXME + return; + } + if (! leadPointReached(curr)) { controlHeading(curr); controlSpeed(curr, next); @@ -929,9 +935,9 @@ void FGAIAircraft::controlHeading(FGAIWaypoint* curr) { cerr << "calc_bearing is not a finite number : " << "Speed " << speed << "pos : " << pos.getLatitudeDeg() << ", " << pos.getLongitudeDeg() - << "waypoint " << curr->getLatitude() << ", " << curr->getLongitude() << endl; - cerr << "waypoint name " << curr->getName(); - exit(1); // FIXME + << ", waypoint: " << curr->getLatitude() << ", " << curr->getLongitude() << endl; + cerr << "waypoint name: '" << curr->getName() << "'" << endl; + //exit(1); // FIXME } } diff --git a/src/AIModel/AIFlightPlan.cxx b/src/AIModel/AIFlightPlan.cxx index e552f05e0..1e03b8835 100644 --- a/src/AIModel/AIFlightPlan.cxx +++ b/src/AIModel/AIFlightPlan.cxx @@ -279,6 +279,8 @@ FGAIWaypoint* const FGAIFlightPlan::getPreviousWaypoint( void ) const FGAIWaypoint* const FGAIFlightPlan::getCurrentWaypoint( void ) const { + if (wpt_iterator == waypoints.end()) + return 0; return *wpt_iterator; } diff --git a/src/AIModel/AIFlightPlanCreate.cxx b/src/AIModel/AIFlightPlanCreate.cxx index 2753dc11e..63ae6f500 100644 --- a/src/AIModel/AIFlightPlanCreate.cxx +++ b/src/AIModel/AIFlightPlanCreate.cxx @@ -650,11 +650,11 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt, //cerr << "Distance : " << distance << endl; //cerr << "Azimuth : " << azimuth << endl; //cerr << "Initial Lateral point: " << lateralOffset << endl; - double lat = refPoint.getLatitudeDeg(); - double lon = refPoint.getLongitudeDeg(); +// double lat = refPoint.getLatitudeDeg(); +// double lon = refPoint.getLongitudeDeg(); //cerr << "Reference point (" << lat << ", " << lon << ")." << endl; - lat = initialTarget.getLatitudeDeg(); - lon = initialTarget.getLongitudeDeg(); +// lat = initialTarget.getLatitudeDeg(); +// lon = initialTarget.getLongitudeDeg(); //cerr << "Initial Target point (" << lat << ", " << lon << ")." << endl; double ratio = initialTurnRadius / distance; @@ -723,8 +723,8 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt, azimuth = SGGeodesy::courseDeg(origin, secondaryTarget); - lat = secondaryTarget.getLatitudeDeg(); - lon = secondaryTarget.getLongitudeDeg(); +// lat = secondaryTarget.getLatitudeDeg(); +// lon = secondaryTarget.getLongitudeDeg(); //cerr << "Secondary Target point (" << lat << ", " << lon << ")." << endl; //cerr << "Distance : " << distance << endl; //cerr << "Azimuth : " << azimuth << endl; @@ -748,8 +748,8 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt, SGGeodesy::direct(origin, azimuth, newDistance, tertiaryTarget, dummyAz2); - lat = tertiaryTarget.getLatitudeDeg(); - lon = tertiaryTarget.getLongitudeDeg(); +// lat = tertiaryTarget.getLatitudeDeg(); +// lon = tertiaryTarget.getLongitudeDeg(); //cerr << "tertiary Target point (" << lat << ", " << lon << ")." << endl; diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index 3727fc601..47cb34769 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -893,7 +893,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat, TrafficVectorIterator current, closest, closestOnNetwork; TrafficVectorIterator i = activeTraffic.begin(); bool otherReasonToSlowDown = false; - bool previousInstruction; +// bool previousInstruction; if (activeTraffic.size()) { //while ((i->getId() != id) && (i != activeTraffic.end())) while (i != activeTraffic.end()) { @@ -912,10 +912,10 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat, current = i; //closest = current; - previousInstruction = current->getSpeedAdjustment(); +// previousInstruction = current->getSpeedAdjustment(); double mindist = HUGE_VAL; if (activeTraffic.size()) { - double course, dist, bearing, minbearing, az2; + double course, dist, bearing, az2; // minbearing, SGGeod curr(SGGeod::fromDegM(lon, lat, alt)); //TrafficVector iterator closest; closest = current; @@ -937,7 +937,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat, mindist = dist; closest = i; closestOnNetwork = i; - minbearing = bearing; +// minbearing = bearing; } } @@ -961,7 +961,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat, // << endl; mindist = dist; closest = i; - minbearing = bearing; +// minbearing = bearing; otherReasonToSlowDown = true; } } @@ -1359,7 +1359,7 @@ void FGGroundNetwork::render(bool visible) group = new osg::Group; FGScenery * local_scenery = globals->get_scenery(); // double elevation_meters = 0.0; - double elevation_feet = 0.0; +// double elevation_feet = 0.0; time_t now = time(NULL) + fgGetLong("/sim/time/warp"); //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) { //double dx = 0; @@ -1399,7 +1399,7 @@ void FGGroundNetwork::render(bool visible) SGGeod center2 = end; center2.setElevationM(SG_MAX_ELEVATION_M); if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) { - elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5; +// elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5; //elevation_meters += 0.5; } else { @@ -1459,7 +1459,7 @@ void FGGroundNetwork::render(bool visible) SGGeod center2 = segments[k]->getStart()->getGeod(); center2.setElevationM(SG_MAX_ELEVATION_M); if (local_scenery->get_elevation_m( center2, elevationStart, NULL )) { - elevation_feet = elevationStart * SG_METER_TO_FEET + 0.5; +// elevation_feet = elevationStart * SG_METER_TO_FEET + 0.5; //elevation_meters += 0.5; } else { @@ -1471,7 +1471,7 @@ void FGGroundNetwork::render(bool visible) SGGeod center2 = segments[k]->getEnd()->getGeod(); center2.setElevationM(SG_MAX_ELEVATION_M); if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) { - elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5; +// elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5; //elevation_meters += 0.5; } else {