#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>
#include "AIAircraft.hxx"
using std::cerr;
+using std::string;
FGAIWaypoint::FGAIWaypoint() {
speed = 0;
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 )
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--;
}
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,
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();
(waypoints.back())->setName((waypoints.back())->getName() + name);
}
-void FGAIFlightPlan::setGate(ParkingAssignment pka)
+void FGAIFlightPlan::setGate(const ParkingAssignment& pka)
{
gate = pka;
}
{
return gate.parking();
}
+
+FGAirportRef FGAIFlightPlan::departureAirport() const
+{
+ return departure;
+}
+
+FGAirportRef FGAIFlightPlan::arrivalAirport() const
+{
+ return arrival;
+}