1
0
Fork 0

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:
James Turner 2013-11-23 19:58:45 +00:00
parent 42ab4fd222
commit 2015016466
4 changed files with 40 additions and 15 deletions

View file

@ -449,7 +449,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
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");
@ -469,21 +469,24 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
} 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();
FindAndCacheAircraft f(globals->get_props());
if (!f.loadAircraft()) {
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;
}
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_OK;
}
/**
* Initialize vor/ndb/ils/fix list management and query systems (as
@ -987,6 +990,10 @@ void fgStartNewReset()
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);
@ -998,6 +1005,7 @@ void fgStartNewReset()
flightgear::CameraGroup::buildDefaultGroup(viewer.get());
fgOSResetProperties();
// init some things manually
// which do not follow the regular init pattern

View file

@ -39,6 +39,7 @@ bool fgInitHome();
// Read in configuration (file and command line)
int fgInitConfig ( int argc, char **argv, bool reinit );
int fgInitAircraft(bool reinit);
// log various settings / configuration state
void fgOutputSettings();

View file

@ -146,7 +146,7 @@ FGGlobals::FGGlobals() :
ATIS_mgr( NULL ),
controls( NULL ),
viewmgr( NULL ),
commands( SGCommandMgr::instance() ),
commands( new SGCommandMgr ),
channel_options_list( NULL ),
initial_waypoints( NULL ),
fontcache ( new FGFontCache ),
@ -230,6 +230,8 @@ FGGlobals::~FGGlobals()
locale = NULL;
props.clear();
delete commands;
}
// set the fg_root path

View file

@ -388,6 +388,20 @@ int fgMainInit( int argc, char **argv ) {
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++;