]> git.mxchange.org Git - flightgear.git/commitdiff
Guard against saved bad terrasync path.
authorJames Turner <zakalawe@mac.com>
Sun, 4 Jan 2015 17:50:10 +0000 (17:50 +0000)
committerJames Turner <zakalawe@mac.com>
Sun, 4 Jan 2015 18:02:26 +0000 (18:02 +0000)
- warn when the terrasync path is not writeable, with a message box.

src/Main/options.cxx

index 48efc9c50c7cd9b8a6c560432cefa07e6a3a200e..7ba86d8271300227891ac0896bcdc6d75a66b5a4 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <iostream>
 #include <string>
+#include <sstream>
 
 #include <simgear/math/sg_random.h>
 #include <simgear/props/props_io.hxx>
@@ -2225,7 +2226,7 @@ OptionResult Options::processOptions()
   }
     
 // terrasync directory fixup
-  string terrasyncDir = fgGetString("/sim/terrasync/scenery-dir");
+    string terrasyncDir = simgear::strutils::strip(fgGetString("/sim/terrasync/scenery-dir"));
   if (terrasyncDir.empty()) {
          terrasyncDir = defaultTerrasyncDir();
          // auto-save it for next time
@@ -2249,6 +2250,17 @@ OptionResult Options::processOptions()
   if (!objectsDir.exists()) {
       objectsDir.create(0755);
   }
+
+    // check the above actuall worked
+    if (!objectsDir.exists() || !terrainDir.exists()) {
+        std::stringstream ss;
+        ss << "Scenery download will be disabled. The configured location is '" << terrasyncDir << "'.";
+        flightgear::modalMessageBox("Invalid scenery download location",
+                                    "Automatic scenery download is configured to use a location (path) which invalid.",
+                                    ss.str());
+        fgSetBool("/sim/terrasync/enabled", false);
+    }
+
   if (fgGetBool("/sim/terrasync/enabled")) {
     const string_list& scenery_paths(globals->get_fg_scenery());
     if (std::find(scenery_paths.begin(), scenery_paths.end(), terrasyncDir) == scenery_paths.end()) {