]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_ctrl.cxx
Fix line endings
[flightgear.git] / src / Environment / environment_ctrl.cxx
index 87b79544aa9245e98c86652b810fd5e7565a68cb..0b901640b69c7eb7e3e978787ebd96f4b40d5d1e 100644 (file)
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <simgear/debug/logstream.hxx>
 
 #include <stdlib.h>
@@ -328,7 +332,8 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl ()
       _error_count( 0 ),
       _stale_count( 0 ),
       _dt( 0.0 ),
-      _error_dt( 0.0 )
+      _error_dt( 0.0 ),
+      last_apt(0)
 {
 #if defined(ENABLE_THREADS)
     thread = new MetarThread(this);
@@ -412,7 +417,7 @@ FGMetarEnvironmentCtrl::init ()
             if ( result.m != NULL ) {
                 SG_LOG( SG_GENERAL, SG_INFO, "closest station w/ metar = "
                         << a->getId());
-                last_apt = *a;
+                last_apt = a;
                 _icao = a->getId();
                 search_elapsed = 0.0;
                 fetch_elapsed = 0.0;
@@ -470,13 +475,13 @@ FGMetarEnvironmentCtrl::update(double delta_time_sec)
                              latitude->getDoubleValue(),
                              true );
         if ( a ) {
-            if ( last_apt.getId() != a->getId()
+            if ( !last_apt || last_apt->getId() != a->getId()
                  || fetch_elapsed > same_station_interval_sec )
             {
                 SG_LOG( SG_GENERAL, SG_INFO, "closest station w/ metar = "
                         << a->getId());
                 request_queue.push( a->getId() );
-                last_apt = *a;
+                last_apt = a;
                 _icao = a->getId();
                 search_elapsed = 0.0;
                 fetch_elapsed = 0.0;
@@ -702,6 +707,16 @@ FGMetarEnvironmentCtrl::update_metar_properties( const FGMetar *m )
 
 
 #if defined(ENABLE_THREADS)
+/**
+ * Ensure mutex is unlocked.
+ */
+void
+metar_cleanup_handler( void* arg )
+{
+    FGMetarEnvironmentCtrl* fetcher = (FGMetarEnvironmentCtrl*) arg;
+    fetcher->mutex.unlock();
+}
+
 /**
  *
  */
@@ -723,16 +738,6 @@ FGMetarEnvironmentCtrl::MetarThread::run()
     }
     pthread_cleanup_pop(1);
 }
-
-/**
- * Ensure mutex is unlocked.
- */
-void
-metar_cleanup_handler( void* arg )
-{
-    FGMetarEnvironmentCtrl* fetcher = (FGMetarEnvironmentCtrl*) arg;
-    fetcher->mutex.unlock();
-}
 #endif // ENABLE_THREADS