#include <Airports/runways.hxx>
#include <Airports/simple.hxx>
#include <ATC/ATCdisplay.hxx>
+#include <ATC/ATCmgr.hxx>
+#include <ATC/atislist.hxx>
#include <Autopilot/auto_gui.hxx>
#include <Autopilot/newauto.hxx>
#include <Cockpit/cockpit.hxx>
#include <FDM/ADA.hxx>
#include <FDM/Balloon.h>
#include <FDM/External.hxx>
-#include <FDM/JSBSim.hxx>
+#include <FDM/JSBSim/JSBSim.hxx>
#include <FDM/LaRCsim.hxx>
#include <FDM/MagicCarpet.hxx>
#include <FDM/NullFDM.hxx>
#include <Time/moonpos.hxx>
#include <Time/tmp.hxx>
-#ifndef FG_OLD_WEATHER
+#ifndef FG_NEW_ENVIRONMENT
# include <WeatherCM/FGLocalWeatherDatabase.h>
#else
-# include <Weather/weather.hxx>
+# include <Environment/environment_mgr.hxx>
#endif
#include "fg_init.hxx"
aircraft_path.append(aircraft);
aircraft_path.concat("-set.xml");
SG_LOG(SG_INPUT, SG_INFO, "Reading default aircraft: " << aircraft
- << " from " << props_path.str());
+ << " from " << aircraft_path.str());
try {
readProperties(aircraft_path.str(), globals->get_props());
} catch (const sg_exception &e) {
return true;
}
+void fgSetPosFromGlideSlope(void) {
+ double gs = fgGetDouble("/velocities/glideslope");
+ double od = fgGetDouble("/sim/startup/offset-distance");
+ double alt = fgGetDouble("/position/altitude-ft");
+
+ //if glideslope and offset-distance are set and altitude is
+ //not, calculate the initial altitude
+ if( fabs(gs) > 0.01 && fabs(od) > 0.1 && alt < -9990 ) {
+ od *= SG_NM_TO_METER * SG_METER_TO_FEET;
+ alt = fabs(od*tan(gs));
+ fgSetDouble("/position/altitude-ft",alt);
+ fgSetBool("/sim/startup/onground", false);
+ SG_LOG(SG_GENERAL,SG_INFO, "Calculated altitude as: " << alt << " ft");
+ } else if( fabs(gs) > 0.01 && alt > 0 && fabs(od) < 0.1) {
+ od = alt/tan(gs);
+ od *= -1*SG_FEET_TO_METER * SG_METER_TO_NM;
+ fgSetDouble("/sim/startup/offset-distance",od);
+ SG_LOG(SG_GENERAL,SG_INFO, "Calculated offset distance as: "
+ << od << " nm");
+ } else if( fabs(gs) > 0.01 ) {
+ SG_LOG(SG_GENERAL,SG_ALERT, "Glideslope given but not altitude"
+ << " or offset-distance. Resetting"
+ << " glideslope to zero" );
+ fgSetDouble("/velocities/glideslope",0);
+ }
+
+}
// General house keeping initializations
bool fgInitGeneral( void ) {
= fgGetNode("/position/longitude-deg");
static const SGPropertyNode *latitude
= fgGetNode("/position/latitude-deg");
-
+ static const SGPropertyNode *cur_time_override
+ = fgGetNode("/sim/time/cur-time-override", true);
+
SGPath zone( globals->get_fg_root() );
zone.append( "Timezone" );
SGTime *t = new SGTime( longitude->getDoubleValue()
* SGD_DEGREES_TO_RADIANS,
latitude->getDoubleValue()
* SGD_DEGREES_TO_RADIANS,
- zone.str() );
+ zone.str(),
+ cur_time_override->getLongValue() );
// Handle potential user specified time offsets
time_t cur_time = t->get_cur_time();
globals->set_warp_delta( 0 );
- t->update( 0.0, 0.0, globals->get_warp() );
+ t->update( 0.0, 0.0,
+ cur_time_override->getLongValue(),
+ globals->get_warp() );
return t;
}
////////////////////////////////////////////////////////////////////
// Initialize the weather modeling subsystem
-#ifndef FG_OLD_WEATHER
+#ifndef FG_NEW_ENVIRONMENT
// Initialize the WeatherDatabase
SG_LOG(SG_GENERAL, SG_INFO, "Creating LocalWeatherDatabase");
sgVec3 position;
global_events.Register( "weather update", fgUpdateWeatherDatabase,
fgEVENT::FG_EVENT_READY, 30000);
#else
- current_weather.Init();
+ globals->get_environment_mgr()->init();
+ globals->get_environment_mgr()->bind();
#endif
////////////////////////////////////////////////////////////////////
// Initialise ATC display system
////////////////////////////////////////////////////////////////////
- //DCL
SG_LOG(SG_GENERAL, SG_INFO, " ATC Display");
- current_atcdisplay = new FGATCDisplay;
- current_atcdisplay->init();
+ globals->set_ATC_display(new FGATCDisplay);
+ globals->get_ATC_display()->init();
+
+ ////////////////////////////////////////////////////////////////////
+ // Initialise the ATC Manager
+ ////////////////////////////////////////////////////////////////////
+
+ SG_LOG(SG_GENERAL, SG_INFO, " ATC Manager");
+ globals->set_ATC_mgr(new FGATCMgr);
+ globals->get_ATC_mgr()->init();
////////////////////////////////////////////////////////////////////
// Initialize the built-in commands.
#endif
fgInitFDM();
+
+ // allocates structures so must happen before any of the flight
+ // model or control parameters are set
+ fgAircraftInit(); // In the future this might not be the case.
fgInitView();