]> git.mxchange.org Git - flightgear.git/commitdiff
Bugfix in the ai initialization randomization procedure. Randomly
authordurk <durk>
Sun, 26 Mar 2006 21:40:35 +0000 (21:40 +0000)
committerdurk <durk>
Sun, 26 Mar 2006 21:40:35 +0000 (21:40 +0000)
removing waypoints could cause the AIFlightPlan to run out of waypoints.
This patch prevents that by retaining at least two waypoints.

src/AIModel/AIAircraft.cxx
src/AIModel/AIFlightPlanCreate.cxx
src/Airports/groundnetwork.hxx

index 8b54c2bdd7d73512d3cfc851e4e75f3739e1312a..5b347d068c8c77b6dac4f25d38a39f71d73cd29d 100644 (file)
@@ -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;
index 296a5920cae4f9b8ceb56c49c10ade29b84dbe92..9a2b81561fb7434a1c4c7b5863ed1e009c6a2253 100644 (file)
@@ -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);
              }
index 2d779b5b86272e635bfd7e0fb7b62dac4deb8620..c7a8b215f51501fe9ea937d12d06c671d631ea75 100644 (file)
@@ -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;