X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Frunwayprefs.cxx;h=8337d31f9fad3e60c7c8ea5430536fa4fe8bed47;hb=386aefe69358ce41a11c9afeb8f56e26758fe56b;hp=9be9644f63d703f02990928efe7e81c9a423848d;hpb=7dfae1562bdb68d0c67e728f3f922c6373b83c9c;p=flightgear.git diff --git a/src/Airports/runwayprefs.cxx b/src/Airports/runwayprefs.cxx index 9be9644f6..8337d31f9 100644 --- a/src/Airports/runwayprefs.cxx +++ b/src/Airports/runwayprefs.cxx @@ -26,21 +26,11 @@ #endif #include -//#include #include -//#include -//#include - -//#include -//#include -//#include -//#include -//#include #include #include
-//#include
#include #include "runwayprefs.hxx" @@ -118,7 +108,7 @@ string ScheduleTime::getName(time_t dayStart) //couldn't find one so return 0; //cerr << "Returning 0 " << endl; } - return string(0); + return string(""); } /****************************************************************************** * RunwayList @@ -194,7 +184,7 @@ RunwayGroup& RunwayGroup:: operator= (const RunwayGroup &other) return *this; } -void RunwayGroup::setActive(const string &aptId, +void RunwayGroup::setActive(const FGAirport* airport, double windSpeed, double windHeading, double maxTail, @@ -202,7 +192,7 @@ void RunwayGroup::setActive(const string &aptId, stringVec *currentlyActive) { - FGRunway rwy; + FGRunway* rwy; int activeRwys = rwyList.size(); // get the number of runways active int nrOfPreferences; // bool found = true; @@ -234,16 +224,17 @@ void RunwayGroup::setActive(const string &aptId, // validSelection = true; for (int j = 0; j < activeRwys; j++) - { - - name = rwyList[j].getRwyList(i); - //cerr << "Name of Runway: " << name << endl; - if (globals->get_runways()->search( aptId, - name, - &rwy)) - { - //cerr << "Succes" << endl; - hdgDiff = fabs(windHeading - rwy._heading); + { + string ident(rwyList[j].getRwyList(i)); + if (!airport->hasRunwayWithIdent(ident)) { + SG_LOG(SG_GENERAL, SG_WARN, "no such runway:" << ident << " at " << airport->ident()); + continue; + } + + rwy = airport->getRunwayByIdent(ident); + + //cerr << "Succes" << endl; + hdgDiff = fabs(windHeading - rwy->headingDeg()); //cerr << "Wind Heading: " << windHeading << "Runway Heading: " < 180) @@ -252,22 +243,20 @@ void RunwayGroup::setActive(const string &aptId, hdgDiff *= ((2*M_PI)/360.0); // convert to radians crossWind = windSpeed * sin(hdgDiff); tailWind = -windSpeed * cos(hdgDiff); - //cerr << "Tailwind : " << tailWind << endl; - //cerr << "Crosswnd : " << crossWind << endl; + //cerr << ". Tailwind : " << tailWind; + //cerr << ". Crosswnd : " << crossWind; if ((tailWind > maxTail) || (crossWind > maxCross)) { - //cerr << "Invalid : " << endl; + //cerr << ". [Invalid] " << endl; validSelection = false; } else { - //cerr << "Valid : " << endl;; + //cerr << ". [Valid] "; } - }else { - SG_LOG( SG_GENERAL, SG_INFO, "Failed to find runway " << name << " at " << aptId ); - exit(1); - } - } + //cerr << endl; + } // of active runways iteration + if (validSelection) { //cerr << "Valid selection : " << i << endl;; @@ -310,15 +299,11 @@ void RunwayGroup::setActive(const string &aptId, bool validSelection = true; for (int j = 0; j < 2; j++) { - //cerr << "I J " << i << " " << j << endl; - name = rwyList[choice[j]].getRwyList(i); - //cerr << "Name of Runway: " << name << endl; - if (globals->get_runways()->search( aptId, - name, - &rwy)) - { + name = rwyList[choice[j]].getRwyList(i); + rwy = airport->getRunwayByIdent(name); + //cerr << "Succes" << endl; - hdgDiff = fabs(windHeading - rwy._heading); + hdgDiff = fabs(windHeading - rwy->headingDeg()); if (hdgDiff > 180) hdgDiff = 360 - hdgDiff; hdgDiff *= ((2*M_PI)/360.0); // convert to radians @@ -326,10 +311,7 @@ void RunwayGroup::setActive(const string &aptId, tailWind = -windSpeed * cos(hdgDiff); if ((tailWind > maxTail) || (crossWind > maxCross)) validSelection = false; - }else { - SG_LOG( SG_GENERAL, SG_INFO, "Failed to find runway " << name << " at " << aptId ); - exit(1); - } + } if (validSelection)