#if defined( _MSC_VER) || defined(__MINGW32__)
# include <direct.h> // for getcwd()
# define getcwd _getcwd
+# include <io.h> // isatty()
+# define isatty _isatty
#endif
// work around a stdc++ lib bug in some versions of linux, but doesn't
#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>
}
SGPropertyNode autosave;
-#ifdef _MSC_VER
+#if defined( _MSC_VER ) || defined( __MINGW32__ )
char *envp = ::getenv( "APPDATA" );
if (envp != NULL ) {
SGPath config( envp );
// 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;
}
return true;
}
-
/**
* Initialize vor/ndb/ils/fix list management and query systems (as
* well as simple airport db list)
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;
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" );
}
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() );
curr = curr->getChild("fg-current", 0, true);
curr->setStringValue(cwd ? cwd : "");
curr->setAttribute(SGPropertyNode::WRITE, false);
+
+ fgSetBool("/sim/startup/stdout-to-terminal", isatty(1));
+ fgSetBool("/sim/startup/stderr-to-terminal", isatty(2));
return true;
}
globals->get_scenery()->get_scene_graph()
->addChild(simgear::Particles::getCommonRoot());
+ simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true));
////////////////////////////////////////////////////////////////////
// Initialize the flight model subsystem.
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
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();