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
+
\f
////////////////////////////////////////////////////////////////////////
void
FGBFI::update ()
{
+ _check_altitude();
+ _check_lighting();
if (_needReinit) {
reinit();
}
{
current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
fgUpdateSkyAndLightingParams();
+ if (_lighting_countdown <= 0)
+ _lighting_countdown = 5;
}
{
current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
fgUpdateSkyAndLightingParams();
+ if (_lighting_countdown <= 0)
+ _lighting_countdown = 5;
}
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);
+ }
}
// 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
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