Blame this on David Megginson ... :-)
Save/restore seems to be working now, thanks to a couple of unspeakable kludges: 1. Every time the altitude changes, pause the flight simulator for five frames and then change it a second time. 2. Every time the latitude or longitude changes, wait five frames, then invoke fgUpdateSkyAndLightingParams() a second time.
This commit is contained in:
parent
65087c6b56
commit
94fd1bd8f2
3 changed files with 54 additions and 35 deletions
|
@ -146,6 +146,34 @@ reinit ()
|
|||
cout << "BFI: end reinit\n";
|
||||
}
|
||||
|
||||
// BEGIN: kludge 2000-12-07
|
||||
// This is a kludge around a LaRCsim problem; see setAltitude()
|
||||
// for details.
|
||||
static int _altitude_countdown = 0;
|
||||
static double _requested_altitude = -9999;
|
||||
static bool _saved_freeze = false;
|
||||
static inline void _check_altitude ()
|
||||
{
|
||||
if (_altitude_countdown > 0) {
|
||||
_altitude_countdown--;
|
||||
if (_altitude_countdown == 0) {
|
||||
current_aircraft.fdm_state->set_Altitude(_requested_altitude);
|
||||
globals->set_freeze(_saved_freeze);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int _lighting_countdown = 0;
|
||||
static inline void _check_lighting ()
|
||||
{
|
||||
if (_lighting_countdown > 0) {
|
||||
_lighting_countdown--;
|
||||
if (_lighting_countdown == 0)
|
||||
fgUpdateSkyAndLightingParams();
|
||||
}
|
||||
}
|
||||
// END: kludge
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -337,6 +365,8 @@ FGBFI::init ()
|
|||
void
|
||||
FGBFI::update ()
|
||||
{
|
||||
_check_altitude();
|
||||
_check_lighting();
|
||||
if (_needReinit) {
|
||||
reinit();
|
||||
}
|
||||
|
@ -620,6 +650,8 @@ FGBFI::setLatitude (double latitude)
|
|||
{
|
||||
current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
|
||||
fgUpdateSkyAndLightingParams();
|
||||
if (_lighting_countdown <= 0)
|
||||
_lighting_countdown = 5;
|
||||
}
|
||||
|
||||
|
||||
|
@ -641,6 +673,8 @@ FGBFI::setLongitude (double longitude)
|
|||
{
|
||||
current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
|
||||
fgUpdateSkyAndLightingParams();
|
||||
if (_lighting_countdown <= 0)
|
||||
_lighting_countdown = 5;
|
||||
}
|
||||
|
||||
|
||||
|
@ -673,7 +707,22 @@ void
|
|||
FGBFI::setAltitude (double altitude)
|
||||
{
|
||||
current_aircraft.fdm_state->set_Altitude(altitude);
|
||||
fgUpdateSkyAndLightingParams();
|
||||
|
||||
// 2000-12-07
|
||||
// This is an ugly kludge around a
|
||||
// LaRCsim problem; if the
|
||||
// requested altitude cannot be
|
||||
// set right away (because it's
|
||||
// below the last-calculated ground
|
||||
// level), pause FGFS, wait for
|
||||
// five frames, and then try again.
|
||||
if (_altitude_countdown <= 0 &&
|
||||
fabs(getAltitude() - altitude) > 5.0) {
|
||||
_altitude_countdown = 5;
|
||||
_requested_altitude = altitude;
|
||||
_saved_freeze = globals->get_freeze();
|
||||
globals->set_freeze(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -146,10 +146,9 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
// add 1000' of emergency altitude. Possibly good for
|
||||
// unflipping yourself :-)
|
||||
{
|
||||
FGBFI::setAltitude(FGBFI::getAltitude() + 1000);
|
||||
// double alt = cur_fdm_state->get_Altitude() + 1000;
|
||||
// fgFDMForceAltitude( globals->get_options()->get_flight_model(),
|
||||
// alt * FEET_TO_METER );
|
||||
double alt = cur_fdm_state->get_Altitude() + 1000;
|
||||
fgFDMForceAltitude( globals->get_options()->get_flight_model(),
|
||||
alt * FEET_TO_METER );
|
||||
}
|
||||
return;
|
||||
case 49: // numeric keypad 1
|
||||
|
|
|
@ -60,36 +60,7 @@ fgSaveFlight (ostream &output)
|
|||
bool
|
||||
fgLoadFlight (istream &input)
|
||||
{
|
||||
bool retval = readPropertyList(input, ¤t_properties);
|
||||
|
||||
// FIXME: from keyboard.cxx
|
||||
// this makes sure that the tile
|
||||
// cache is updated after a restore;
|
||||
// it would be better if FGFS just
|
||||
// noticed the new lat/lon.
|
||||
if (retval) {
|
||||
bool freeze = globals->get_freeze();
|
||||
FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
|
||||
if ( !freeze )
|
||||
globals->set_freeze( true );
|
||||
BusyCursor(0);
|
||||
if ( global_tile_mgr.init() ) {
|
||||
// Load the local scenery data
|
||||
global_tile_mgr.update(
|
||||
cur_fdm_state->get_Longitude() * RAD_TO_DEG,
|
||||
cur_fdm_state->get_Latitude() * RAD_TO_DEG );
|
||||
} else {
|
||||
FG_LOG( FG_GENERAL, FG_ALERT,
|
||||
"Error in Tile Manager initialization!" );
|
||||
exit(-1);
|
||||
}
|
||||
BusyCursor(1);
|
||||
if ( !freeze )
|
||||
globals->set_freeze( false );
|
||||
}
|
||||
// end FIXME
|
||||
|
||||
return retval;
|
||||
return readPropertyList(input, ¤t_properties);
|
||||
}
|
||||
|
||||
// end of save.cxx
|
||||
|
|
Loading…
Add table
Reference in a new issue