]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIFlightPlanCreatePushBack.cxx
Interim windows build fix
[flightgear.git] / src / AIModel / AIFlightPlanCreatePushBack.cxx
index d774f3b51494ef894cf3833d05f939229ee3e71f..923596d04c6c73bab1e632d849e891b35db1ce3b 100644 (file)
 
 #include <simgear/math/sg_geodesy.hxx>
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/dynamics.hxx>
+#include <Airports/groundnetwork.hxx>
 
 #include <Environment/environment_mgr.hxx>
 #include <Environment/environment.hxx>
@@ -38,6 +39,7 @@
 #include "AIAircraft.hxx"
 #include "performancedata.hxx"
 
+using std::string;
 
 // TODO: Use James Turner's createOnGround functions.
 bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
@@ -50,11 +52,12 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
     double vTaxi = ac->getPerformance()->vTaxi();
     double vTaxiBackward = vTaxi * (-2.0/3.0);
     double vTaxiReduced  = vTaxi * (2.0/3.0);
+    
     // Active runway can be conditionally set by ATC, so at the start of a new flight, this
     // must be reset.
     activeRunway.clear();
 
-    if (!(dep->getDynamics()->getGroundNetwork()->exists())) {
+    if (!(dep->getDynamics()->getGroundController()->exists())) {
         //cerr << "Push Back fallback" << endl;
         createPushBackFallBack(ac, firstFlight, dep,
                                radius, fltType, aircraftType, airline);
@@ -85,7 +88,7 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
     FGGroundNetwork* groundNet = dep->getDynamics()->getGroundNetwork();
     FGParking *parking = gate.parking();
     if (parking && parking->getPushBackPoint() > 0) {
-        FGTaxiRoute route = groundNet->findShortestRoute(parking->guid(), parking->getPushBackPoint(), false);
+        FGTaxiRoute route = groundNet->findShortestRoute(parking, parking->getPushBackPoint(), false);
       
         int size = route.size();
         if (size < 2) {
@@ -94,15 +97,16 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
         }
         
         route.first();
-        PositionedID node, previous= 0;
+        FGTaxiNodeRef node;
+        int rte;
       
-        while (route.next(&node))
+        while (route.next(node, &rte))
         {
             char buffer[10];
-            snprintf (buffer, 10, "%lld",  (long long int) node);
-            FGTaxiNode *tn = groundNet->findNode(node);
-            FGAIWaypoint *wpt = createOnGround(ac, string(buffer), tn->geod(), dep->getElevation(), vTaxiBackward);
-          
+            snprintf (buffer, 10, "%d",  node->getIndex());
+            FGAIWaypoint *wpt = createOnGround(ac, string(buffer), node->geod(), dep->getElevation(), vTaxiBackward);
+            
+            /*
             if (previous) {
               FGTaxiSegment* segment = groundNet->findSegment(previous, node);
               wpt->setRouteIndex(segment->getIndex());
@@ -110,10 +114,11 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
               // not on the route yet, make up a unique segment ID
               int x = (int) tn->guid();
               wpt->setRouteIndex(x);
-            }
-          
+            }*/
+            
+            wpt->setRouteIndex(rte);          
             pushBackWaypoint(wpt);
-            previous = node;
+            //previous = node;
         }
         // some special considerations for the last point:
         waypoints.back()->setName(string("PushBackPoint"));
@@ -123,14 +128,14 @@ bool FGAIFlightPlan::createPushBack(FGAIAircraft *ac,
         ac->setTaxiClearanceRequest(false);
         double az2 = 0.0;
 
-      FGTaxiSegment* pushForwardSegment = dep->getDynamics()->getGroundNetwork()->findSegment(parking->guid(), 0);
+      FGTaxiSegment* pushForwardSegment = dep->getDynamics()->getGroundNetwork()->findSegment(parking, 0);
       // there aren't any routes for this parking.
       if (!pushForwardSegment) {
           SG_LOG(SG_AI, SG_ALERT, "Gate " << parking->ident() << "doesn't seem to have routes associated with it.");
           return false;
       }
 
-      lastNodeVisited = pushForwardSegment->getEnd()->getIndex();
+      lastNodeVisited = pushForwardSegment->getEnd();
       double distance = pushForwardSegment->getLength();
 
       double parkingHeading = parking->getHeading();