From: James Turner Date: Sat, 22 Feb 2014 16:13:36 +0000 (-0800) Subject: Add 'set-scenery-paths' command. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c7f29929045bbe80012be1b833b29d58e03ccb35;p=flightgear.git Add 'set-scenery-paths' command. --- diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index e936b3a38..9daf6db74 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -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 }, diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 2617067d2..e3b21f790 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -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); diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 8e04f478f..0569a7129 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -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);