]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / Airports / groundnetwork.cxx
index 2fd437026cd506930a5f33e44b1185c3ce24f055..a97f8075a00e93dd399a46b4b8f5b3a0bf3f8e02 100644 (file)
@@ -46,6 +46,8 @@
 #include <AIModel/AIAircraft.hxx>
 #include <AIModel/AIFlightPlan.hxx>
 
+#include <ATC/atc_mgr.hxx>
+
 #include <Scenery/scenery.hxx>
 
 #include "groundnetwork.hxx"
@@ -510,6 +512,7 @@ void FGGroundNetwork::announcePosition(int id,
     }
 }
 
+
 void FGGroundNetwork::signOff(int id)
 {
     TrafficVectorIterator i = activeTraffic.begin();
@@ -538,7 +541,6 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic
     int state = i->getState();
     if ((state >= minState) && (state <= maxState) && available) {
         if ((msgDir == ATC_AIR_TO_GROUND) && isUserAircraft(i->getAircraft())) {
-            
             //cerr << "Checking state " << state << " for " << i->getAircraft()->getCallSign() << endl;
             static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true);
             int n = trans_num->getIntValue();
@@ -546,13 +548,14 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic
                 trans_num->setIntValue(-1);
                  // PopupCallback(n);
                  cerr << "Selected transmission message " << n << endl;
+                 FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
+                 atc->getATCDialog()->removeEntry(1);
             } else {
                 //cerr << "creating message for " << i->getAircraft()->getCallSign() << endl;
                 transmit(&(*i), msgId, msgDir, false);
                 return false;
             }
         }
-        //cerr << "Transmitting startup msg" << endl;
         transmit(&(*i), msgId, msgDir, true);
         i->updateState();
         lastTransmission = now;
@@ -707,6 +710,8 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
             }
         }
         //Check traffic at the tower controller
+        // Note, as of 2011-08-01, this should no longer be necessecary.
+        /*
         if (towerController->hasActiveTraffic()) {
             for (TrafficVectorIterator i =
                  towerController->getActiveTraffic().begin();
@@ -728,6 +733,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
             }
         }
         // Finally, check UserPosition
+        // Note, as of 2011-08-01, this should no longer be necessecary.
         double userLatitude = fgGetDouble("/position/latitude-deg");
         double userLongitude = fgGetDouble("/position/longitude-deg");
         SGGeod user(SGGeod::fromDeg(userLongitude, userLatitude));
@@ -742,7 +748,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
             minbearing = bearing;
             otherReasonToSlowDown = true;
         }
-
+        */
         current->clearSpeedAdjustment();
 
         if (current->checkPositionAndIntentions(*closest)
@@ -758,6 +764,8 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
                 if (closest->getId() != current->getId())
                     current->setSpeedAdjustment(closest->getSpeed() *
                                                 (mindist / 100));
+                    if (closest->getAircraft()->isScheduledForTakeoff())
+                        current->getAircraft()->scheduleForATCTowerDepartureControl();
                 else
                     current->setSpeedAdjustment(0);     // This can only happen when the user aircraft is the one closest
                 if (mindist < maxAllowableDistance) {
@@ -913,24 +921,6 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
             current->setState(0);
             current->setHoldPosition(false);
     }
-
-    /*if ((state == 1) && (available)) {
-        //cerr << "ACKNOWLEDGE HOLD" << endl;
-        transmit(&(*current), MSG_ACKNOWLEDGE_HOLD_POSITION, ATC_AIR_TO_GROUND, true);
-        current->setState(0);
-        current->setHoldPosition(true);
-        lastTransmission = now;
-        available = false;
-
-    }
-    if ((state == 2) && (available)) {
-        //cerr << "ACKNOWLEDGE RESUME" << endl;
-        transmit(&(*current), MSG_ACKNOWLEDGE_RESUME_TAXI, ATC_AIR_TO_GROUND, true);
-        current->setState(0);
-        current->setHoldPosition(false);
-        lastTransmission = now;
-        available = false;
-    }*/
 } 
 
 /**
@@ -1208,4 +1198,8 @@ void FGGroundNetwork::render(bool visible)
         }
         globals->get_scenery()->get_scene_graph()->addChild(group);
     }
-}
\ No newline at end of file
+}
+
+string FGGroundNetwork::getName() {
+    return string(parent->getId() + "-ground");
+}