1
0
Fork 0

Merge branch 'maint2' into next

This commit is contained in:
Tim Moore 2009-01-07 10:38:07 +01:00
commit 90b2d25671
2 changed files with 29 additions and 22 deletions

View file

@ -348,26 +348,24 @@ void FGAirportDynamics::setRwyUse(const FGRunwayPreference& ref)
//cerr << "Exiting due to not implemented yet" << endl; //cerr << "Exiting due to not implemented yet" << endl;
//exit(1); //exit(1);
} }
void FGAirportDynamics::getActiveRunway(const string &trafficType, int action, string &runway)
bool FGAirportDynamics::innerGetActiveRunway(const string &trafficType, int action, string &runway)
{ {
double windSpeed; double windSpeed;
double windHeading; double windHeading;
double maxTail; double maxTail;
double maxCross; double maxCross;
string name; string name;
string type; string type;
if (!(rwyPrefs.available())) if (!rwyPrefs.available()) {
{ return false;
runway = chooseRunwayFallback(); }
return; // generic fall back goes here
} RunwayGroup *currRunwayGroup = 0;
else int nrActiveRunways = 0;
{ time_t dayStart = fgGetLong("/sim/time/utc/day-seconds");
RunwayGroup *currRunwayGroup = 0; if ((abs((long)(dayStart - lastUpdate)) > 600) || trafficType != prevTrafficType)
int nrActiveRunways = 0;
time_t dayStart = fgGetLong("/sim/time/utc/day-seconds");
if ((abs((long)(dayStart - lastUpdate)) > 600) || trafficType != prevTrafficType)
{ {
landing.clear(); landing.clear();
takeoff.clear(); takeoff.clear();
@ -390,19 +388,19 @@ void FGAirportDynamics::getActiveRunway(const string &trafficType, int action, s
//cerr << "A"<< endl; //cerr << "A"<< endl;
currSched = rwyPrefs.getSchedule(trafficType.c_str()); currSched = rwyPrefs.getSchedule(trafficType.c_str());
if (!(currSched)) if (!(currSched))
return; return false;
//cerr << "B"<< endl; //cerr << "B"<< endl;
scheduleName = currSched->getName(dayStart); scheduleName = currSched->getName(dayStart);
maxTail = currSched->getTailWind (); maxTail = currSched->getTailWind ();
maxCross = currSched->getCrossWind (); maxCross = currSched->getCrossWind ();
//cerr << "SChedule anme = " << scheduleName << endl; //cerr << "SChedule anme = " << scheduleName << endl;
if (scheduleName.empty()) if (scheduleName.empty())
return; return false;
//cerr << "C"<< endl; //cerr << "C"<< endl;
currRunwayGroup = rwyPrefs.getGroup(scheduleName); currRunwayGroup = rwyPrefs.getGroup(scheduleName);
//cerr << "D"<< endl; //cerr << "D"<< endl;
if (!(currRunwayGroup)) if (!(currRunwayGroup))
return; return false;
nrActiveRunways = currRunwayGroup->getNrActiveRunways(); nrActiveRunways = currRunwayGroup->getNrActiveRunways();
// Keep a history of the currently active runways, to ensure // Keep a history of the currently active runways, to ensure
@ -451,7 +449,8 @@ void FGAirportDynamics::getActiveRunway(const string &trafficType, int action, s
} }
//cerr << endl; //cerr << endl;
} }
if (action == 1) // takeoff
if (action == 1) // takeoff
{ {
int nr = takeoff.size(); int nr = takeoff.size();
if (nr) if (nr)
@ -466,7 +465,8 @@ void FGAirportDynamics::getActiveRunway(const string &trafficType, int action, s
runway = chooseRunwayFallback(); runway = chooseRunwayFallback();
} }
} }
if (action == 2) // landing
if (action == 2) // landing
{ {
int nr = landing.size(); int nr = landing.size();
if (nr) if (nr)
@ -478,9 +478,16 @@ void FGAirportDynamics::getActiveRunway(const string &trafficType, int action, s
runway = chooseRunwayFallback(); runway = chooseRunwayFallback();
} }
} }
//runway = globals->get_runways()->search(_ap->getId(), int(windHeading));
//cerr << "Seleceted runway: " << runway << endl; return true;
} }
void FGAirportDynamics::getActiveRunway(const string &trafficType, int action, string &runway)
{
bool ok = innerGetActiveRunway(trafficType, action, runway);
if (!ok) {
runway = chooseRunwayFallback();
}
} }
string FGAirportDynamics::chooseRunwayFallback() string FGAirportDynamics::chooseRunwayFallback()

View file

@ -72,7 +72,7 @@ private:
//double avWindSpeed [10]; //double avWindSpeed [10];
string chooseRunwayFallback(); string chooseRunwayFallback();
bool innerGetActiveRunway(const string &trafficType, int action, string &runway);
public: public:
FGAirportDynamics(FGAirport* ap); FGAirportDynamics(FGAirport* ap);
FGAirportDynamics(const FGAirportDynamics &other); FGAirportDynamics(const FGAirportDynamics &other);