]> git.mxchange.org Git - flightgear.git/commitdiff
Add 'set-scenery-paths' command.
authorJames Turner <zakalawe@mac.com>
Sat, 22 Feb 2014 16:13:36 +0000 (08:13 -0800)
committerJames Turner <zakalawe@mac.com>
Wed, 12 Mar 2014 18:56:19 +0000 (18:56 +0000)
src/Main/fg_commands.cxx
src/Main/globals.cxx
src/Main/globals.hxx

index e936b3a383919cb1c65a1c88fc4d248db77ed45e..9daf6db74dd1a5a4958f0da593e5cad9b5e39b53 100644 (file)
@@ -1407,6 +1407,41 @@ do_profiler_stop(const SGPropertyNode *arg)
 }
 
 
+static bool
+do_set_scenery_paths(const SGPropertyNode* arg)
+{
+  SGPropertyNode* sim = fgGetNode("/sim", true);
+  sim->removeChildren("fg-scenery");
+  
+  globals->clear_fg_scenery();
+  
+  std::string terrasyncPath(fgGetString("/sim/terrasync/scenery-dir"));
+  bool seenTerrasyncPath = false;
+  
+  simgear::PropertyList paths = arg->getChildren("path");
+  for (size_t i = 0; i < paths.size(); ++i) {
+    std::string s = paths[i]->getStringValue();
+    if (s == terrasyncPath) {
+      seenTerrasyncPath = true;
+    }
+    
+    globals->append_fg_scenery(s);
+  }
+  
+  if (fgGetBool("/sim/terrasync/enabled") && !seenTerrasyncPath) {
+    globals->append_fg_scenery(terrasyncPath);
+  }
+  
+  if (paths.empty()) {
+    // no scenery paths set *at all*, use the data in FG_ROOT
+    SGPath root(globals->get_fg_root());
+    root.append("Scenery");
+    globals->append_fg_scenery(root.str());
+  }
+  
+  return true;
+}
+
 ////////////////////////////////////////////////////////////////////////
 // Command setup.
 ////////////////////////////////////////////////////////////////////////
@@ -1481,7 +1516,8 @@ static struct {
     { "print-visible-scene", do_print_visible_scene_info },
     { "reload-shaders", do_reload_shaders },
     { "reload-materials", do_materials_reload },
-
+    { "set-scenery-paths", do_set_scenery_paths },
+  
     { "profiler-start", do_profiler_start },
     { "profiler-stop",  do_profiler_stop },
 
index 2617067d26944a94296935bcfb8b4808a55ffcc0..e3b21f790e8c5e979dfcab0c2279b2b5075d8d0d 100644 (file)
@@ -339,7 +339,6 @@ SGPath FGGlobals::find_data_dir(const std::string& pathSuffix) const
 
 void FGGlobals::append_fg_scenery (const std::string &paths)
 {
-//    fg_scenery.clear();
     SGPropertyNode* sim = fgGetNode("/sim", true);
 
   // find first unused fg-scenery property in /sim
@@ -395,6 +394,11 @@ void FGGlobals::append_fg_scenery (const std::string &paths)
     } // of path list iteration
 }
 
+void FGGlobals::clear_fg_scenery()
+{
+  fg_scenery.clear();
+}
+
 void FGGlobals::append_aircraft_path(const std::string& path)
 {
   SGPath dirPath(path);
index 8e04f478f8fd7ff099b31c6822c7fd191f25f66e..0569a71299463d404a29b8d22b4d970ca34001bc 100644 (file)
@@ -219,6 +219,8 @@ public:
     inline const string_list &get_fg_scenery () const { return fg_scenery; }
     void append_fg_scenery (const std::string &scenery);
 
+    void clear_fg_scenery();
+  
     const string_list& get_aircraft_paths() const { return fg_aircraft_dirs; }
     void append_aircraft_path(const std::string& path);
     void append_aircraft_paths(const std::string& path);