]> git.mxchange.org Git - flightgear.git/commitdiff
Allow aircraft-dir option to override aircraft search logic completely.
authorJames Turner <zakalawe@mac.com>
Sun, 16 Oct 2011 20:15:54 +0000 (21:15 +0100)
committerJames Turner <zakalawe@mac.com>
Sun, 16 Oct 2011 20:15:54 +0000 (21:15 +0100)
src/Main/fg_init.cxx
src/Main/options.cxx

index 3a3bad44f380c4da9411890ff413776315f814bd..a504c7cb8f8a409185a700f37425ab9784f8d497 100644 (file)
@@ -338,6 +338,29 @@ public:
     }
     
     _searchAircraft = aircraft + "-set.xml";
+    std::string aircraftDir = fgGetString("/sim/aircraft-dir", "");
+    if (!aircraftDir.empty()) {
+      // aircraft-dir was set, skip any searching at all, if it's valid
+      simgear::Dir acPath(aircraftDir);
+      SGPath setFile = acPath.file(_searchAircraft);
+      if (setFile.exists()) {
+        SG_LOG(SG_GENERAL, SG_INFO, "found aircraft in dir: " << aircraftDir );
+        
+        try {
+          readProperties(setFile.str(), globals->get_props());
+        } catch ( const sg_exception &e ) {
+          SG_LOG(SG_INPUT, SG_ALERT, "Error reading aircraft: " << e.getFormattedMessage());
+          return false;
+        }
+        
+        return true;
+      } else {
+        SG_LOG(SG_GENERAL, SG_ALERT, "aircraft '" << _searchAircraft << 
+               "' not found in specified dir:" << aircraftDir);
+        return false;
+      }
+    }
+    
     if (!checkCache()) {
       // prepare cache for re-scan
       SGPropertyNode *n = _cache->getNode("fg-root", true);
index b769221425b0d457a0364277195a84ebc8339de2..d6ab0b7dffa08d7f58f2f397212c6e37b5123325 100644 (file)
@@ -1395,7 +1395,7 @@ struct OptionDesc {
     {"fg-aircraft",                  true,  OPTION_IGNORE | OPTION_MULTI,   "", false, "", 0 },
     {"fdm",                          true,  OPTION_STRING, "/sim/flight-model", false, "", 0 },
     {"aero",                         true,  OPTION_STRING, "/sim/aero", false, "", 0 },
-    {"aircraft-dir",                 true,  OPTION_STRING, "/sim/aircraft-dir", false, "", 0 },
+    {"aircraft-dir",                 true,  OPTION_IGNORE,   "", false, "", 0 },
     {"model-hz",                     true,  OPTION_INT,    "/sim/model-hz", false, "", 0 },
     {"speed",                        true,  OPTION_INT,    "/sim/speed-up", false, "", 0 },
     {"trim",                         false, OPTION_BOOL,   "/sim/presets/trim", true, "", 0 },
@@ -1764,6 +1764,11 @@ void Options::initAircraft()
     fgShowAircraft(path);
     exit(0);
   }
+  
+  if (isOptionSet("aircraft-dir")) {
+    // set this now, so it's available in FindAndCacheAircraft
+    fgSetString("/sim/aircraft-dir", valueForOption("aircraft-dir"));
+  }
 }
   
 void Options::processArgResult(int result)