diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index b11dc450e..79b86bea7 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -836,7 +836,8 @@ FGMetarFetcher::FGMetarFetcher() : search_timer(0.0), error_timer(0.0), _stale_count(0), - _error_count(0) + _error_count(0), + enabled(false) { longitude_n = fgGetNode( "/position/longitude-deg", true ); latitude_n = fgGetNode( "/position/latitude-deg", true ); @@ -901,8 +902,19 @@ void FGMetarFetcher::update (double delta_time_sec) _error_count = 0; } - if( enable_n->getBoolValue() == false ) + if( enable_n->getBoolValue() == false ) { + enabled = false; return; + } + + // we were just enabled, reset all timers to + // trigger immediate metar fetch + if( !enabled ) { + search_timer = 0.0; + fetch_timer = 0.0; + error_timer = error_timer_sec; + enabled = true; + } FGAirport * a = NULL; diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx index a64155798..f5a5024cc 100644 --- a/src/Environment/environment_ctrl.hxx +++ b/src/Environment/environment_ctrl.hxx @@ -249,6 +249,7 @@ private: long _stale_count; long _error_count; + bool enabled; };