X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fpositioninit.cxx;h=337ab7141fdc73e54e0592f4ecaa5c0696159ad8;hb=0c00cd3c6d34e4e167457897a274864cb7236da6;hp=681296687ba771a8732384586ff1cbcf992a685a;hpb=6954360dfa82f4be96493a74e3d52c41db4dff7c;p=flightgear.git diff --git a/src/Main/positioninit.cxx b/src/Main/positioninit.cxx index 681296687..337ab7141 100644 --- a/src/Main/positioninit.cxx +++ b/src/Main/positioninit.cxx @@ -196,7 +196,7 @@ static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& par SG_LOG( SG_GENERAL, SG_ALERT, "Failed to find airport " << id ); return false; } - FGAirportDynamics* dcs = apt->getDynamics(); + FGAirportDynamicsRef dcs = apt->getDynamics(); if (!dcs) { SG_LOG( SG_GENERAL, SG_ALERT, "Airport " << id << "does not appear to have parking information available"); @@ -213,24 +213,24 @@ static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& par string acfile = fgGetString("/sim/aircraft") + string(".xml"); acData.append(acfile); SGPropertyNode root; - readProperties(acData.str(), &root); + readProperties(acData, &root); SGPropertyNode * node = root.getNode("sim"); fltType = node->getStringValue("aircraft-class", "NONE" ); acOperator = node->getStringValue("aircraft-operator", "NONE" ); } catch (const sg_exception &) { SG_LOG(SG_GENERAL, SG_INFO, - "Could not load aircraft aircrat type and operator information from: " << acData.str() << ". Using defaults"); + "Could not load aircraft aircrat type and operator information from: " << acData << ". Using defaults"); // cout << path.str() << endl; } if (fltType.empty() || fltType == "NONE") { SG_LOG(SG_GENERAL, SG_INFO, - "Aircraft type information not found in: " << acData.str() << ". Using default value"); + "Aircraft type information not found in: " << acData << ". Using default value"); fltType = fgGetString("/sim/aircraft-class" ); } if (acOperator.empty() || fltType == "NONE") { SG_LOG(SG_GENERAL, SG_INFO, - "Aircraft operator information not found in: " << acData.str() << ". Using default value"); + "Aircraft operator information not found in: " << acData << ". Using default value"); acOperator = fgGetString("/sim/aircraft-operator" ); } @@ -261,7 +261,7 @@ static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& par // The parking will be released after this function returns. // As a temporary measure, I'll try to reserve the parking via the atc_manager, which should work, because it uses the same // mechanism as the AI traffic code. - dcs->setParkingAvailable(pka.parking()->guid(), false); + dcs->setParkingAvailable(pka.parking(), false); fgApplyStartOffset(pka.parking()->geod(), pka.parking()->getHeading()); return true; } @@ -599,10 +599,20 @@ bool initPosition() } if ( !set_pos ) { - // No lon/lat specified, no airport specified, default to - // middle of KSFO field. - fgSetDouble("/sim/presets/longitude-deg", -122.374843); - fgSetDouble("/sim/presets/latitude-deg", 37.619002); + // No lon/lat specified, no airport specified, use the default airport + // TODO: don't hardcode this + const FGAirport* airport = fgFindAirportID("LEBL"); + if( airport ) { + const SGGeod & airportGeod = airport->geod(); + fgSetDouble("/sim/presets/longitude-deg", airportGeod.getLongitudeDeg()); + fgSetDouble("/sim/presets/latitude-deg", airportGeod.getLatitudeDeg()); + } else { + // So, the default airport is unknown? We are in serious trouble. + // Let's hope KSFO still exists somehow + fgSetDouble("/sim/presets/longitude-deg", -122.374843); + fgSetDouble("/sim/presets/latitude-deg", 37.619002); + SG_LOG(SG_GENERAL, SG_ALERT, "Sorry, the default airport seems to be unknown."); + } } fgSetDouble( "/position/longitude-deg",