]> git.mxchange.org Git - flightgear.git/commitdiff
Tweaks to startup configuration handling
authorJames Turner <zakalawe@mac.com>
Sat, 26 Oct 2013 17:29:23 +0000 (18:29 +0100)
committerJames Turner <zakalawe@mac.com>
Sat, 26 Oct 2013 17:29:31 +0000 (18:29 +0100)
- restore-defaults kills the nav cache, terra-sync cache
- new ignore-autosave option bypasses autosave.xml and leaves it
  untouched (does not over-write on exit)

src/Main/fg_init.cxx
src/Main/main.cxx
src/Main/options.cxx
src/Navaids/NavDataCache.cxx

index 8aaeeb4306d8097aefd036474d1292b588a10c9b..5353dca7c8c7fc22e03f23891fb60e041b3b37a7 100644 (file)
@@ -434,9 +434,10 @@ int fgInitConfig ( int argc, char **argv )
       SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
       fgLoadProps("preferences.xml", globals->get_props());
       SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
-
-      // do not load user settings when reset to default is requested
-      if (flightgear::Options::sharedInstance()->isOptionSet("restore-defaults"))
+        
+      // do not load user settings when reset to default is requested, or if
+      // told to explicitly ignore
+      if (options->isOptionSet("restore-defaults") || options->isOptionSet("ignore-autosave"))
       {
           SG_LOG(SG_ALL, SG_ALERT, "Ignoring user settings. Restoring defaults.");
       }
index 12d55fdd1f6e31f79280e51618eb6919d355307d..26ac132abfff94463e61d5509c23e68e7aa1a1bf 100644 (file)
@@ -131,6 +131,16 @@ static void fgIdleFunction ( void ) {
         // and airports data in parallel with a nav-cache rebuild.
         SGPath tsyncCache(globals->get_fg_home());
         tsyncCache.append("terrasync-cache.xml");
+        
+        // wipe the cache file if requested
+        if (flightgear::Options::sharedInstance()->isOptionSet("restore-defaults")) {
+            SG_LOG(SG_GENERAL, SG_INFO, "restore-defaults requested, wiping terrasync update cache at " <<
+                   tsyncCache);
+            if (tsyncCache.exists()) {
+                tsyncCache.remove();
+            }
+        }
+        
         fgSetString("/sim/terrasync/cache-path", tsyncCache.c_str());
         
         simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props());
index 9be906cba0de78fcba939abf7f4a6467f0e3816e..cee21855ca5a922909fb88b1b4fe3910fbd3d0c0 100644 (file)
@@ -1206,6 +1206,14 @@ fgOptCallSign(const char * arg)
     return FG_OPTIONS_OK;
 }
 
+static int
+fgOptIgnoreAutosave(const char* arg)
+{
+    fgSetBool("/sim/startup/ignore-autosave", true);
+    // don't overwrite autosave on exit
+    fgSetBool("/sim/startup/save-on-exit", false);
+    return FG_OPTIONS_OK;
+}
 
 // Set a property for the --prop: option. Syntax: --prop:[<type>:]<name>=<value>
 // <type> can be "double" etc. but also only the first letter "d".
@@ -1403,6 +1411,7 @@ struct OptionDesc {
     {"enable-fullscreen",            false, OPTION_BOOL,   "/sim/startup/fullscreen", true, "", 0 },
     {"disable-save-on-exit",         false, OPTION_BOOL,   "/sim/startup/save-on-exit", false, "", 0 },
     {"enable-save-on-exit",          false, OPTION_BOOL,   "/sim/startup/save-on-exit", true, "", 0 },
+    {"ignore-autosave",              false, OPTION_FUNC,   "", false, "", fgOptIgnoreAutosave },
     {"restore-defaults",             false, OPTION_BOOL,   "/sim/startup/restore-defaults", true, "", 0 },
     {"shading-flat",                 false, OPTION_BOOL,   "/sim/rendering/shading", false, "", 0 },
     {"shading-smooth",               false, OPTION_BOOL,   "/sim/rendering/shading", true, "", 0 },
index a17c8c6eaa67c4e83e31496804c8e8e618e88ad0..28b8a636b1d23afcbbb3890f33e139c4e11f4cb9 100644 (file)
@@ -58,6 +58,7 @@
 #include <simgear/threads/SGGuard.hxx>
 
 #include <Main/globals.hxx>
+#include <Main/options.hxx>
 #include "markerbeacon.hxx"
 #include "navrecord.hxx"
 #include <Airports/airport.hxx>
@@ -1096,6 +1097,11 @@ NavDataCache* NavDataCache::instance()
   
 bool NavDataCache::isRebuildRequired()
 {
+    if (flightgear::Options::sharedInstance()->isOptionSet("restore-defaults")) {
+        SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: restore-defaults requested, will rebuild cache");
+        return true;
+    }
+    
   if (isCachedFileModified(d->aptDatPath) ||
       isCachedFileModified(d->metarDatPath) ||
       isCachedFileModified(d->navDatPath) ||