From 6d1267516101858004ac6e33c18aa55b925ac363 Mon Sep 17 00:00:00 2001 From: torsten Date: Mon, 8 Jun 2009 19:39:37 +0000 Subject: [PATCH] immediately fetch a metar if real-weather-fetch is re-enabled at runtime --- src/Environment/environment_ctrl.cxx | 16 ++++++++++++++-- src/Environment/environment_ctrl.hxx | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) 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; };