]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/globals.cxx
Make use of the new SGPath::add() function and automatically append 'Terren' and...
[flightgear.git] / src / Main / globals.cxx
index 204c298909de760100cbaad2029aaf9ca944940f..97777dcb27ef5a46983506df99492fa13e40f57d 100644 (file)
@@ -21,6 +21,7 @@
 // $Id$
 
 
+#include <simgear/sound/soundmgr_openal.hxx>
 #include <simgear/structure/commands.hxx>
 #include <simgear/misc/sg_path.hxx>
 
@@ -54,8 +55,7 @@ FGGlobals::FGGlobals() :
     time_params( NULL ),
     ephem( NULL ),
     mag( NULL ),
-    autopilot( NULL ),
-    route( NULL ),
+    route_mgr( NULL ),
     current_panel( NULL ),
     soundmgr( NULL ),
     airports( NULL ),
@@ -72,9 +72,16 @@ FGGlobals::FGGlobals() :
     acmodel( NULL ),
     model_mgr( NULL ),
     channel_options_list( NULL ),
+    initial_waypoints(0),
     scenery( NULL ),
     tile_mgr( NULL ),
-    io( new FGIO )
+    io( new FGIO ),
+    navlist( NULL ),
+    loclist( NULL ),
+    gslist( NULL ),
+    dmelist( NULL ),
+    mkrlist( NULL ),
+    fixlist( NULL )
 {
 }
 
@@ -82,12 +89,18 @@ FGGlobals::FGGlobals() :
 // Destructor
 FGGlobals::~FGGlobals() 
 {
-  delete subsystem_mgr;
-  delete event_mgr;
-  delete initial_state;
-  delete props;
-  delete commands;
-  delete io;
+    delete soundmgr;
+    delete subsystem_mgr;
+    delete event_mgr;
+    delete initial_state;
+    delete props;
+    delete commands;
+    delete io;
+  
+    // make sure only to delete the initial waypoints list if it acually
+    // still exists. 
+    if (initial_waypoints)
+        delete initial_waypoints;
 }
 
 
@@ -104,6 +117,38 @@ void FGGlobals::set_fg_root (const string &root) {
         }
 }
 
+void FGGlobals::set_fg_scenery (const string &scenery) {
+
+    if (scenery.empty())
+        return;
+
+    SGPath pt( scenery ), po( scenery );
+    pt.append("Terrain");
+    po.append("Objects");
+
+cout << "pt: " << pt.str() << endl;
+cout << "po: " << po.str() << endl;
+    ulDir *td = ulOpenDir(pt.c_str());
+    ulDir *od = ulOpenDir(po.c_str());
+
+    if (td == NULL) {
+        if (od == NULL) {
+            fg_scenery = scenery;
+        } else {
+            fg_scenery = po.str();
+            ulCloseDir(od);
+        }
+    } else {
+        if (od != NULL) {
+            pt.add(po.str());
+            ulCloseDir(od);
+        }
+        fg_scenery = pt.str();
+        ulCloseDir(td);
+    }
+cout << "fg_scenery: " << fg_scenery << endl;
+}
+
 
 SGSubsystemMgr *
 FGGlobals::get_subsystem_mgr () const