From e64a2db5a0a59558b6a4013fa9e3718bcbe3f487 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 19 Nov 2016 13:19:19 +0000 Subject: [PATCH] Remove the scenery path mangling. Requires a matching SG commit for correct operation. --- src/Main/globals.cxx | 25 +------------------------ src/Main/globals.hxx | 2 -- src/Main/options.cxx | 5 ++--- src/Navaids/NavDataCache.cxx | 2 +- src/Scenery/tilemgr.cxx | 14 ++++++++++++++ 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index ad48a9ef9..77af423b0 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -331,7 +331,7 @@ SGPath FGGlobals::find_data_dir(const std::string& pathSuffix) const void FGGlobals::append_fg_scenery (const PathList &paths) { - BOOST_FOREACH(const SGPath& path, paths) { + for (const SGPath& path : paths) { append_fg_scenery(path); } } @@ -363,32 +363,11 @@ void FGGlobals::append_fg_scenery (const SGPath &path) // needed to load Models from this scenery path simgear::ResourceManager::instance()->addBasePath(abspath.local8BitStr(), simgear::ResourceManager::PRIORITY_DEFAULT); - simgear::Dir dir(abspath); - SGPath terrainDir(dir.file("Terrain")); - SGPath objectsDir(dir.file("Objects")); - // this code used to add *either* the base dir, OR add the - // Terrain and Objects subdirs, but the conditional logic was commented - // out, such that all three dirs are added. Unfortunately there's - // no information as to why the change was made. fg_scenery.push_back(abspath); - unmangled_fg_scenery.push_back(abspath); extra_read_allowed_paths.push_back(abspath); - if (terrainDir.exists()) { - fg_scenery.push_back(terrainDir); - } - - if (objectsDir.exists()) { - fg_scenery.push_back(objectsDir); - } - - // insert a marker for FGTileEntry::load(), so that - // FG_SCENERY=A:B becomes list ["A/Terrain", "A/Objects", "", - // "B/Terrain", "B/Objects", ""] - fg_scenery.push_back(SGPath()); - // make scenery dirs available to Nasal SGPropertyNode* n = sim->getChild("fg-scenery", propIndex++, true); n->setStringValue(abspath.utf8Str()); @@ -411,9 +390,7 @@ void FGGlobals::append_read_allowed_paths(const SGPath &path) void FGGlobals::clear_fg_scenery() { fg_scenery.clear(); - unmangled_fg_scenery.clear(); fgGetNode("/sim", true)->removeChildren("fg-scenery"); - } // The 'path' argument to this method must come from trustworthy code, because diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 31a80f91a..b3b80c5cc 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -111,7 +111,6 @@ private: // Roots of FlightGear scenery tree PathList fg_scenery; - PathList unmangled_fg_scenery; // Paths Nasal is allowed to read PathList extra_read_allowed_paths; @@ -240,7 +239,6 @@ public: void set_terrasync_dir (const SGPath &path); const PathList &get_fg_scenery () const { return fg_scenery; } - const PathList &get_unmangled_fg_scenery () const { return unmangled_fg_scenery; } const PathList &get_extra_read_allowed_paths () const { return extra_read_allowed_paths; } /** * Add a scenery directory diff --git a/src/Main/options.cxx b/src/Main/options.cxx index b8a3edf5b..0f70dbcec 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2583,7 +2583,7 @@ void Options::showVersion() const cout << "FG_HOME=" << globals->get_fg_home().utf8Str() << endl; cout << "FG_SCENERY="; - PathList scn = globals->get_unmangled_fg_scenery(); + PathList scn = globals->get_fg_scenery(); cout << SGPath::join(scn, &SGPath::pathListSep) << endl; cout << "SimGear version: " << SG_STRINGIZE(SIMGEAR_VERSION) << endl; cout << "OSG version: " << osgGetVersion() << endl; @@ -2623,8 +2623,7 @@ void Options::printJSONReport() const cJSON_AddStringToObject(configNode, "FG_HOME", globals->get_fg_home().utf8Str().c_str()); - cJSON *sceneryPathsNode = p->createJSONArrayFromPathList( - globals->get_unmangled_fg_scenery()); + cJSON *sceneryPathsNode = p->createJSONArrayFromPathList(globals->get_fg_scenery()); cJSON_AddItemToObject(configNode, "scenery paths", sceneryPathsNode); cJSON *aircraftPathsNode = p->createJSONArrayFromPathList( diff --git a/src/Navaids/NavDataCache.cxx b/src/Navaids/NavDataCache.cxx index e779ce89f..5cb07b732 100644 --- a/src/Navaids/NavDataCache.cxx +++ b/src/Navaids/NavDataCache.cxx @@ -1029,7 +1029,7 @@ NavDataCache::DatFilesGroupInfo NavDataCache::NavDataCachePrivate::findDatFiles( SGPath visitedPath; // to avoid duplicates and time wasting const string datFilesSubDir = "NavData/" + NavDataCache::datTypeStr[datFileType]; - const PathList& sceneryPaths = globals->get_unmangled_fg_scenery(); + const PathList& sceneryPaths = globals->get_fg_scenery(); result.datFileType = datFileType; result.totalSize = 0; diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 6b92e2e8c..d99b59d44 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -185,6 +185,20 @@ void FGTileMgr::reinit() _options->setPluginStringData("SimGear::LOD_RANGE_DETAILED", fgGetString("/sim/rendering/static-lod/detailed", boost::lexical_cast(SG_OBJECT_RANGE_DETAILED))); _options->setPluginStringData("SimGear::RENDER_BUILDING_MESH", fgGetBool("/sim/rendering/building-mesh", false) ? "true" : "false"); + string_list scenerySuffixes; + for (auto node : fgGetNode("/sim/rendering/", true)->getChildren("scenery-path-suffix")) { + if (node->getBoolValue("enabled", true)) { + scenerySuffixes.push_back(node->getStringValue("name")); + } + } + + if (scenerySuffixes.empty()) { + // if preferences didn't load, use some default + scenerySuffixes = {"Objects", "Terrain"}; // defaut values + } + + _options->setSceneryPathSuffixes(scenerySuffixes); + if (state != Start) { // protect against multiple scenery reloads and properly reset flags,