Break config init / aircraft loading apart.
Allows aircraft loading to proceed during reset without original values over-writing the updated ones.
This commit is contained in:
parent
42ab4fd222
commit
2015016466
4 changed files with 40 additions and 15 deletions
|
@ -449,7 +449,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
|
||||||
options->init(argc, argv, dataPath);
|
options->init(argc, argv, dataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadDefaults = flightgear::Options::sharedInstance()->shouldLoadDefaultConfig();
|
bool loadDefaults = options->shouldLoadDefaultConfig();
|
||||||
if (loadDefaults) {
|
if (loadDefaults) {
|
||||||
// Read global preferences from $FG_ROOT/preferences.xml
|
// Read global preferences from $FG_ROOT/preferences.xml
|
||||||
SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
|
SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
|
||||||
|
@ -470,21 +470,24 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "not reading default configuration files");
|
SG_LOG(SG_GENERAL, SG_INFO, "not reading default configuration files");
|
||||||
}// of no-default-config selected
|
}// of no-default-config selected
|
||||||
|
|
||||||
|
return flightgear::FG_OPTIONS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fgInitAircraft(bool reinit)
|
||||||
|
{
|
||||||
// Scan user config files and command line for a specified aircraft.
|
// Scan user config files and command line for a specified aircraft.
|
||||||
options->initAircraft();
|
if (!reinit) {
|
||||||
|
flightgear::Options::sharedInstance()->initAircraft();
|
||||||
|
}
|
||||||
|
|
||||||
FindAndCacheAircraft f(globals->get_props());
|
FindAndCacheAircraft f(globals->get_props());
|
||||||
if (!f.loadAircraft()) {
|
if (!f.loadAircraft()) {
|
||||||
return flightgear::FG_OPTIONS_ERROR;
|
return flightgear::FG_OPTIONS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse options after loading aircraft to ensure any user
|
return flightgear::FG_OPTIONS_OK;
|
||||||
// overrides of defaults are honored.
|
|
||||||
return options->processOptions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize vor/ndb/ils/fix list management and query systems (as
|
* Initialize vor/ndb/ils/fix list management and query systems (as
|
||||||
* well as simple airport db list)
|
* well as simple airport db list)
|
||||||
|
@ -987,6 +990,10 @@ void fgStartNewReset()
|
||||||
fgInitConfig(0, NULL, true);
|
fgInitConfig(0, NULL, true);
|
||||||
fgInitGeneral(); // all of this?
|
fgInitGeneral(); // all of this?
|
||||||
|
|
||||||
|
fgGetNode("/sim")->removeChild("aircraft-dir");
|
||||||
|
fgInitAircraft(true);
|
||||||
|
flightgear::Options::sharedInstance()->processOptions();
|
||||||
|
|
||||||
render = new FGRenderer;
|
render = new FGRenderer;
|
||||||
render->setEventHandler(eventHandler);
|
render->setEventHandler(eventHandler);
|
||||||
globals->set_renderer(render);
|
globals->set_renderer(render);
|
||||||
|
@ -999,6 +1006,7 @@ void fgStartNewReset()
|
||||||
|
|
||||||
fgOSResetProperties();
|
fgOSResetProperties();
|
||||||
|
|
||||||
|
|
||||||
// init some things manually
|
// init some things manually
|
||||||
// which do not follow the regular init pattern
|
// which do not follow the regular init pattern
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ bool fgInitHome();
|
||||||
// Read in configuration (file and command line)
|
// Read in configuration (file and command line)
|
||||||
int fgInitConfig ( int argc, char **argv, bool reinit );
|
int fgInitConfig ( int argc, char **argv, bool reinit );
|
||||||
|
|
||||||
|
int fgInitAircraft(bool reinit);
|
||||||
|
|
||||||
// log various settings / configuration state
|
// log various settings / configuration state
|
||||||
void fgOutputSettings();
|
void fgOutputSettings();
|
||||||
|
|
|
@ -146,7 +146,7 @@ FGGlobals::FGGlobals() :
|
||||||
ATIS_mgr( NULL ),
|
ATIS_mgr( NULL ),
|
||||||
controls( NULL ),
|
controls( NULL ),
|
||||||
viewmgr( NULL ),
|
viewmgr( NULL ),
|
||||||
commands( SGCommandMgr::instance() ),
|
commands( new SGCommandMgr ),
|
||||||
channel_options_list( NULL ),
|
channel_options_list( NULL ),
|
||||||
initial_waypoints( NULL ),
|
initial_waypoints( NULL ),
|
||||||
fontcache ( new FGFontCache ),
|
fontcache ( new FGFontCache ),
|
||||||
|
@ -230,6 +230,8 @@ FGGlobals::~FGGlobals()
|
||||||
locale = NULL;
|
locale = NULL;
|
||||||
|
|
||||||
props.clear();
|
props.clear();
|
||||||
|
|
||||||
|
delete commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the fg_root path
|
// set the fg_root path
|
||||||
|
|
|
@ -388,6 +388,20 @@ int fgMainInit( int argc, char **argv ) {
|
||||||
return EXIT_SUCCESS;
|
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.
|
// Initialize the Window/Graphics environment.
|
||||||
fgOSInit(&argc, argv);
|
fgOSInit(&argc, argv);
|
||||||
_bootstrap_OSInit++;
|
_bootstrap_OSInit++;
|
||||||
|
|
Loading…
Reference in a new issue