using std::cout;
using std::endl;
+namespace {
+
+TrafficVectorIterator findTraffic(TrafficVector& vec, int id)
+{
+ TrafficVectorIterator it = vec.begin();
+ for (; it != vec.end(); ++it) {
+ if (it->getId() == id) {
+ return it;
+ }
+ }
+
+ return it; // vec.end, effectively
+}
+
+void clearTrafficControllers(TrafficVector& vec)
+{
+ TrafficVectorIterator it = vec.begin();
+ for (; it != vec.end(); ++it) {
+ it->getAircraft()->clearATCController();
+ }
+}
+
+} // of anonymous namespace
+
/***************************************************************************
* ActiveRunway
**************************************************************************/
FGTrafficRecord::~FGTrafficRecord()
{
- //if (aircraft) {
- // aircraft->clearATCController();
- //}
}
void FGTrafficRecord::setPositionAndIntentions(int pos,
parent = par;
}
+FGTowerController::~FGTowerController()
+{
+ // to avoid the exception described in:
+ // https://sourceforge.net/p/flightgear/codetickets/1864/
+ // we want to ensure AI aircraft signing-off is a no-op now
+
+ clearTrafficControllers(activeTraffic);
+}
+
//
void FGTowerController::announcePosition(int id,
FGAIFlightPlan * intendedRoute,
parent = par;
}
+FGStartupController::~FGStartupController()
+{
+ clearTrafficControllers(activeTraffic);
+}
+
void FGStartupController::announcePosition(int id,
FGAIFlightPlan * intendedRoute,
int currentPosition, double lat,
parent = par;
}
+FGApproachController::~FGApproachController()
+{
+ clearTrafficControllers(activeTraffic);
+}
+
//
void FGApproachController::announcePosition(int id,
FGAIFlightPlan * intendedRoute,
public:
FGTowerController(FGAirportDynamics *parent);
- virtual ~FGTowerController() {};
+ virtual ~FGTowerController();
+
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
double lat, double lon,
double hdg, double spd, double alt, double radius, int leg,
public:
FGStartupController(FGAirportDynamics *parent);
- virtual ~FGStartupController() {};
+ virtual ~FGStartupController();
+
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
double lat, double lon,
double hdg, double spd, double alt, double radius, int leg,
public:
FGApproachController(FGAirportDynamics * parent);
- virtual ~FGApproachController() { };
+ virtual ~FGApproachController();
+
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
double lat, double lon,
double hdg, double spd, double alt, double radius, int leg,