]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIFlightPlanCreate.cxx
assign a unique module name to ai/mp embedded nasal (again): __model%u
[flightgear.git] / src / AIModel / AIFlightPlanCreate.cxx
index 87c2531482a2e2c69bd08b0bc837605d342945cf..77032b3fac87aff29b8eb954dbd38e3df23621e2 100644 (file)
@@ -24,6 +24,9 @@
 
 #include "AIFlightPlan.hxx"
 #include <simgear/math/sg_geodesy.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/props/props_io.hxx>
+
 #include <Airports/runways.hxx>
 #include <Airports/dynamics.hxx>
 #include "AIAircraft.hxx"
@@ -145,6 +148,27 @@ FGAIFlightPlan::cloneWithPos(FGAIAircraft *ac, waypoint* aWpt, const std::string
   return wpt;
 }
 
+FGAIFlightPlan::waypoint*
+FGAIFlightPlan::clone(waypoint* aWpt)
+{
+  waypoint* wpt  = new waypoint;
+  wpt->name      = aWpt->name;
+  wpt->longitude = aWpt->longitude;
+  wpt->latitude  = aWpt->latitude;
+
+  wpt->altitude  = aWpt->altitude;
+  wpt->speed     = aWpt->speed; 
+  wpt->crossat   = aWpt->crossat;
+  wpt->gear_down = aWpt->gear_down;
+  wpt->flaps_down= aWpt->flaps_down;
+  wpt->finished  = aWpt->finished;
+  wpt->on_ground = aWpt->on_ground;
+  wpt->routeIndex = 0;
+  
+  return wpt;
+}
+
+
 void FGAIFlightPlan::createDefaultTakeoffTaxi(FGAIAircraft *ac, FGAirport* aAirport, FGRunway* aRunway)
 {
   SGGeod runwayTakeoff = aRunway->pointOnCenterline(5.0);
@@ -403,6 +427,8 @@ void FGAIFlightPlan::createTakeOff(FGAIAircraft *ac, bool firstFlight, FGAirport
 void FGAIFlightPlan::createClimb(FGAIAircraft *ac, bool firstFlight, FGAirport *apt, double speed, double alt, const string &fltType)
 {
   waypoint *wpt;
+  bool planLoaded = false;
+  string fPLName;
 
   if (firstFlight) {
     string rwyClass = getRunwayClassFromTrafficType(fltType);
@@ -410,20 +436,29 @@ void FGAIFlightPlan::createClimb(FGAIAircraft *ac, bool firstFlight, FGAirport *
     apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, heading);
     rwy = apt->getRunwayByIdent(activeRunway);
   }
-  
-  SGGeod climb1 = rwy->pointOnCenterline(10*SG_NM_TO_METER);
-  wpt = createInAir(ac, "10000ft climb", climb1, speed, 10000);
-  wpt->gear_down = true;
-  wpt->flaps_down= true;
-  waypoints.push_back(wpt); 
-
-  SGGeod climb2 = rwy->pointOnCenterline(20*SG_NM_TO_METER);
-  wpt = cloneWithPos(ac, wpt, "18000ft climb", climb2);
-  wpt->altitude  = 18000;
-  waypoints.push_back(wpt); 
+  if (sid) {
+    for (wpt_vector_iterator i = sid->getFirstWayPoint(); 
+         i != sid->getLastWayPoint(); 
+         i++) {
+            waypoints.push_back(clone(*(i)));
+            //cerr << " Cloning waypoint " << endl;
+    }
+  } else  {
+      SGGeod climb1 = rwy->pointOnCenterline(10*SG_NM_TO_METER);
+      wpt = createInAir(ac, "10000ft climb", climb1, speed, 10000);
+      wpt->gear_down = true;
+      wpt->flaps_down= true;
+      waypoints.push_back(wpt); 
+
+      SGGeod climb2 = rwy->pointOnCenterline(20*SG_NM_TO_METER);
+      wpt = cloneWithPos(ac, wpt, "18000ft climb", climb2);
+      wpt->altitude  = 18000;
+      waypoints.push_back(wpt); 
+   }
 }
 
 
+
 /*******************************************************************
  * CreateDecent
  * initialize the Aircraft at the parking location