]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/dynamics.cxx
Some cleanup in the ATC/AI code before merging with the next branch:
[flightgear.git] / src / Airports / dynamics.cxx
index 69f8c051ddfc9152b440a4eb73df930d63416abd..3d443d08fa227456ee6a41227367bdb40dfd6633 100644 (file)
@@ -50,9 +50,10 @@ using std::random_shuffle;
 #include "dynamics.hxx"
 
 FGAirportDynamics::FGAirportDynamics(FGAirport * ap):
-_ap(ap), rwyPrefs(ap), SIDs(ap),
+    _ap(ap), rwyPrefs(ap), SIDs(ap),
     atisSequenceIndex(-1),
-    atisSequenceTimeStamp(0.0)
+    atisSequenceTimeStamp(0.0),
+    startupController(this)
 {
     lastUpdate = 0;
 }
@@ -75,10 +76,11 @@ void FGAirportDynamics::init()
     random_shuffle(parkings.begin(), parkings.end());
     sort(parkings.begin(), parkings.end());
     // add the gate positions to the ground network. 
+    groundNetwork.setParent(_ap);
     groundNetwork.addNodes(&parkings);
     groundNetwork.init();
     groundNetwork.setTowerController(&towerController);
-    groundNetwork.setParent(_ap);
+    
 }
 
 bool FGAirportDynamics::getAvailableParking(double *lat, double *lon,
@@ -514,6 +516,32 @@ int FGAirportDynamics::getGroundFrequency(unsigned leg)
     return groundFreq;
 }
 
+int FGAirportDynamics::getTowerFrequency(unsigned nr)
+{
+    int towerFreq = 0;
+    if (nr < 2) {
+        SG_LOG(SG_ATC, SG_ALERT,
+               "Leg value is smaller than two at " << SG_ORIGIN);
+    }
+    if (freqTower.size() == 0) {
+        return 0;
+    }
+    if ((freqTower.size() > nr - 1) && (nr > 1)) {
+        towerFreq = freqTower[nr - 1];
+    }
+    if ((freqTower.size() < nr - 1) && (nr > 1)) {
+        towerFreq =
+            (freqTower.size() <
+             (nr - 1)) ? freqTower[freqTower.size() -
+                                     1] : freqTower[nr - 2];
+    }
+    if ((freqTower.size() >= nr - 1) && (nr > 1)) {
+        towerFreq = freqTower[nr - 2];
+    }
+    return towerFreq;
+}
+
+
 FGAIFlightPlan *FGAirportDynamics::getSID(string activeRunway,
                                           double heading)
 {