]> 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 20c1c20768bc55181bcba5c3a3a2023107817098..97777dcb27ef5a46983506df99492fa13e40f57d 100644 (file)
@@ -117,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