From 9f3a2ddbdcde529a465055e0c8bdb04eaa4e3377 Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Sun, 26 Jan 2014 16:05:45 +0000
Subject: [PATCH] Change default Windows terrasync path

Now use (new) SGPath::documents helper to download
to a user-visible location: Document\FlightGear.
(Linux & Mac behaviour is unchanged)
---
 src/Main/options.cxx | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/Main/options.cxx b/src/Main/options.cxx
index 7448eb6ed..241e77404 100644
--- a/src/Main/options.cxx
+++ b/src/Main/options.cxx
@@ -2106,6 +2106,20 @@ string_list Options::valuesForOption(const std::string& key) const
   return result;
 }
 
+
+static string defaultTerrasyncDir()
+{
+#if defined(SG_WINDOWS)
+	SGPath p(SGPath::documents());
+	p.append("FlightGear");
+#else
+    SGPath p(globals->get_fg_home());
+#endif
+	p.append("TerraSync");
+	return p.str();
+}
+
+
 OptionResult Options::processOptions()
 {
   // establish locale before showing help (this selects the default locale,
@@ -2169,15 +2183,16 @@ OptionResult Options::processOptions()
 // terrasync directory fixup
   string terrasyncDir = fgGetString("/sim/terrasync/scenery-dir");
   if (terrasyncDir.empty()) {
-    SGPath p(globals->get_fg_home());
-    p.append("TerraSync");
-    terrasyncDir = p.str();
-    SG_LOG(SG_GENERAL, SG_INFO,
-           "Using default TerraSync dir: " << terrasyncDir);
-    fgSetString("/sim/terrasync/scenery-dir", terrasyncDir);
+	  terrasyncDir = defaultTerrasyncDir();
+	  // auto-save it for next time
+	  
+	  SG_LOG(SG_GENERAL, SG_INFO,
+		  "Using default TerraSync: " << terrasyncDir);
+      fgSetString("/sim/terrasync/scenery-dir", terrasyncDir);
   }
-  
+
   SGPath p(terrasyncDir);
+
   // following is necessary to ensure NavDataCache sees stable scenery paths from
   // terrasync. Ensure the Terrain and Objects subdirs exist immediately, rather
   // than waiting for the first tiles to be scheduled.