Updated save file and bfi code from David Megginson.
This commit is contained in:
parent
32ab096214
commit
109088a84e
4 changed files with 228 additions and 17 deletions
126
src/Main/bfi.cxx
126
src/Main/bfi.cxx
|
@ -32,9 +32,11 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/math/fg_types.hxx>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
|
||||
#include <Controls/controls.hxx>
|
||||
#include <Autopilot/newauto.hxx>
|
||||
#include <Scenery/scenery.hxx>
|
||||
|
@ -104,6 +106,8 @@ FGBFI::reinit ()
|
|||
// that's going to get clobbered
|
||||
// when we reinit the subsystems.
|
||||
|
||||
cout << "BFI: start reinit\n";
|
||||
|
||||
// TODO: add more AP stuff
|
||||
double elevator = getElevator();
|
||||
double aileron = getAileron();
|
||||
|
@ -143,6 +147,8 @@ FGBFI::reinit ()
|
|||
setGPSTargetLongitude(gpsLongitude);
|
||||
|
||||
_needReinit = false;
|
||||
|
||||
cout << "BFI: end reinit\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,6 +170,26 @@ FGBFI::getFlightModel ()
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the current aircraft as a string.
|
||||
*/
|
||||
const string
|
||||
FGBFI::getAircraft ()
|
||||
{
|
||||
return current_options.get_aircraft();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the current aircraft directory (UIUC) as a string.
|
||||
*/
|
||||
const string
|
||||
FGBFI::getAircraftDir ()
|
||||
{
|
||||
return aircraft_dir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the flight model as an integer.
|
||||
*
|
||||
|
@ -177,6 +203,28 @@ FGBFI::setFlightModel (int model)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current aircraft.
|
||||
*/
|
||||
void
|
||||
FGBFI::setAircraft (const string &aircraft)
|
||||
{
|
||||
current_options.set_aircraft(aircraft);
|
||||
needReinit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current aircraft directory (UIUC).
|
||||
*/
|
||||
void
|
||||
FGBFI::setAircraftDir (const string &dir)
|
||||
{
|
||||
aircraft_dir = dir;
|
||||
needReinit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the current Zulu time.
|
||||
*/
|
||||
|
@ -724,10 +772,13 @@ FGBFI::getAPHeadingLock ()
|
|||
void
|
||||
FGBFI::setAPHeadingLock (bool lock)
|
||||
{
|
||||
double heading = getAPHeading();
|
||||
current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
|
||||
current_autopilot->set_HeadingEnabled(lock);
|
||||
setAPHeading(heading);
|
||||
if (lock) {
|
||||
current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
|
||||
current_autopilot->set_HeadingEnabled(true);
|
||||
} else if (current_autopilot->get_HeadingMode() ==
|
||||
FGAutopilot::FG_HEADING_LOCK) {
|
||||
current_autopilot->set_HeadingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -769,8 +820,13 @@ FGBFI::getAPNAV1Lock ()
|
|||
void
|
||||
FGBFI::setAPNAV1Lock (bool lock)
|
||||
{
|
||||
current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
|
||||
current_autopilot->set_HeadingEnabled(lock);
|
||||
if (lock) {
|
||||
current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
|
||||
current_autopilot->set_HeadingEnabled(true);
|
||||
} else if (current_autopilot->get_HeadingMode() ==
|
||||
FGAutopilot::FG_HEADING_NAV1) {
|
||||
current_autopilot->set_HeadingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -924,10 +980,9 @@ FGBFI::setADFRotation (double rot)
|
|||
bool
|
||||
FGBFI::getGPSLock ()
|
||||
{
|
||||
return ( current_autopilot->get_HeadingEnabled() &&
|
||||
( current_autopilot->get_HeadingMode() ==
|
||||
FGAutopilot::FG_HEADING_WAYPOINT )
|
||||
);
|
||||
return (current_autopilot->get_HeadingEnabled() &&
|
||||
(current_autopilot->get_HeadingMode() ==
|
||||
FGAutopilot::FG_HEADING_WAYPOINT ));
|
||||
}
|
||||
|
||||
|
||||
|
@ -937,8 +992,13 @@ FGBFI::getGPSLock ()
|
|||
void
|
||||
FGBFI::setGPSLock (bool lock)
|
||||
{
|
||||
current_autopilot->set_HeadingEnabled( true );
|
||||
current_autopilot->set_HeadingMode( FGAutopilot::FG_HEADING_WAYPOINT );
|
||||
if (lock) {
|
||||
current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_WAYPOINT);
|
||||
current_autopilot->set_HeadingEnabled(true);
|
||||
} else if (current_autopilot->get_HeadingMode() ==
|
||||
FGAutopilot::FG_HEADING_WAYPOINT) {
|
||||
current_autopilot->set_HeadingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1022,6 +1082,26 @@ FGBFI::getVisibility ()
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether clouds are enabled.
|
||||
*/
|
||||
bool
|
||||
FGBFI::getClouds ()
|
||||
{
|
||||
return current_options.get_clouds();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the height of the clouds ASL (units?).
|
||||
*/
|
||||
double
|
||||
FGBFI::getCloudsASL ()
|
||||
{
|
||||
return current_options.get_clouds_asl();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current visibility (units??).
|
||||
*/
|
||||
|
@ -1036,6 +1116,28 @@ FGBFI::setVisibility (double visibility)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Switch clouds on or off.
|
||||
*/
|
||||
void
|
||||
FGBFI::setClouds (bool clouds)
|
||||
{
|
||||
current_options.set_clouds(clouds);
|
||||
needReinit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the cloud height.
|
||||
*/
|
||||
void
|
||||
FGBFI::setCloudsASL (double cloudsASL)
|
||||
{
|
||||
current_options.set_clouds_asl(cloudsASL);
|
||||
needReinit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Time
|
||||
|
|
|
@ -51,11 +51,15 @@ public:
|
|||
|
||||
// Simulation
|
||||
static int getFlightModel ();
|
||||
static const string getAircraft ();
|
||||
static const string getAircraftDir ();
|
||||
static time_t getTimeGMT ();
|
||||
static bool getHUDVisible ();
|
||||
static bool getPanelVisible ();
|
||||
|
||||
static void setFlightModel (int flightModel);
|
||||
static void setAircraft (const string &aircraft);
|
||||
static void setAircraftDir (const string &aircraftDir);
|
||||
static void setTimeGMT (time_t time);
|
||||
static void setHUDVisible (bool hudVisible);
|
||||
static void setPanelVisible (bool panelVisible);
|
||||
|
@ -170,8 +174,13 @@ public:
|
|||
|
||||
// Weather
|
||||
static double getVisibility ();
|
||||
static bool getClouds ();
|
||||
static double getCloudsASL ();
|
||||
|
||||
static void setVisibility (double visiblity);
|
||||
static void setClouds (bool clouds);
|
||||
static void setCloudsASL (double cloudsASL);
|
||||
|
||||
|
||||
// Time (this varies with time) huh, huh
|
||||
static double getMagVar ();
|
||||
|
|
|
@ -296,6 +296,7 @@ public:
|
|||
inline void set_hud_status( bool status ) { hud_status = status; }
|
||||
inline void set_sound (bool value) { sound = value; }
|
||||
inline void set_flight_model (int value) { flight_model = value; }
|
||||
inline void set_aircraft (const string &ac) { aircraft = ac; }
|
||||
inline void set_model_hz (int value) { model_hz = value; }
|
||||
inline void set_fog (fgFogKind value) { fog = value; }
|
||||
inline void set_clouds( bool value ) { clouds = value; }
|
||||
|
|
|
@ -55,6 +55,10 @@ fgSaveFlight (ostream &output)
|
|||
// Simulation
|
||||
//
|
||||
SAVE("flight-model", FGBFI::getFlightModel());
|
||||
if (FGBFI::getAircraft().length() > 0)
|
||||
SAVE("aircraft", FGBFI::getAircraft());
|
||||
if (FGBFI::getAircraftDir().length() > 0)
|
||||
SAVE("aircraft-dir", FGBFI::getAircraftDir());
|
||||
SAVE("time", FGBFI::getTimeGMT());
|
||||
SAVE("hud", FGBFI::getHUDVisible());
|
||||
SAVE("panel", FGBFI::getPanelVisible());
|
||||
|
@ -64,7 +68,13 @@ fgSaveFlight (ostream &output)
|
|||
//
|
||||
SAVE("latitude", FGBFI::getLatitude());
|
||||
SAVE("longitude", FGBFI::getLongitude());
|
||||
SAVE("altitude", FGBFI::getAltitude());
|
||||
|
||||
// KLUDGE: deal with gear wierdness
|
||||
if (FGBFI::getAGL() < 6) {
|
||||
SAVE("altitude", FGBFI::getAltitude() - 6);
|
||||
} else {
|
||||
SAVE("altitude", FGBFI::getAltitude());
|
||||
}
|
||||
|
||||
//
|
||||
// Orientation
|
||||
|
@ -98,11 +108,23 @@ fgSaveFlight (ostream &output)
|
|||
SAVE("brake", FGBFI::getBrake());
|
||||
|
||||
//
|
||||
// Navigation.
|
||||
// Radio navigation
|
||||
//
|
||||
if (FGBFI::getTargetAirport().length() > 0) {
|
||||
SAVE("nav1-active-frequency", FGBFI::getNAV1Freq());
|
||||
SAVE("nav1-standby-frequency", FGBFI::getNAV1AltFreq());
|
||||
SAVE("nav1-selected-radial", FGBFI::getNAV1SelRadial());
|
||||
SAVE("nav2-active-frequency", FGBFI::getNAV2Freq());
|
||||
SAVE("nav2-standby-frequency", FGBFI::getNAV2AltFreq());
|
||||
SAVE("nav2-selected-radial", FGBFI::getNAV2SelRadial());
|
||||
SAVE("adf-active-frequency", FGBFI::getADFFreq());
|
||||
SAVE("adf-standby-frequency", FGBFI::getADFAltFreq());
|
||||
SAVE("adf-rotation", FGBFI::getADFRotation());
|
||||
|
||||
//
|
||||
// Autopilot and GPS
|
||||
//
|
||||
if (FGBFI::getTargetAirport().length() > 0)
|
||||
SAVE("target-airport", FGBFI::getTargetAirport());
|
||||
}
|
||||
SAVE("autopilot-altitude-lock", FGBFI::getAPAltitudeLock());
|
||||
SAVE("autopilot-altitude", FGBFI::getAPAltitude());
|
||||
SAVE("autopilot-heading-lock", FGBFI::getAPHeadingLock());
|
||||
|
@ -115,6 +137,8 @@ fgSaveFlight (ostream &output)
|
|||
// Environment.
|
||||
//
|
||||
SAVE("visibility", FGBFI::getVisibility());
|
||||
SAVE("clouds", FGBFI::getClouds());
|
||||
SAVE("clouds-asl", FGBFI::getCloudsASL());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -156,6 +180,18 @@ fgLoadFlight (istream &input)
|
|||
FGBFI::setFlightModel(i);
|
||||
}
|
||||
|
||||
else if (text == "aircraft:") {
|
||||
input >> text;
|
||||
cout << "aircraft is " << text << endl;
|
||||
FGBFI::setAircraft(text);
|
||||
}
|
||||
|
||||
else if (text == "aircraft-dir:") {
|
||||
input >> text;
|
||||
cout << "aircraft-dir is " << text << endl;
|
||||
FGBFI::setAircraftDir(text);
|
||||
}
|
||||
|
||||
else if (text == "time:") {
|
||||
input >> i;
|
||||
cout << "saved time is " << i << endl;
|
||||
|
@ -290,8 +326,59 @@ fgLoadFlight (istream &input)
|
|||
FGBFI::setBrake(n);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Navigation.
|
||||
// Radio navigation
|
||||
//
|
||||
|
||||
else if (text == "nav1-active-frequency:") {
|
||||
input >> n;
|
||||
FGBFI::setNAV1Freq(n);
|
||||
}
|
||||
|
||||
else if (text == "nav1-standby-frequency:") {
|
||||
input >> n;
|
||||
FGBFI::setNAV1AltFreq(n);
|
||||
}
|
||||
|
||||
else if (text == "nav1-selected-radial:") {
|
||||
input >> n;
|
||||
FGBFI::setNAV1SelRadial(n);
|
||||
}
|
||||
|
||||
else if (text == "nav2-active-frequency:") {
|
||||
input >> n;
|
||||
FGBFI::setNAV2Freq(n);
|
||||
}
|
||||
|
||||
else if (text == "nav2-standby-frequency:") {
|
||||
input >> n;
|
||||
FGBFI::setNAV2AltFreq(n);
|
||||
}
|
||||
|
||||
else if (text == "nav2-selected-radial:") {
|
||||
input >> n;
|
||||
FGBFI::setNAV2SelRadial(n);
|
||||
}
|
||||
|
||||
else if (text == "adf-active-frequency:") {
|
||||
input >> n;
|
||||
FGBFI::setADFFreq(n);
|
||||
}
|
||||
|
||||
else if (text == "adf-standby-frequency:") {
|
||||
input >> n;
|
||||
FGBFI::setADFAltFreq(n);
|
||||
}
|
||||
|
||||
else if (text == "adf-rotation:") {
|
||||
input >> n;
|
||||
FGBFI::setADFRotation(n);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Autopilot and GPS
|
||||
//
|
||||
|
||||
else if (text == "target-airport:") {
|
||||
|
@ -352,6 +439,18 @@ fgLoadFlight (istream &input)
|
|||
FGBFI::setVisibility(n);
|
||||
}
|
||||
|
||||
else if (text == "clouds:") {
|
||||
input >> i;
|
||||
cout << "clouds is " << i << endl;
|
||||
FGBFI::setClouds(i);
|
||||
}
|
||||
|
||||
else if (text == "clouds-asl:") {
|
||||
input >> n;
|
||||
cout << "clouds-asl is " << n << endl;
|
||||
FGBFI::setCloudsASL(n);
|
||||
}
|
||||
|
||||
//
|
||||
// Don't die if we don't recognize something
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue