options->init(argc, argv, dataPath);
}
- bool loadDefaults = flightgear::Options::sharedInstance()->shouldLoadDefaultConfig();
+ bool loadDefaults = options->shouldLoadDefaultConfig();
if (loadDefaults) {
// Read global preferences from $FG_ROOT/preferences.xml
SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
} else {
SG_LOG(SG_GENERAL, SG_INFO, "not reading default configuration files");
}// of no-default-config selected
-
- // Scan user config files and command line for a specified aircraft.
- options->initAircraft();
+
+ return flightgear::FG_OPTIONS_OK;
+}
+int fgInitAircraft(bool reinit)
+{
+ // Scan user config files and command line for a specified aircraft.
+ if (!reinit) {
+ flightgear::Options::sharedInstance()->initAircraft();
+ }
+
FindAndCacheAircraft f(globals->get_props());
if (!f.loadAircraft()) {
- return flightgear::FG_OPTIONS_ERROR;
+ return flightgear::FG_OPTIONS_ERROR;
}
-
- // parse options after loading aircraft to ensure any user
- // overrides of defaults are honored.
- return options->processOptions();
+
+ return flightgear::FG_OPTIONS_OK;
}
-
-
/**
* Initialize vor/ndb/ils/fix list management and query systems (as
* well as simple airport db list)
fgInitConfig(0, NULL, true);
fgInitGeneral(); // all of this?
+ fgGetNode("/sim")->removeChild("aircraft-dir");
+ fgInitAircraft(true);
+ flightgear::Options::sharedInstance()->processOptions();
+
render = new FGRenderer;
render->setEventHandler(eventHandler);
globals->set_renderer(render);
flightgear::CameraGroup::buildDefaultGroup(viewer.get());
fgOSResetProperties();
+
// init some things manually
// which do not follow the regular init pattern
ATIS_mgr( NULL ),
controls( NULL ),
viewmgr( NULL ),
- commands( SGCommandMgr::instance() ),
+ commands( new SGCommandMgr ),
channel_options_list( NULL ),
initial_waypoints( NULL ),
fontcache ( new FGFontCache ),
locale = NULL;
props.clear();
+
+ delete commands;
}
// set the fg_root path
return EXIT_SUCCESS;
}
+ configResult = fgInitAircraft(false);
+ if (configResult == flightgear::FG_OPTIONS_ERROR) {
+ return EXIT_FAILURE;
+ } else if (configResult == flightgear::FG_OPTIONS_EXIT) {
+ return EXIT_SUCCESS;
+ }
+
+ configResult = flightgear::Options::sharedInstance()->processOptions();
+ if (configResult == flightgear::FG_OPTIONS_ERROR) {
+ return EXIT_FAILURE;
+ } else if (configResult == flightgear::FG_OPTIONS_EXIT) {
+ return EXIT_SUCCESS;
+ }
+
// Initialize the Window/Graphics environment.
fgOSInit(&argc, argv);
_bootstrap_OSInit++;