Tweaks to startup configuration handling
- 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)
This commit is contained in:
parent
d5b70e98e0
commit
e93dc27153
4 changed files with 29 additions and 3 deletions
|
@ -434,9 +434,10 @@ int fgInitConfig ( int argc, char **argv )
|
||||||
SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
|
SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
|
||||||
fgLoadProps("preferences.xml", globals->get_props());
|
fgLoadProps("preferences.xml", globals->get_props());
|
||||||
SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
|
SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
|
||||||
|
|
||||||
// do not load user settings when reset to default is requested
|
// do not load user settings when reset to default is requested, or if
|
||||||
if (flightgear::Options::sharedInstance()->isOptionSet("restore-defaults"))
|
// told to explicitly ignore
|
||||||
|
if (options->isOptionSet("restore-defaults") || options->isOptionSet("ignore-autosave"))
|
||||||
{
|
{
|
||||||
SG_LOG(SG_ALL, SG_ALERT, "Ignoring user settings. Restoring defaults.");
|
SG_LOG(SG_ALL, SG_ALERT, "Ignoring user settings. Restoring defaults.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,16 @@ static void fgIdleFunction ( void ) {
|
||||||
// and airports data in parallel with a nav-cache rebuild.
|
// and airports data in parallel with a nav-cache rebuild.
|
||||||
SGPath tsyncCache(globals->get_fg_home());
|
SGPath tsyncCache(globals->get_fg_home());
|
||||||
tsyncCache.append("terrasync-cache.xml");
|
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());
|
fgSetString("/sim/terrasync/cache-path", tsyncCache.c_str());
|
||||||
|
|
||||||
simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props());
|
simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props());
|
||||||
|
|
|
@ -1206,6 +1206,14 @@ fgOptCallSign(const char * arg)
|
||||||
return FG_OPTIONS_OK;
|
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>
|
// Set a property for the --prop: option. Syntax: --prop:[<type>:]<name>=<value>
|
||||||
// <type> can be "double" etc. but also only the first letter "d".
|
// <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 },
|
{"enable-fullscreen", false, OPTION_BOOL, "/sim/startup/fullscreen", true, "", 0 },
|
||||||
{"disable-save-on-exit", false, OPTION_BOOL, "/sim/startup/save-on-exit", false, "", 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 },
|
{"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 },
|
{"restore-defaults", false, OPTION_BOOL, "/sim/startup/restore-defaults", true, "", 0 },
|
||||||
{"shading-flat", false, OPTION_BOOL, "/sim/rendering/shading", false, "", 0 },
|
{"shading-flat", false, OPTION_BOOL, "/sim/rendering/shading", false, "", 0 },
|
||||||
{"shading-smooth", false, OPTION_BOOL, "/sim/rendering/shading", true, "", 0 },
|
{"shading-smooth", false, OPTION_BOOL, "/sim/rendering/shading", true, "", 0 },
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#include <simgear/threads/SGGuard.hxx>
|
#include <simgear/threads/SGGuard.hxx>
|
||||||
|
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
|
#include <Main/options.hxx>
|
||||||
#include "markerbeacon.hxx"
|
#include "markerbeacon.hxx"
|
||||||
#include "navrecord.hxx"
|
#include "navrecord.hxx"
|
||||||
#include <Airports/airport.hxx>
|
#include <Airports/airport.hxx>
|
||||||
|
@ -1096,6 +1097,11 @@ NavDataCache* NavDataCache::instance()
|
||||||
|
|
||||||
bool NavDataCache::isRebuildRequired()
|
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) ||
|
if (isCachedFileModified(d->aptDatPath) ||
|
||||||
isCachedFileModified(d->metarDatPath) ||
|
isCachedFileModified(d->metarDatPath) ||
|
||||||
isCachedFileModified(d->navDatPath) ||
|
isCachedFileModified(d->navDatPath) ||
|
||||||
|
|
Loading…
Add table
Reference in a new issue