X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Ffg_init.cxx;h=0e83ba131b952db0859ab0286f97fa38747f93b5;hb=fcf1709df61ec93182dc51ca4afa58ea152749a0;hp=1ebff97b1439bdccbaec25b5179966a1701a6b15;hpb=94a34719566150281d2d91e1ffcafa0e3e935b88;p=flightgear.git diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 1ebff97b1..0e83ba131 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -58,6 +58,8 @@ #include #include #include +#include + #include #include #include @@ -72,18 +74,13 @@ #include -#if ENABLE_ATCDCL -# include -# include "ATCDCL/commlist.hxx" -#else -# include "ATC/atis.hxx" -# include "ATC/atcutils.hxx" -#endif +#include +#include +#include #include #include -#include #include #include @@ -91,12 +88,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -586,7 +585,7 @@ public: 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; @@ -598,6 +597,9 @@ public: 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); @@ -626,11 +628,29 @@ public: } 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 cache = _cache->getChildren("aircraft"); for (unsigned int i = 0; i < cache.size(); i++) { @@ -817,7 +837,7 @@ static void fgApplyStartOffset(const SGGeod& aStartPos, double aHeading, double } // 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; @@ -1071,15 +1091,8 @@ fgInitNav () fixlist.init( p_fix ); // adds fixes to the DB in positioned.cxx SG_LOG(SG_GENERAL, SG_INFO, " Airways"); - SGPath p_awy( globals->get_fg_root() ); - p_awy.append( "Navaids/awy.dat" ); - FGAirwayNetwork *awyNet = new FGAirwayNetwork; - //cerr << "Loading Airways" << endl; - awyNet->load (p_awy ); - awyNet->init(); - //cerr << "initializing airways" << endl; - globals->set_airwaynet( awyNet ); - + flightgear::Airway::load(); + return true; } @@ -1313,9 +1326,6 @@ bool fgInitSubsystems() { // Initialize the scenery management subsystem. //////////////////////////////////////////////////////////////////// - globals->add_subsystem("tile-manager", globals->get_tile_mgr(), - SGSubsystemMgr::DISPLAY); - globals->get_scenery()->get_scene_graph() ->addChild(simgear::Particles::getCommonRoot()); simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true)); @@ -1365,38 +1375,25 @@ bool fgInitSubsystems() { globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT); - //////////////////////////////////////////////////////////////////// - // Initialize the lighting subsystem. - //////////////////////////////////////////////////////////////////// - - globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY); - ////////////////////////////////////////////////////////////////////// // Initialize the 2D cloud subsystem. //////////////////////////////////////////////////////////////////// fgGetBool("/sim/rendering/bump-mapping", false); -#ifdef ENABLE_AUDIO_SUPPORT - //////////////////////////////////////////////////////////////////// - // Initialize the sound-effects subsystem. - //////////////////////////////////////////////////////////////////// - globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY); -#endif + //////////////////////////////////////////////////////////////////// - // 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 //////////////////////////////////////////////////////////////////// @@ -1418,33 +1415,24 @@ bool fgInitSubsystems() { // 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. //////////////////////////////////////////////////////////////////// - string panel_path = fgGetString("/sim/panel/path", - "Panels/Default/default.xml"); - - globals->set_current_panel( fgReadPanel(panel_path) ); - if (globals->get_current_panel() == 0) { + string panel_path(fgGetString("/sim/panel/path")); + if (!panel_path.empty()) { + FGPanel* p = fgReadPanel(panel_path); + if (p) { + globals->set_current_panel(p); + p->init(); + p->bind(); + SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path ); + } else { SG_LOG( SG_INPUT, SG_ALERT, "Error reading new panel from " << panel_path ); - } else { - SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path ); - globals->get_current_panel()->init(); - globals->get_current_panel()->bind(); + } } - //////////////////////////////////////////////////////////////////// // Initialize the controls subsystem. //////////////////////////////////////////////////////////////////// @@ -1465,7 +1453,37 @@ bool fgInitSubsystems() { //////////////////////////////////////////////////////////////////// globals->add_subsystem("replay", new FGReplay); +#ifdef ENABLE_AUDIO_SUPPORT + //////////////////////////////////////////////////////////////////// + // Initialize the sound-effects subsystem. + //////////////////////////////////////////////////////////////////// + globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY); +#endif + + //////////////////////////////////////////////////////////////////// + // Initialize the lighting subsystem. + //////////////////////////////////////////////////////////////////// + + globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY); + + // ordering here is important : Nasal (via events), then models, then views + globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY); + + FGAircraftModel* acm = new FGAircraftModel; + globals->set_aircraft_model(acm); + globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY); + + FGModelMgr* mm = new FGModelMgr; + globals->set_model_mgr(mm); + globals->add_subsystem("model-manager", mm, SGSubsystemMgr::DISPLAY); + FGViewMgr *viewmgr = new FGViewMgr; + globals->set_viewmgr( viewmgr ); + globals->add_subsystem("view-manager", viewmgr, SGSubsystemMgr::DISPLAY); + + globals->add_subsystem("tile-manager", globals->get_tile_mgr(), + SGSubsystemMgr::DISPLAY); + //////////////////////////////////////////////////////////////////// // Bind and initialize subsystems. //////////////////////////////////////////////////////////////////// @@ -1488,6 +1506,8 @@ bool fgInitSubsystems() { // End of subsystem initialization. //////////////////////////////////////////////////////////////////// + fgSetBool("/sim/initialized", true); + SG_LOG( SG_GENERAL, SG_INFO, endl); // Save the initial state for future @@ -1500,25 +1520,32 @@ bool fgInitSubsystems() { 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(); @@ -1529,11 +1556,11 @@ void fgReInitSubsystems() // 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); } @@ -1543,27 +1570,9 @@ void fgReInitSubsystems() 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); } ///////////////////////////////////////////////////////////////////////////////