home->setStringValue(dataPath.c_str());
home->setAttribute(SGPropertyNode::WRITE, false);
- flightgear::Options::sharedInstance()->init(argc, argv, dataPath);
+ flightgear::Options* options = flightgear::Options::sharedInstance();
+ options->init(argc, argv, dataPath);
+ bool loadDefaults = flightgear::Options::sharedInstance()->shouldLoadDefaultConfig();
+ if (loadDefaults) {
+ // Read global preferences from $FG_ROOT/preferences.xml
+ 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"))
+ {
+ SG_LOG(SG_ALL, SG_ALERT, "Ignoring user settings. Restoring defaults.");
+ }
+ else
+ {
+ globals->loadUserSettings(dataPath);
+ }
+ } else {
+ SG_LOG(SG_GENERAL, SG_INFO, "not reading default configuration files");
+ }// of no-default-config selected
- // Read global preferences from $FG_ROOT/preferences.xml
- 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"))
- {
- SG_LOG(SG_ALL, SG_ALERT, "Ignoring user settings. Restoring defaults.");
- }
- else
- {
- globals->loadUserSettings(dataPath);
- }
-
// Scan user config files and command line for a specified aircraft.
- flightgear::Options::sharedInstance()->initAircraft();
+ options->initAircraft();
FindAndCacheAircraft f(globals->get_props());
if (!f.loadAircraft()) {
// parse options after loading aircraft to ensure any user
// overrides of defaults are honored.
- flightgear::Options::sharedInstance()->processOptions();
+ options->processOptions();
return true;
}
FG_OPTIONS_EXIT = 3,
FG_OPTIONS_VERBOSE_HELP = 4,
FG_OPTIONS_SHOW_AIRCRAFT = 5,
- FG_OPTIONS_SHOW_SOUND_DEVICES = 6
+ FG_OPTIONS_SHOW_SOUND_DEVICES = 6,
+ FG_OPTIONS_NO_DEFAULT_CONFIG = 7
};
static flightgear::Options* shared_instance = NULL;
{"version", false, OPTION_FUNC, "", false, "", fgOptVersion },
{"enable-fpe", false, OPTION_IGNORE, "", false, "", 0},
{"fgviewer", false, OPTION_IGNORE, "", false, "", 0},
+ {"no-default-config", false, OPTION_IGNORE, "", false, "", 0},
{"prop", true, OPTION_FUNC | OPTION_MULTI, "", false, "", fgOptSetProperty},
{0}
};
bool showHelp,
verbose,
- showAircraft;
+ showAircraft,
+ shouldLoadDefaultConfig;
OptionDescDict options;
OptionValueVec values;
p->showHelp = false;
p->verbose = false;
p->showAircraft = false;
+ p->shouldLoadDefaultConfig = true;
// build option map
OptionDesc *desc = &fgOptionArray[ 0 ];
// to show extra (debug/info/warning) messages for the start-up phase.
fgOptLogLevel(valueForOption("log-level", "alert").c_str());
+ if (!p->shouldLoadDefaultConfig) {
+ setupRoot();
+ return;
+ }
+
// then config files
SGPath config;
else if (result == FG_OPTIONS_VERBOSE_HELP)
p->verbose = true;
else if (result == FG_OPTIONS_SHOW_AIRCRAFT) {
- p->showAircraft = true;
+ p->showAircraft = true;
+ } else if (result == FG_OPTIONS_NO_DEFAULT_CONFIG) {
+ p->shouldLoadDefaultConfig = false;
} else if (result == FG_OPTIONS_SHOW_SOUND_DEVICES) {
SGSoundMgr smgr;
return(FG_OPTIONS_SHOW_AIRCRAFT);
} else if ( s.find( "--show-sound-devices") == 0) {
return(FG_OPTIONS_SHOW_SOUND_DEVICES);
+ } else if ( s.find( "--no-default-config") == 0) {
+ return FG_OPTIONS_NO_DEFAULT_CONFIG;
} else if ( s.find( "--prop:") == 0) {
// property setting has a slightly different syntax, so fudge things
OptionDesc* desc = p->findOption("prop");
}
}
+bool Options::shouldLoadDefaultConfig() const
+{
+ return p->shouldLoadDefaultConfig;
+}
+
} // of namespace flightgear
* init the aircraft options
*/
void initAircraft();
+
+ /**
+ * should defualt configuration files be loaded and processed or not?
+ * There's many configuration files we have historically read by default
+ * on startup - preferences.xml, fgfs.rc in various places and so on.
+ * --no-default-config allows this behaviour to be changed, so only
+ * expicitly listed files are read - this is useful for testing. Expose
+ * the value of the option here.
+ */
+ bool shouldLoadDefaultConfig() const;
private:
void showUsage() const;