]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.cxx
- Added ultra-light traffic is now a separate traffic class that can have its
[flightgear.git] / src / Airports / groundnetwork.cxx
index d6cdc68ac6ad0faf6f1dccede458183d8dc78005..9e26374aa52903c069eb10c426f2d0d0308f8f22 100644 (file)
 //#include <Main/fg_props.hxx>
 //#include <Airports/runways.hxx>
 
-
 #include <AIModel/AIFlightPlan.hxx>
 
 //#include STL_STRING
 
 #include "groundnetwork.hxx"
 
-SG_USING_STD(sort);
-
-
-
-/**************************************************************************
- * FGTaxiNode
- *************************************************************************/
-FGTaxiNode::FGTaxiNode()
-{
-}
-
-void FGTaxiNode::sortEndSegments(bool byLength)
-{
-  if (byLength)
-    sort(next.begin(), next.end(), sortByLength);
-  else
-    sort(next.begin(), next.end(), sortByHeadingDiff);
-}
-
-
-bool compare_nodes(FGTaxiNode *a, FGTaxiNode *b) {
-return (*a) < (*b);
-}
-
 /***************************************************************************
  * FGTaxiSegment
  **************************************************************************/
@@ -135,17 +110,7 @@ void FGTaxiSegment::setCourseDiff(double crse)
     headingDiff = fabs(headingDiff - 360);
 }
 
-bool compare_segments(FGTaxiSegment *a, FGTaxiSegment *b) {
-return (*a) < (*b);
-}
-
-bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b) {
-  return a->hasSmallerHeadingDiff(*b);
-}
 
-bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
-  return a->getLength() > b->getLength();
-}
 /***************************************************************************
  * FGTaxiRoute
  **************************************************************************/
@@ -225,6 +190,13 @@ void FGTaxiRoute::rewind(int route)
 /***************************************************************************
  * FGGroundNetwork()
  **************************************************************************/
+bool compare_nodes(FGTaxiNode *a, FGTaxiNode *b) {
+return (*a) < (*b);
+}
+
+bool compare_segments(FGTaxiSegment *a, FGTaxiSegment *b) {
+return (*a) < (*b);
+}
 
 FGGroundNetwork::FGGroundNetwork()
 {
@@ -1039,7 +1011,6 @@ bool FGGroundNetwork::checkForCircularWaits(int id)
    TrafficVectorIterator i = activeTraffic.begin();
    int trafficSize = activeTraffic.size();
    if (trafficSize)  {
-        //while ((i->getId() != id) && i != activeTraffic.end()) 
         while (i != activeTraffic.end()) {
         if (i->getId() == id) {
            break;
@@ -1049,7 +1020,7 @@ bool FGGroundNetwork::checkForCircularWaits(int id)
   }
   else {
       return false;
-  } 
+  }
   if (i == activeTraffic.end() || (trafficSize == 0)) {
     SG_LOG(SG_GENERAL, SG_ALERT, "AI error: Trying to access non-existing aircraft in FGGroundNetwork::checkForCircularWaits");
   }
@@ -1058,6 +1029,13 @@ bool FGGroundNetwork::checkForCircularWaits(int id)
    target = current->getWaitsForId();
    //bool printed = false; // Note that this variable is for debugging purposes only.
    int counter = 0;
+
+   if (id == target) {
+       //cerr << "aircraft waits for user" << endl;
+       return false;
+   }
+
+
    while ((target > 0) && (target != id) && counter++ < trafficSize) {
     //printed = true;
      TrafficVectorIterator i = activeTraffic.begin();
@@ -1102,10 +1080,18 @@ bool FGGroundNetwork::checkForCircularWaits(int id)
     //     << " (" << other->getId()  << "); " << endl;;
     //current = other;
    }
+
+
+
+
+
+
    //if (printed)
    //   cerr << "[done] " << endl << endl;;
    if (id == target) {
-       SG_LOG(SG_GENERAL, SG_INFO, "Detected circular wait condition");
+       SG_LOG(SG_GENERAL, SG_ALERT, "Detected circular wait condition");
+       cerr << "Id = " << id << endl;
+       cerr << "target = " << target << endl;
        return true;
    } else {
    return false;