From: James Turner Date: Wed, 15 Jan 2014 17:10:12 +0000 (+0000) Subject: Tweaks to fg-aircraft handling. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2b55acd3eba188cc0b286b98b48f1f7bc1f5ef5c;p=flightgear.git Tweaks to fg-aircraft handling. Warn (but do not require, since people would probably complain) when added paths do not contain an Aircraft subdir. When people specify a path which ends in /Aircraft, use the parent directory. --- diff --git a/src/Main/AircraftDirVisitorBase.hxx b/src/Main/AircraftDirVisitorBase.hxx index cb216c797..1096a788d 100644 --- a/src/Main/AircraftDirVisitorBase.hxx +++ b/src/Main/AircraftDirVisitorBase.hxx @@ -46,7 +46,16 @@ protected: const string_list& paths(globals->get_aircraft_paths()); string_list::const_iterator it = paths.begin(); for (; it != paths.end(); ++it) { - VisitResult vr = visitDir(simgear::Dir(*it), 0); + SGPath p(*it); + // additional aircraft-paths are supposed to specify the directory + // containing the 'Aircraft' dir (same structure as fg-root, so cross- + // aircraft resource paths can be resolved correctly). Some users omit + // this, so check for both. + p.append("Aircraft"); + if (!p.exists()) + p = SGPath(*it); + + VisitResult vr = visitDir(p, 0); if (vr != VISIT_CONTINUE) { return vr; } diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 3f469d05a..d0a3d102e 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -401,9 +401,23 @@ void FGGlobals::append_aircraft_path(const std::string& path) { SGPath dirPath(path); if (!dirPath.exists()) { - SG_LOG(SG_GENERAL, SG_WARN, "aircraft path not found:" << path); + SG_LOG(SG_GENERAL, SG_ALERT, "aircraft path not found:" << path); return; } + + SGPath acSubdir(dirPath); + acSubdir.append("Aircraft"); + if (!acSubdir.exists()) { + if (dirPath.file() == "Aircraft") { + dirPath = dirPath.dir(); + SG_LOG(SG_GENERAL, SG_WARN, "Specified an aircraft-dir path ending in 'Aircraft':" << path + << ", will instead use parent directory:" << dirPath); + } else { + SG_LOG(SG_GENERAL, SG_ALERT, "Aircraft-dir path '" << path << + "' does not contain an 'Aircraft' subdirectory, cross-aircraft paths will not resolve correctly."); + } + } + std::string abspath = dirPath.realpath(); unsigned int index = fg_aircraft_dirs.size();