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:
parent
b906a06be7
commit
3c738b5cee
3 changed files with 19 additions and 16 deletions
|
@ -704,20 +704,21 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now )
|
|||
dep->getDynamics()->releaseParking(fp->getGate());
|
||||
}
|
||||
// Some debug messages, specific to testing the Logical networks.
|
||||
//if ((arr->getId() == string("EHAM")) && (prev->name == "Center"))
|
||||
// {
|
||||
//
|
||||
// cerr << "Schiphol ground "
|
||||
// << trafficRef->getRegistration() << " "
|
||||
// << trafficRef->getCallSign();
|
||||
// if (trafficRef->getHeavy())
|
||||
// cerr << "Heavy";
|
||||
// cerr << " landed runway "
|
||||
// << fp->getRunway()
|
||||
// << " request taxi to gate "
|
||||
// << arr->getDynamics()->getParkingName(fp->getGate())
|
||||
// << endl;
|
||||
// }
|
||||
if ((arr->getId() == string("EHAM")) && (prev->name == "Center"))
|
||||
{
|
||||
|
||||
cerr << "Schiphol ground "
|
||||
<< trafficRef->getRegistration() << " "
|
||||
<< trafficRef->getCallSign();
|
||||
if (trafficRef->getHeavy())
|
||||
cerr << "Heavy";
|
||||
cerr << ", arriving from " << dep->getName() ;
|
||||
cerr << " landed runway "
|
||||
<< fp->getRunway()
|
||||
<< " request taxi to gate "
|
||||
<< arr->getDynamics()->getParkingName(fp->getGate())
|
||||
<< endl;
|
||||
}
|
||||
if (prev->name == "END")
|
||||
fp->setTime(trafficRef->getDepartureTime());
|
||||
//cerr << "5" << endl;
|
||||
|
|
|
@ -303,7 +303,9 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction,
|
|||
isPushBackPoint = true;
|
||||
int nrWaypoints = route.size();
|
||||
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;
|
||||
route.next(&node);
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
bool next(int *val);
|
||||
|
||||
void first() { currNode = nodes.begin(); };
|
||||
int size() { return nodes.end() - nodes.begin(); };
|
||||
int size() { return nodes.size(); };
|
||||
};
|
||||
|
||||
typedef vector<FGTaxiRoute> TaxiRouteVector;
|
||||
|
|
Loading…
Reference in a new issue