1
0
Fork 0

Trying to bullet-proof the traffic code.

This commit is contained in:
James Turner 2015-12-18 21:42:22 -08:00
parent 0f590280c7
commit 865bb365ed
4 changed files with 53 additions and 9 deletions

View file

@ -107,6 +107,11 @@ void FGGroundController::announcePosition(int id,
double radius, int leg,
FGAIAircraft * aircraft)
{
if (!aircraft || !aircraft->getPerformance()) {
SG_LOG(SG_ATC, SG_ALERT, "announcePosition: missing aircraft performance");
return;
}
TrafficVectorIterator i = activeTraffic.begin();
// Search search if the current id alread has an entry
// This might be faster using a map instead of a vector, but let's start by taking a safe route

View file

@ -57,7 +57,10 @@ FGTaxiSegment::FGTaxiSegment(FGTaxiNode* aStart, FGTaxiNode* aEnd) :
index(0),
oppositeDirection(0)
{
};
if (!aStart || !aEnd) {
throw sg_exception("Missing node arguments creating FGTaxiSegment");
}
}
SGGeod FGTaxiSegment::getCenter() const
{

View file

@ -505,17 +505,53 @@ bool FGAISchedule::next()
return true;
}
time_t FGAISchedule::getDepartureTime() { return (*flights.begin())->getDepartureTime (); }
time_t FGAISchedule::getDepartureTime()
{
if (flights.empty())
return 0;
FGAirport *FGAISchedule::getDepartureAirport() { return (*flights.begin())->getDepartureAirport(); }
return (*flights.begin())->getDepartureTime ();
}
FGAirport *FGAISchedule::getArrivalAirport() { return (*flights.begin())->getArrivalAirport (); }
FGAirport *FGAISchedule::getDepartureAirport()
{
if (flights.empty())
return 0;
int FGAISchedule::getCruiseAlt() { return (*flights.begin())->getCruiseAlt (); }
return (*flights.begin())->getDepartureAirport();
}
const std::string &FGAISchedule::getCallSign() { return (*flights.begin())->getCallSign (); }
FGAirport *FGAISchedule::getArrivalAirport()
{
if (flights.empty())
return 0;
const std::string &FGAISchedule::getFlightRules() { return (*flights.begin())->getFlightRules (); }
return (*flights.begin())->getArrivalAirport ();
}
int FGAISchedule::getCruiseAlt()
{
if (flights.empty())
return 0;
return (*flights.begin())->getCruiseAlt ();
}
std::string FGAISchedule::getCallSign()
{
if (flights.empty())
return std::string();
return (*flights.begin())->getCallSign ();
}
std::string FGAISchedule::getFlightRules()
{
if (flights.empty())
return std::string();
return (*flights.begin())->getFlightRules ();
}
FGScheduledFlight* FGAISchedule::findAvailableFlight (const string &currentDestination,
const string &req,

View file

@ -118,9 +118,9 @@ class FGAISchedule
const std::string& getFlightType () { return flightType;};
const std::string& getAirline () { return airline; };
const std::string& getAircraft () { return acType; };
const std::string& getCallSign ();
std::string getCallSign ();
const std::string& getRegistration () { return registration;};
const std::string& getFlightRules ();
std::string getFlightRules ();
bool getHeavy () { return heavy; };
double getCourse () { return courseToDest; };
unsigned int getRunCount () { return runCount; };