1
0
Fork 0

Clean-up: move autosave.xml loading code to proper method

This commit is contained in:
ThorstenB 2011-12-30 01:01:15 +01:00
parent 3100da1602
commit 90ce4ec93d
3 changed files with 18 additions and 24 deletions

View file

@ -548,34 +548,16 @@ bool fgInitConfig ( int argc, char **argv )
return false;
}
SGPropertyNode autosave;
SGPath autosaveFile = simgear::Dir(dataPath).file("autosave.xml");
if (autosaveFile.exists()) {
SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile.str());
try {
readProperties(autosaveFile.str(), &autosave, SGPropertyNode::USERARCHIVE);
} catch (sg_exception& e) {
SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
<< "(from " << e.getOrigin() << ")");
}
}
globals->loadUserSettings(dataPath);
// Scan user config files and command line for a specified aircraft.
flightgear::Options::sharedInstance()->initAircraft();
FindAndCacheAircraft f(&autosave);
FindAndCacheAircraft f(globals->get_props());
if (!f.loadAircraft()) {
return false;
}
copyProperties(&autosave, globals->get_props());
// TODO Move some of the code above into loadUserSettings after the 2.6 release
// call dummy function, for now just to indicate that data was loaded
globals->loadUserSettings();
// parse options after loading aircraft to ensure any user
// overrides of defaults are honored.
flightgear::Options::sharedInstance()->processOptions();

View file

@ -444,11 +444,23 @@ FGGlobals::restoreInitialState ()
// Load user settings from autosave.xml
void
FGGlobals::loadUserSettings()
FGGlobals::loadUserSettings(const SGPath& dataPath)
{
// dummy method for now.
//TODO Move code loading autosave.xml in here after the 2.6.0 release.
// remember that we have (tried) to load any existing autsave.xml
haveUserSettings = true;
SGPath autosaveFile = simgear::Dir(dataPath).file("autosave.xml");
SGPropertyNode autosave;
if (autosaveFile.exists()) {
SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile.str());
try {
readProperties(autosaveFile.str(), &autosave, SGPropertyNode::USERARCHIVE);
} catch (sg_exception& e) {
SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
<< "(from " << e.getOrigin() << ")");
}
}
copyProperties(&autosave, globals->get_props());
}
// Save user settings in autosave.xml

View file

@ -330,7 +330,7 @@ public:
/**
* Load user settings from autosave.xml
*/
void loadUserSettings();
void loadUserSettings(const SGPath& datapath);
/**
* Save user settings in autosave.xml