#include <AIModel/AIManager.hxx>
-#if ENABLE_ATCDCL
-# include <ATCDCL/ATCmgr.hxx>
-# include "ATCDCL/commlist.hxx"
-#else
-# include "ATC/atis.hxx"
-# include "ATC/atcutils.hxx"
-#endif
+#include <ATCDCL/ATCmgr.hxx>
+#include <ATCDCL/commlist.hxx>
+#include <ATC/atis.hxx>
#include <Autopilot/route_mgr.hxx>
#include <Autopilot/autopilotgroup.hxx>
-#include <Cockpit/cockpit.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/panel_io.hxx>
bool loadAircraft()
{
- std::string aircraft = fgGetString( "/sim/aircraft", "");
+ std::string aircraft = fgGetString( "/sim/aircraft", "");
if (aircraft.empty()) {
SG_LOG(SG_GENERAL, SG_ALERT, "no aircraft specified");
return false;
SGPropertyNode *n = _cache->getNode("fg-root", true);
n->setStringValue(globals->get_fg_root().c_str());
n->setAttribute(SGPropertyNode::USERARCHIVE, true);
+ n = _cache->getNode("fg-aircraft", true);
+ n->setStringValue(getAircraftPaths().c_str());
+ n->setAttribute(SGPropertyNode::USERARCHIVE, true);
_cache->removeChildren("aircraft");
fgFindAircraft(this, &FindAndCacheAircraft::checkAircraft);
}
private:
+ SGPath getAircraftPaths() {
+ string_list pathList = globals->get_aircraft_paths();
+ SGPath aircraftPaths;
+ string_list::const_iterator it = pathList.begin();
+ if (it != pathList.end()) {
+ aircraftPaths.set(*it);
+ it++;
+ }
+ for (; it != pathList.end(); ++it) {
+ aircraftPaths.add(*it);
+ }
+ return aircraftPaths;
+ }
+
bool checkCache()
{
if (globals->get_fg_root() != _cache->getStringValue("fg-root", "")) {
return false; // cache mismatch
}
+
+ if (getAircraftPaths().str() != _cache->getStringValue("fg-aircraft", "")) {
+ return false; // cache mismatch
+ }
vector<SGPropertyNode_ptr> cache = _cache->getChildren("aircraft");
for (unsigned int i = 0; i < cache.size(); i++) {
}
// Set current_options lon/lat given an airport id and heading (degrees)
-static bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
+bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
if ( id.empty() )
return false;
////////////////////////////////////////////////////////////////////
- // Initialise the ATC Manager
+ // Initialise the ATC Manager
////////////////////////////////////////////////////////////////////
-#if ENABLE_ATCDCL
SG_LOG(SG_GENERAL, SG_INFO, " ATC Manager");
globals->set_ATC_mgr(new FGATCMgr);
globals->get_ATC_mgr()->init();
-#else
+
////////////////////////////////////////////////////////////////////
// Initialise the ATIS Manager
////////////////////////////////////////////////////////////////////
globals->add_subsystem("atis", new FGAtisManager, SGSubsystemMgr::POST_FDM);
-#endif
////////////////////////////////////////////////////////////////////
// AI Traffic manager
globals->add_subsystem("Traffic Manager", new FGTrafficManager, SGSubsystemMgr::POST_FDM);
-
- if( fgCockpitInit()) {
- // Cockpit initialized ok.
- } else {
- SG_LOG( SG_GENERAL, SG_ALERT, "Error in Cockpit initialization!" );
- exit(-1);
- }
-
-
////////////////////////////////////////////////////////////////////
// Add a new 2D panel.
////////////////////////////////////////////////////////////////////
// End of subsystem initialization.
////////////////////////////////////////////////////////////////////
+ fgSetBool("/sim/initialized", true);
+
SG_LOG( SG_GENERAL, SG_INFO, endl);
// Save the initial state for future
void fgReInitSubsystems()
{
- // static const SGPropertyNode *longitude
- // = fgGetNode("/sim/presets/longitude-deg");
- // static const SGPropertyNode *latitude
- // = fgGetNode("/sim/presets/latitude-deg");
- static const SGPropertyNode *altitude
- = fgGetNode("/sim/presets/altitude-ft");
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
- SG_LOG( SG_GENERAL, SG_INFO,
- "fgReInitSubsystems(): /position/altitude = "
- << altitude->getDoubleValue() );
+ SG_LOG( SG_GENERAL, SG_INFO, "fgReInitSubsystems()");
+// setup state to begin re-init
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
+
+ fgSetBool("/sim/signals/reinit", true);
fgSetBool("/sim/crashed", false);
+// do actual re-init steps
+ globals->get_subsystem("flight")->unbind();
+
+ // reset control state, before restoring initial state; -set or config files
+ // may specify values for flaps, trim tabs, magnetos, etc
+ globals->get_controls()->reset_all();
+
+ globals->restoreInitialState();
+
+ // update our position based on current presets
+ fgInitPosition();
+
// Force reupdating the positions of the ai 3d models. They are used for
// initializing ground level for the FDM.
globals->get_subsystem("ai_model")->reinit();
// reload offsets from config defaults
globals->get_viewmgr()->reinit();
- globals->get_controls()->reset_all();
-
globals->get_subsystem("time")->reinit();
globals->get_subsystem("tile-manager")->reinit();
+// setup state to end re-init
+ fgSetBool("/sim/signals/reinit", false);
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
void doSimulatorReset(void) // from gui_local.cxx -- TODO merge with fgReInitSubsystems()
{
- static SGPropertyNode_ptr master_freeze = fgGetNode("/sim/freeze/master", true);
-
- bool freeze = master_freeze->getBoolValue();
- if (!freeze)
- master_freeze->setBoolValue(true);
-
- fgSetBool("/sim/signals/reinit", true);
-
- globals->get_subsystem("flight")->unbind();
-
- globals->restoreInitialState();
-
- // update our position based on current presets
- fgInitPosition();
+
fgReInitSubsystems();
-
- fgSetBool("/sim/signals/reinit", false);
-
- if (!freeze)
- master_freeze->setBoolValue(false);
}
///////////////////////////////////////////////////////////////////////////////