]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / Airports / groundnetwork.cxx
index 011acb866d513014d9023dd164be137047255eb6..0470e4af92ef9a28663887cd57e42fc90d404924 100644 (file)
@@ -30,6 +30,7 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/route/waypoint.hxx>
 
+#include <Airports/simple.hxx>
 #include <Airports/dynamics.hxx>
 
 #include <AIModel/AIAircraft.hxx>
@@ -459,6 +460,7 @@ void FGGroundNetwork::announcePosition(int id,
                                        double radius, int leg,
                                        FGAIAircraft * aircraft)
 {
+    init();
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id alread has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
@@ -509,9 +511,9 @@ void FGGroundNetwork::signOff(int id)
     }
 }
 
-void FGGroundNetwork::update(int id, double lat, double lon,
-                             double heading, double speed, double alt,
-                             double dt)
+void FGGroundNetwork::updateAircraftInformation(int id, double lat, double lon,
+                                                double heading, double speed, double alt,
+                                                double dt)
 {
     // Check whether aircraft are on hold due to a preceding pushback. If so, make sure to 
     // Transmit air-to-ground "Ready to taxi request:
@@ -553,35 +555,46 @@ void FGGroundNetwork::update(int id, double lat, double lon,
     current->clearResolveCircularWait();
     current->setWaitsForId(0);
     checkSpeedAdjustment(id, lat, lon, heading, speed, alt);
-    checkHoldPosition(id, lat, lon, heading, speed, alt);
-    if (checkForCircularWaits(id)) {
-        i->setResolveCircularWait();
-    }
     bool needsTaxiClearance = current->getAircraft()->getTaxiClearanceRequest();
-    int state = current->getState();
-    time_t now = time(NULL) + fgGetLong("/sim/time/warp");
-    if ((now - lastTransmission) > 15) {
-        available = true;
-    }
-    if (needsTaxiClearance && available) {
-         transmit(&(*current), MSG_REQUEST_TAXI_CLEARANCE, ATC_AIR_TO_GROUND);
-         current->getAircraft()->setTaxiClearanceRequest(false);
-         current->setState(3);
-         lastTransmission = now;
-         available = false;
-    }
-    if ((state == 3) && available) {
-         transmit(&(*current), MSG_ISSUE_TAXI_CLEARANCE, ATC_GROUND_TO_AIR);
-         current->setState(4);
-         lastTransmission = now;
-         available = false;
-    }
-    if ((state == 4) && available) {
-         transmit(&(*current), MSG_ACKNOWLEDGE_TAXI_CLEARANCE, ATC_AIR_TO_GROUND);
-         current->setState(0);
-         lastTransmission = now;
-         available = false;
+    if (!needsTaxiClearance) {
+        checkHoldPosition(id, lat, lon, heading, speed, alt);
+        if (checkForCircularWaits(id)) {
+            i->setResolveCircularWait();
+        }
+    } else {
+        current->setHoldPosition(true);
+        int state = current->getState();
+        time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+        if ((now - lastTransmission) > 15) {
+            available = true;
+        }
+        if ((state < 3) && available) {
+             transmit(&(*current), MSG_REQUEST_TAXI_CLEARANCE, ATC_AIR_TO_GROUND);
+             current->setState(3);
+             lastTransmission = now;
+             available = false;
+        }
+        if ((state == 3) && available) {
+            transmit(&(*current), MSG_ISSUE_TAXI_CLEARANCE, ATC_GROUND_TO_AIR);
+            current->setState(4);
+            lastTransmission = now;
+            available = false;
+        }
+        if ((state == 4) && available) {
+            transmit(&(*current), MSG_ACKNOWLEDGE_TAXI_CLEARANCE, ATC_AIR_TO_GROUND);
+            current->setState(5);
+            lastTransmission = now;
+            available = false;
+        }
+        if ((state == 5) && available) {
+            current->setState(0);
+            current->getAircraft()->setTaxiClearanceRequest(false);
+            current->setHoldPosition(true);
+            available = false;
+        }
+
     }
+
 }
 
 /**