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(); curr = fp->getCurrentWaypoint();
next = fp->getNextWaypoint(); next = fp->getNextWaypoint();
} }
if (!curr)
{
// Oops! FIXME
return;
}
if (! leadPointReached(curr)) { if (! leadPointReached(curr)) {
controlHeading(curr); controlHeading(curr);
controlSpeed(curr, next); controlSpeed(curr, next);
@ -929,9 +935,9 @@ void FGAIAircraft::controlHeading(FGAIWaypoint* curr) {
cerr << "calc_bearing is not a finite number : " cerr << "calc_bearing is not a finite number : "
<< "Speed " << speed << "Speed " << speed
<< "pos : " << pos.getLatitudeDeg() << ", " << pos.getLongitudeDeg() << "pos : " << pos.getLatitudeDeg() << ", " << pos.getLongitudeDeg()
<< "waypoint " << curr->getLatitude() << ", " << curr->getLongitude() << endl; << ", waypoint: " << curr->getLatitude() << ", " << curr->getLongitude() << endl;
cerr << "waypoint name " << curr->getName(); cerr << "waypoint name: '" << curr->getName() << "'" << endl;
exit(1); // FIXME //exit(1); // FIXME
} }
} }

View file

@ -279,6 +279,8 @@ FGAIWaypoint* const FGAIFlightPlan::getPreviousWaypoint( void ) const
FGAIWaypoint* const FGAIFlightPlan::getCurrentWaypoint( void ) const FGAIWaypoint* const FGAIFlightPlan::getCurrentWaypoint( void ) const
{ {
if (wpt_iterator == waypoints.end())
return 0;
return *wpt_iterator; return *wpt_iterator;
} }

View file

@ -650,11 +650,11 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
//cerr << "Distance : " << distance << endl; //cerr << "Distance : " << distance << endl;
//cerr << "Azimuth : " << azimuth << endl; //cerr << "Azimuth : " << azimuth << endl;
//cerr << "Initial Lateral point: " << lateralOffset << endl; //cerr << "Initial Lateral point: " << lateralOffset << endl;
double lat = refPoint.getLatitudeDeg(); // double lat = refPoint.getLatitudeDeg();
double lon = refPoint.getLongitudeDeg(); // double lon = refPoint.getLongitudeDeg();
//cerr << "Reference point (" << lat << ", " << lon << ")." << endl; //cerr << "Reference point (" << lat << ", " << lon << ")." << endl;
lat = initialTarget.getLatitudeDeg(); // lat = initialTarget.getLatitudeDeg();
lon = initialTarget.getLongitudeDeg(); // lon = initialTarget.getLongitudeDeg();
//cerr << "Initial Target point (" << lat << ", " << lon << ")." << endl; //cerr << "Initial Target point (" << lat << ", " << lon << ")." << endl;
double ratio = initialTurnRadius / distance; double ratio = initialTurnRadius / distance;
@ -723,8 +723,8 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
azimuth = SGGeodesy::courseDeg(origin, secondaryTarget); azimuth = SGGeodesy::courseDeg(origin, secondaryTarget);
lat = secondaryTarget.getLatitudeDeg(); // lat = secondaryTarget.getLatitudeDeg();
lon = secondaryTarget.getLongitudeDeg(); // lon = secondaryTarget.getLongitudeDeg();
//cerr << "Secondary Target point (" << lat << ", " << lon << ")." << endl; //cerr << "Secondary Target point (" << lat << ", " << lon << ")." << endl;
//cerr << "Distance : " << distance << endl; //cerr << "Distance : " << distance << endl;
//cerr << "Azimuth : " << azimuth << endl; //cerr << "Azimuth : " << azimuth << endl;
@ -748,8 +748,8 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
SGGeodesy::direct(origin, azimuth, SGGeodesy::direct(origin, azimuth,
newDistance, tertiaryTarget, dummyAz2); newDistance, tertiaryTarget, dummyAz2);
lat = tertiaryTarget.getLatitudeDeg(); // lat = tertiaryTarget.getLatitudeDeg();
lon = tertiaryTarget.getLongitudeDeg(); // lon = tertiaryTarget.getLongitudeDeg();
//cerr << "tertiary Target point (" << lat << ", " << lon << ")." << endl; //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 current, closest, closestOnNetwork;
TrafficVectorIterator i = activeTraffic.begin(); TrafficVectorIterator i = activeTraffic.begin();
bool otherReasonToSlowDown = false; bool otherReasonToSlowDown = false;
bool previousInstruction; // bool previousInstruction;
if (activeTraffic.size()) { if (activeTraffic.size()) {
//while ((i->getId() != id) && (i != activeTraffic.end())) //while ((i->getId() != id) && (i != activeTraffic.end()))
while (i != activeTraffic.end()) { while (i != activeTraffic.end()) {
@ -912,10 +912,10 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
current = i; current = i;
//closest = current; //closest = current;
previousInstruction = current->getSpeedAdjustment(); // previousInstruction = current->getSpeedAdjustment();
double mindist = HUGE_VAL; double mindist = HUGE_VAL;
if (activeTraffic.size()) { if (activeTraffic.size()) {
double course, dist, bearing, minbearing, az2; double course, dist, bearing, az2; // minbearing,
SGGeod curr(SGGeod::fromDegM(lon, lat, alt)); SGGeod curr(SGGeod::fromDegM(lon, lat, alt));
//TrafficVector iterator closest; //TrafficVector iterator closest;
closest = current; closest = current;
@ -937,7 +937,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
mindist = dist; mindist = dist;
closest = i; closest = i;
closestOnNetwork = i; closestOnNetwork = i;
minbearing = bearing; // minbearing = bearing;
} }
} }
@ -961,7 +961,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
// << endl; // << endl;
mindist = dist; mindist = dist;
closest = i; closest = i;
minbearing = bearing; // minbearing = bearing;
otherReasonToSlowDown = true; otherReasonToSlowDown = true;
} }
} }
@ -1359,7 +1359,7 @@ void FGGroundNetwork::render(bool visible)
group = new osg::Group; group = new osg::Group;
FGScenery * local_scenery = globals->get_scenery(); FGScenery * local_scenery = globals->get_scenery();
// double elevation_meters = 0.0; // double elevation_meters = 0.0;
double elevation_feet = 0.0; // double elevation_feet = 0.0;
time_t now = time(NULL) + fgGetLong("/sim/time/warp"); time_t now = time(NULL) + fgGetLong("/sim/time/warp");
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) { //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
//double dx = 0; //double dx = 0;
@ -1399,7 +1399,7 @@ void FGGroundNetwork::render(bool visible)
SGGeod center2 = end; SGGeod center2 = end;
center2.setElevationM(SG_MAX_ELEVATION_M); center2.setElevationM(SG_MAX_ELEVATION_M);
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) { 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; //elevation_meters += 0.5;
} }
else { else {
@ -1459,7 +1459,7 @@ void FGGroundNetwork::render(bool visible)
SGGeod center2 = segments[k]->getStart()->getGeod(); SGGeod center2 = segments[k]->getStart()->getGeod();
center2.setElevationM(SG_MAX_ELEVATION_M); center2.setElevationM(SG_MAX_ELEVATION_M);
if (local_scenery->get_elevation_m( center2, elevationStart, NULL )) { 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; //elevation_meters += 0.5;
} }
else { else {
@ -1471,7 +1471,7 @@ void FGGroundNetwork::render(bool visible)
SGGeod center2 = segments[k]->getEnd()->getGeod(); SGGeod center2 = segments[k]->getEnd()->getGeod();
center2.setElevationM(SG_MAX_ELEVATION_M); center2.setElevationM(SG_MAX_ELEVATION_M);
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) { 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; //elevation_meters += 0.5;
} }
else { else {