]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIFlightPlan.cxx
commradio: improvements for atis speech
[flightgear.git] / src / AIModel / AIFlightPlan.cxx
index 5e17a3d9aff7b11c8c764d85828477edb9ba0623..eb0e6cc1f4dc03cbd3149682b64c98469d708bd1 100644 (file)
@@ -33,7 +33,7 @@
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/fg_init.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/groundnetwork.hxx>
@@ -45,6 +45,7 @@
 #include "AIAircraft.hxx"
 
 using std::cerr;
+using std::string;
 
 FGAIWaypoint::FGAIWaypoint() {
   speed       = 0;
@@ -286,21 +287,21 @@ FGAIWaypoint* const FGAIFlightPlan::getNextWaypoint( void ) const
 
 void FGAIFlightPlan::IncrementWaypoint(bool eraseWaypoints )
 {
-  if (eraseWaypoints)
+    if (eraseWaypoints)
     {
-      if (wpt_iterator == waypoints.begin())
-       wpt_iterator++;
-      else
-       {
-         delete *(waypoints.begin());
-         waypoints.erase(waypoints.begin());
-         wpt_iterator = waypoints.begin();
-         wpt_iterator++;
-       }
+        if (wpt_iterator == waypoints.begin())
+            wpt_iterator++;
+        else
+        if (!waypoints.empty())
+        {
+            delete *(waypoints.begin());
+            waypoints.erase(waypoints.begin());
+            wpt_iterator = waypoints.begin();
+            wpt_iterator++;
+        }
     }
-  else
-    wpt_iterator++;
-
+    else
+        wpt_iterator++;
 }
 
 void FGAIFlightPlan::DecrementWaypoint(bool eraseWaypoints )
@@ -310,9 +311,10 @@ void FGAIFlightPlan::DecrementWaypoint(bool eraseWaypoints )
         if (wpt_iterator == waypoints.end())
             wpt_iterator--;
         else
+        if (!waypoints.empty())
         {
-            delete *(waypoints.end());
-            waypoints.erase(waypoints.end());
+            delete *(waypoints.end()-1);
+            waypoints.erase(waypoints.end()-1);
             wpt_iterator = waypoints.end();
             wpt_iterator--;
         }
@@ -397,6 +399,7 @@ void FGAIFlightPlan::deleteWaypoints()
   for (wpt_vector_iterator i = waypoints.begin(); i != waypoints.end();i++)
     delete (*i);
   waypoints.clear();
+  wpt_iterator = waypoints.begin();
 }
 
 // Delete all waypoints except the last, 
@@ -447,7 +450,7 @@ int FGAIFlightPlan::getRouteIndex(int i) {
     return 0;
 }
 
-double FGAIFlightPlan::checkTrackLength(const string& wptName) {
+double FGAIFlightPlan::checkTrackLength(const string& wptName) const {
     // skip the first two waypoints: first one is behind, second one is partially done;
     double trackDistance = 0;
     wpt_vector_iterator wptvec = waypoints.begin();
@@ -471,7 +474,7 @@ void FGAIFlightPlan::shortenToFirst(unsigned int number, string name)
     (waypoints.back())->setName((waypoints.back())->getName() + name);
 }
 
-void FGAIFlightPlan::setGate(ParkingAssignment pka)
+void FGAIFlightPlan::setGate(const ParkingAssignment& pka)
 {
   gate = pka;
 }
@@ -480,3 +483,13 @@ FGParking* FGAIFlightPlan::getParkingGate()
 {
   return gate.parking();
 }
+
+FGAirportRef FGAIFlightPlan::departureAirport() const
+{
+    return departure;
+}
+
+FGAirportRef FGAIFlightPlan::arrivalAirport() const
+{
+    return arrival;
+}