+bool
+fgLoadAircraft (const SGPropertyNode * arg)
+{
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
+
+ // TODO:
+ // remove electrical system
+ cur_fdm_state->unbind();
+
+ // Save the selected aircraft model since restoreInitialState
+ // will obverwrite it.
+ //
+ string aircraft = fgGetString("/sim/aircraft", "");
+ globals->restoreInitialState();
+
+ fgSetString("/sim/aircraft", aircraft.c_str());
+ fgSetString("/sim/panel/path", "Aircraft/c172p/Panels/c172-vfr-panel.xml");
+
+ if ( aircraft.size() > 0 ) {
+ SGPath aircraft_path(globals->get_fg_root());
+ aircraft_path.append("Aircraft");
+ aircraft_path.append(aircraft);
+ aircraft_path.concat("-set.xml");
+ SG_LOG(SG_INPUT, SG_INFO, "Reading default aircraft: " << aircraft
+ << " from " << aircraft_path.str());
+ try {
+ readProperties(aircraft_path.str(), globals->get_props());
+ } catch (const sg_exception &e) {
+ string message = "Error reading default aircraft: ";
+ message += e.getFormattedMessage();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ exit(2);
+ }
+ } else {
+ SG_LOG(SG_INPUT, SG_ALERT, "No default aircraft specified");
+ }
+
+ // Initialize the (new) 2D panel.
+ //
+ string panel_path = fgGetString("/sim/panel/path",
+ "Aircraft/c172p/Panels/c172-vfr-panel.xml");
+
+ FGPanel *panel = fgReadPanel(panel_path);
+ if (panel == 0) {
+ 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()->unbind();
+ delete globals->get_current_panel();
+ globals->set_current_panel( panel );
+ globals->get_current_panel()->init();
+ globals->get_current_panel()->bind();
+ globals->get_current_panel()->update(0);
+ }