From d23628a9ceae5d740de1273f0557263814da46c6 Mon Sep 17 00:00:00 2001 From: torsten Date: Tue, 23 Jun 2009 20:23:37 +0000 Subject: [PATCH] hack to stop startup.nas complaining if metar arrives after nasal-dir-initialized is fired. Immediately fetch and wait for the METAR before continuing. This gets the /environment/metar/xxx properties filled before nasal-dir is initialized. --- src/Environment/environment_ctrl.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index 79b86bea7..68c6e31c9 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -875,6 +875,17 @@ void FGMetarFetcher::init () _stale_count = 0; _error_count = 0; current_airport_id.clear(); + /* Torsten Dreyer: + hack to stop startup.nas complaining if metar arrives after nasal-dir-initialized + is fired. Immediately fetch and wait for the METAR before continuing. This gets the + /environment/metar/xxx properties filled before nasal-dir is initialized. + Maybe the runway selection should happen here to make startup.nas obsolete? + */ + const char * startup_airport = fgGetString("/sim/startup/options/airport"); + if( *startup_airport ) { + current_airport_id = startup_airport; + fetch( current_airport_id ); + } } void FGMetarFetcher::reinit () @@ -945,6 +956,9 @@ void FGMetarFetcher::update (double delta_time_sec) void FGMetarFetcher::fetch( const string & id ) { + if( enable_n->getBoolValue() == false ) + return; + SGSharedPtr result = NULL; // fetch current metar data @@ -966,7 +980,7 @@ void FGMetarFetcher::fetch( const string & id ) } } else { _stale_count = 0; - } + } } catch (const sg_io_exception& e) { SG_LOG( SG_GENERAL, SG_WARN, "Error fetching live weather data: " << e.getFormattedMessage().c_str() );