1
0
Fork 0

Don't call "exit" when reporting an error.

Add some more guards for missing way points.
Comment out some unused variables.
This commit is contained in:
ThorstenB 2012-04-12 19:38:32 +02:00
parent 4348f17b8c
commit ffe7149b81
4 changed files with 28 additions and 20 deletions

View file

@ -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
}
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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 {