diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 8aaeeb430..5353dca7c 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -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."); } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 12d55fdd1..26ac132ab 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -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()); diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 9be906cba..cee21855c 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -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:[:]= // 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 }, diff --git a/src/Navaids/NavDataCache.cxx b/src/Navaids/NavDataCache.cxx index a17c8c6ea..28b8a636b 100644 --- a/src/Navaids/NavDataCache.cxx +++ b/src/Navaids/NavDataCache.cxx @@ -58,6 +58,7 @@ #include #include
+#include
#include "markerbeacon.hxx" #include "navrecord.hxx" #include @@ -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) ||