]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIFlightPlan.cxx
model paging patch from Till Busch
[flightgear.git] / src / AIModel / AIFlightPlan.cxx
index 9a7d6a267bca226371e203916139d7c0ddfdf23e..48af6afb81ae5d916a88ce3b3e808bf7be0dad98 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
 
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/debug/logstream.hxx>
@@ -47,6 +49,7 @@ FGAIFlightPlan::FGAIFlightPlan(const string& filename)
   start_time = 0;
   leg = 10;
   gateId = 0;
+  taxiRoute = 0;
   SGPath path( globals->get_fg_root() );
   path.append( ("/AI/FlightPlans/" + filename).c_str() );
   SGPropertyNode root;
@@ -75,6 +78,8 @@ FGAIFlightPlan::FGAIFlightPlan(const string& filename)
      wpt->gear_down = wpt_node->getBoolValue("gear-down", false);
      wpt->flaps_down= wpt_node->getBoolValue("flaps-down", false);
      wpt->on_ground = wpt_node->getBoolValue("on-ground", false);
+     wpt->time_sec   = wpt_node->getDoubleValue("time-sec", 0);
+     wpt->time       = wpt_node->getStringValue("time", "");
 
      if (wpt->name == "END") wpt->finished = true;
      else wpt->finished = false;
@@ -108,14 +113,17 @@ FGAIFlightPlan::FGAIFlightPlan(const std::string& p,
                               const string& acType,
                               const string& airline)
 {
+  repeat = false;
   leg = 10;
   gateId=0;
+  taxiRoute = 0;
   start_time = start;
   bool useInitialWayPoint = true;
   bool useCurrentWayPoint = false;
   SGPath path( globals->get_fg_root() );
   path.append( "/AI/FlightPlans" );
   path.append( p );
+  
   SGPropertyNode root;
   
   // This is a bit of a hack:
@@ -159,7 +167,7 @@ FGAIFlightPlan::FGAIFlightPlan(const std::string& p,
          }
        }
       catch (const sg_exception &e) {
-       SG_LOG(SG_GENERAL, SG_ALERT,
+       SG_LOG(SG_GENERAL, SG_WARN,
               "Error reading AI flight plan: ");
        cerr << "Errno = " << errno << endl;
        if (errno == ENOENT)
@@ -184,8 +192,8 @@ FGAIFlightPlan::FGAIFlightPlan(const std::string& p,
        leg = 4;
       else if (timeDiff >= 2000)
        leg = 5;
-      
-      //cerr << "Set leg to : " << leg << endl;  
+
+      SG_LOG(SG_GENERAL, SG_INFO, "Route from " << dep->getId() << " to " << arr->getId() << ". Set leg to : " << leg);
       wpt_iterator = waypoints.begin();
       create(dep,arr, leg, alt, speed, lat, lon,
             firstLeg, radius, fltType, acType, airline);
@@ -290,12 +298,7 @@ FGAIFlightPlan::FGAIFlightPlan(const std::string& p,
 FGAIFlightPlan::~FGAIFlightPlan()
 {
   deleteWaypoints();
-  //waypoints.clear();
-  //while (waypoints.begin() != waypoints.end())
-  //  {
-  //    delete *(waypoints.begin());
-  //    waypoints.erase (waypoints.begin());
-  //  }
+  delete taxiRoute;
 }
 
 
@@ -345,6 +348,7 @@ void FGAIFlightPlan::IncrementWaypoint(bool eraseWaypoints )
     }
   else
     wpt_iterator++;
+
 }
 
 // gives distance in feet from a position to a waypoint
@@ -483,3 +487,19 @@ void FGAIFlightPlan::restart()
 {
   wpt_iterator = waypoints.begin();
 }
+
+
+void FGAIFlightPlan::deleteTaxiRoute() 
+{
+  delete taxiRoute;
+  taxiRoute = 0;
+}
+
+
+int FGAIFlightPlan::getRouteIndex(int i) {
+  if ((i > 0) && (i < waypoints.size())) {
+    return waypoints[i]->routeIndex;
+  }
+  else
+    return 0;
+}