]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Merge branch 'maint' (early part) into next
[flightgear.git] / src / Main / fg_init.cxx
index a23532db1a6cbc04663598813faaaf608e4f618c..fd245f754e788245edc7aa53a1bde06c3d821c65 100644 (file)
@@ -53,7 +53,6 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/exception.hxx>
 #include <simgear/structure/event_mgr.hxx>
-#include <simgear/math/point3d.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <Navaids/navdb.hxx>
 #include <Navaids/navlist.hxx>
 #include <Navaids/fix.hxx>
+#include <Navaids/fixlist.hxx>
 #include <Scenery/scenery.hxx>
 #include <Scenery/tilemgr.hxx>
 #include <Scripting/NasalSys.hxx>
@@ -597,6 +597,10 @@ bool fgInitConfig ( int argc, char **argv ) {
         if (fg_home)
             config = fg_home;
 
+        SGPath home_export(config.str());
+        home_export.append("Export/dummy");
+        home_export.create_dir(0777);
+
         // Set /sim/fg-home and don't allow malign code to override it until
         // Nasal security is set up.  Use FG_HOME if necessary.
         SGPropertyNode *home = fgGetNode("/sim", true);
@@ -939,11 +943,10 @@ static bool fgSetPosFromCarrier( const string& carrier, const string& posid ) {
 // Set current_options lon/lat given an airport id and heading (degrees)
 static bool fgSetPosFromFix( const string& id )
 {
-  FGFix* fix;
-  
-  // set initial position from runway and heading
-  if ( !globals->get_fixlist()->query( id.c_str(), fix ) ) {
-    SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate NAV = " << id );
+  FGPositioned::TypeFilter fixFilter(FGPositioned::FIX);
+  FGPositioned* fix = FGPositioned::findNextWithPartialId(NULL, id, &fixFilter);
+  if (!fix) {
+    SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate fix = " << id );
     return false;
   }
   
@@ -951,7 +954,6 @@ static bool fgSetPosFromFix( const string& id )
   return true;
 }
 
-
 /**
  * Initialize vor/ndb/ils/fix list management and query systems (as
  * well as simple airport db list)
@@ -967,16 +969,12 @@ fgInitNav ()
     SGPath p_metar( globals->get_fg_root() );
     p_metar.append( "Airports/metar.dat" );
 
-    FGAirportList *airports = new FGAirportList();
-    globals->set_airports( airports );
-
-    fgAirportDBLoad( airports, aptdb.str(), p_metar.str() );
+    fgAirportDBLoad( aptdb.str(), p_metar.str() );
 
     FGNavList *navlist = new FGNavList;
     FGNavList *loclist = new FGNavList;
     FGNavList *gslist = new FGNavList;
     FGNavList *dmelist = new FGNavList;
-    FGNavList *mkrlist = new FGNavList;
     FGNavList *tacanlist = new FGNavList;
     FGNavList *carrierlist = new FGNavList;
     FGTACANList *channellist = new FGTACANList;
@@ -985,12 +983,11 @@ fgInitNav ()
     globals->set_loclist( loclist );
     globals->set_gslist( gslist );
     globals->set_dmelist( dmelist );
-    globals->set_mkrlist( mkrlist );
     globals->set_tacanlist( tacanlist );
     globals->set_carrierlist( carrierlist );
     globals->set_channellist( channellist );
 
-    if ( !fgNavDBInit(navlist, loclist, gslist, dmelist, mkrlist, tacanlist, carrierlist, channellist) ) {
+    if ( !fgNavDBInit(navlist, loclist, gslist, dmelist, tacanlist, carrierlist, channellist) ) {
         SG_LOG( SG_GENERAL, SG_ALERT,
                 "Problems loading one or more navigational database" );
     }
@@ -1000,7 +997,6 @@ fgInitNav ()
     p_fix.append( "Navaids/fix.dat" );
     FGFixList *fixlist = new FGFixList;
     fixlist->init( p_fix );
-    globals->set_fixlist( fixlist );
 
     SG_LOG(SG_GENERAL, SG_INFO, "  Airways");
     SGPath p_awy( globals->get_fg_root() );
@@ -1784,6 +1780,14 @@ void reInit(void)  // from gui_local.cxx -- TODO merge with fgReInitSubsystems()
     int xsize = fgGetInt("/sim/startup/xsize");
     int ysize = fgGetInt("/sim/startup/ysize");
 
+    // viewports also needs to be saved/restored as
+    // restoreInitialState() overwrites these
+    SGPropertyNode *guiNode = new SGPropertyNode;
+    SGPropertyNode *cameraNode = new SGPropertyNode;
+    SGPropertyNode *cameraGroupNode = fgGetNode("/sim/rendering/camera-group");
+    copyProperties(cameraGroupNode->getChild("camera"), cameraNode);
+    copyProperties(cameraGroupNode->getChild("gui"), guiNode);
+
     globals->restoreInitialState();
 
     // update our position based on current presets
@@ -1794,6 +1798,12 @@ void reInit(void)  // from gui_local.cxx -- TODO merge with fgReInitSubsystems()
     fgSetInt("/sim/startup/xsize", xsize);
     fgSetInt("/sim/startup/ysize", ysize);
 
+    copyProperties(cameraNode, cameraGroupNode->getChild("camera"));
+    copyProperties(guiNode, cameraGroupNode->getChild("gui"));
+
+    delete guiNode;
+    delete cameraNode;
+
     SGTime *t = globals->get_time_params();
     delete t;
     t = fgInitTime();