#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"
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);
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);
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