#include <Airports/airport.hxx>
#include <Airports/dynamics.hxx>
#include <AIModel/AIManager.hxx>
+#include <GUI/MessageBox.hxx>
+
using std::endl;
using std::string;
SG_LOG( SG_GENERAL, SG_ALERT, "Failed to find airport:" << id);
return false;
}
-
- if (!apt->hasRunwayWithIdent(rwy)) {
- SG_LOG( SG_GENERAL, rwy_req ? SG_ALERT : SG_INFO,
- "Failed to find runway " << rwy <<
+
+ if (apt->hasRunwayWithIdent(rwy)) {
+ FGRunway* r(apt->getRunwayByIdent(rwy));
+ fgSetString("/sim/atc/runway", r->ident().c_str());
+ SGGeod startPos = r->pointOnCenterline( fgGetDouble("/sim/airport/runways/start-offset-m", 5.0));
+ fgApplyStartOffset(startPos, r->headingDeg());
+ return true;
+ } else if (apt->hasHelipadWithIdent(rwy)) {
+ FGHelipad* h(apt->getHelipadByIdent(rwy));
+ fgApplyStartOffset(h->geod(), h->headingDeg());
+ return true;
+ }
+
+ if (rwy_req) {
+ flightgear::modalMessageBox("Runway not available", "Runway/helipad "
+ + rwy + " not found at airport " + apt->getId()
+ + " - " + apt->getName() );
+ } else {
+ SG_LOG( SG_GENERAL, SG_INFO,
+ "Failed to find runway/helipad " << rwy <<
" at airport " << id << ". Using default runway." );
- return false;
}
-
- FGRunway* r(apt->getRunwayByIdent(rwy));
- fgSetString("/sim/atc/runway", r->ident().c_str());
- SGGeod startPos = r->pointOnCenterline( fgGetDouble("/sim/airport/runways/start-offset-m", 5.0));
- fgApplyStartOffset(startPos, r->headingDeg());
- return true;
+ return false;
}
bool finalizeMetar()
{
+ if (!fgGetBool("/environment/realwx/enabled")) {
+ return true;
+ }
+
double hdg = fgGetDouble( "/environment/metar/base-wind-dir-deg", 9999.0 );
string apt = fgGetString("/sim/presets/airport-id");
string rwy = fgGetString("/sim/presets/runway");
if (needMetar) {
// timeout so we don't spin forever if the network is down
- if (global_finalizeTime.elapsedMSec() > fgGetInt("/sim/startup/metar-fetch-timeout-msec", 10000)) {
+ if (global_finalizeTime.elapsedMSec() > fgGetInt("/sim/startup/metar-fetch-timeout-msec", 6000)) {
SG_LOG(SG_GENERAL, SG_WARN, "finalizePosition: timed out waiting for METAR fetch");
return true;
}
+ if (fgGetBool( "/environment/metar/failure" )) {
+ SG_LOG(SG_ENVIRONMENT, SG_INFO, "metar download failed, not waiting");
+ return true;
+ }
+
if (!fgGetBool( "/environment/metar/valid" )) {
return false;
}