From 407a49554681ba41617a0298e466fd55b4f8ec5c Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 16 Oct 2011 21:46:27 +0100 Subject: [PATCH] Automate TerraSync integration with the scenery / dir creation. Now can be used with only --enable-terrasync (and some patience) --- src/Main/options.cxx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index d6ab0b7df..e63fac009 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1953,9 +1953,33 @@ void Options::processOptions() if (envp) { globals->append_fg_scenery(envp); } + +// terrasync directory fixup + if (fgGetBool("/sim/terrasync/enabled")) { + string terrasyncDir = fgGetString("/sim/terrasync/scenery-dir"); + if (terrasyncDir.empty()) { + SGPath p(fgGetString("/sim/fg-home")); + p.append("TerraSync"); + if (!p.exists()) { + simgear::Dir dd(p); + dd.create(0700); + } + + terrasyncDir = p.str(); + SG_LOG(SG_GENERAL, SG_INFO, + "Using default TerraSync dir: " << terrasyncDir); + fgSetString("/sim/terrasync/scenery-dir", terrasyncDir); + } + + const string_list& scenery_paths(globals->get_fg_scenery()); + if (std::find(scenery_paths.begin(), scenery_paths.end(), terrasyncDir) == scenery_paths.end()) { + // terrasync dir is not in the scenery paths, add it + globals->append_fg_scenery(terrasyncDir); + } + } if (globals->get_fg_scenery().empty()) { - // no scenery paths set *at all*, use the data in FG_ROOT + // no scenery paths set *at all*, use the data in FG_ROOT SGPath root(globals->get_fg_root()); root.append("Scenery"); globals->append_fg_scenery(root.str());