1
0
Fork 0

Bugfix in the ai initialization randomization procedure. Randomly

removing waypoints could cause the AIFlightPlan to run out of waypoints.
This patch prevents that by retaining at least two waypoints.
This commit is contained in:
durk 2006-03-26 21:40:35 +00:00
parent b906a06be7
commit 3c738b5cee
3 changed files with 19 additions and 16 deletions

View file

@ -704,20 +704,21 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now )
dep->getDynamics()->releaseParking(fp->getGate()); dep->getDynamics()->releaseParking(fp->getGate());
} }
// Some debug messages, specific to testing the Logical networks. // Some debug messages, specific to testing the Logical networks.
//if ((arr->getId() == string("EHAM")) && (prev->name == "Center")) if ((arr->getId() == string("EHAM")) && (prev->name == "Center"))
// { {
//
// cerr << "Schiphol ground " cerr << "Schiphol ground "
// << trafficRef->getRegistration() << " " << trafficRef->getRegistration() << " "
// << trafficRef->getCallSign(); << trafficRef->getCallSign();
// if (trafficRef->getHeavy()) if (trafficRef->getHeavy())
// cerr << "Heavy"; cerr << "Heavy";
// cerr << " landed runway " cerr << ", arriving from " << dep->getName() ;
// << fp->getRunway() cerr << " landed runway "
// << " request taxi to gate " << fp->getRunway()
// << arr->getDynamics()->getParkingName(fp->getGate()) << " request taxi to gate "
// << endl; << arr->getDynamics()->getParkingName(fp->getGate())
// } << endl;
}
if (prev->name == "END") if (prev->name == "END")
fp->setTime(trafficRef->getDepartureTime()); fp->setTime(trafficRef->getDepartureTime());
//cerr << "5" << endl; //cerr << "5" << endl;

View file

@ -303,7 +303,9 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction,
isPushBackPoint = true; isPushBackPoint = true;
int nrWaypoints = route.size(); int nrWaypoints = route.size();
int nrWaypointsToSkip = rand() % nrWaypoints; int nrWaypointsToSkip = rand() % nrWaypoints;
for (int i = 0; i < nrWaypointsToSkip; i++) { // but make sure we always keep two active waypoints
// to prevent a segmentation fault
for (int i = 0; i < nrWaypointsToSkip-2; i++) {
isPushBackPoint = false; isPushBackPoint = false;
route.next(&node); route.next(&node);
} }

View file

@ -124,7 +124,7 @@ public:
bool next(int *val); bool next(int *val);
void first() { currNode = nodes.begin(); }; void first() { currNode = nodes.begin(); };
int size() { return nodes.end() - nodes.begin(); }; int size() { return nodes.size(); };
}; };
typedef vector<FGTaxiRoute> TaxiRouteVector; typedef vector<FGTaxiRoute> TaxiRouteVector;