]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/util.cxx
since the submodel_mgr subsystem does now also hold references to AI models,
[flightgear.git] / src / Main / util.cxx
index 9525f1d582553cd6760ba5a19eccfb41ba143f00..056b9c4ed7c4545f4d9f8d3ccc34001a76a89280 100644 (file)
@@ -1,5 +1,5 @@
 // util.cxx - general-purpose utility functions.
-// Copyright (C) 2002  Curtis L. Olson  - curt@me.umn.edu
+// Copyright (C) 2002  Curtis L. Olson  - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -13,7 +13,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
@@ -32,6 +32,9 @@ SG_USING_STD(vector);
 #include "globals.hxx"
 #include "util.hxx"
 
+#ifdef OSG_LIBRARY_STATIC
+#include "osgDB/Registry"
+#endif
 
 void
 fgDefaultWeatherValue (const char * propname, double value)
@@ -98,27 +101,29 @@ fgSetupWind (double min_hdg, double max_hdg, double speed, double gust)
               min_hdg);
   fgSetDouble("/environment/config/aloft/entry[2]/wind-speed-kt",
               speed);
-
-#ifdef FG_WEATHERCM
-  // convert to fps
-  speed *= SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600);
-  while (min_hdg > 360)
-    min_hdg -= 360;
-  while (min_hdg <= 0)
-    min_hdg += 360;
-  min_hdg *= SGD_DEGREES_TO_RADIANS;
-  fgSetDouble("/environment/wind-from-north-fps", speed * cos(dir));
-  fgSetDouble("/environment/wind-from-east-fps", speed * sin(dir));
-#endif // FG_WEATHERCM
 }
 
 
 void
 fgExit (int status)
 {
-    SG_LOG(SG_GENERAL, SG_INFO, "Exiting FlightGear with status " << status);
+    // remove subsystems first, which need access to other subsystems in their
+    // destructors (e.g. "nasal")
+    SGSubsystem *sub;
+
+    sub = globals->get_subsystem("ai_model");
+    globals->get_subsystem_mgr()->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("ai_model");
+    delete sub;
 
-    globals->get_io()->shutdown_all();
+    sub = globals->get_subsystem("submodel_mgr");
+    globals->get_subsystem_mgr()->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("submodel_mgr");
+    delete sub;
+
+#ifdef OSG_LIBRARY_STATIC
+    osgDB::Registry::instance( true);
+#endif
+
+    SG_LOG(SG_GENERAL, SG_INFO, "Exiting FlightGear with status " << status);
     exit(status);
 }