]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_init.cxx
66920fc4b1d35f888064294c42370d9201ec9c3e
[flightgear.git] / src / Main / fg_init.cxx
1 //
2 // fg_init.cxx -- Flight Gear top level initialization routines
3 //
4 // Written by Curtis Olson, started August 1997.
5 //
6 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 //
23 // $Id$
24
25
26 #ifdef HAVE_CONFIG_H
27 #  include <config.h>
28 #endif
29
30 // For BC 5.01 this must be included before OpenGL includes.
31 #ifdef FG_MATH_EXCEPTION_CLASH
32 #  include <math.h>
33 #endif
34
35 #include <GL/glut.h>
36 #include <simgear/xgl/xgl.h>
37
38 #include <stdio.h>
39 #include <stdlib.h>
40
41 // work around a stdc++ lib bug in some versions of linux, but doesn't
42 // seem to hurt to have this here for all versions of Linux.
43 #ifdef linux
44 #  define _G_NO_EXTERN_TEMPLATES
45 #endif
46
47 #include <simgear/compiler.h>
48
49 #include STL_STRING
50
51 #include <simgear/constants.h>
52 #include <simgear/debug/logstream.hxx>
53 #include <simgear/math/fg_geodesy.hxx>
54 #include <simgear/math/point3d.hxx>
55 #include <simgear/math/polar3d.hxx>
56 #include <simgear/misc/fgpath.hxx>
57
58 #include <Aircraft/aircraft.hxx>
59 #include <Airports/simple.hxx>
60 #include <Autopilot/autopilot.hxx>
61 #include <Cockpit/cockpit.hxx>
62 #include <FDM/Balloon.h>
63 #include <FDM/External.hxx>
64 #include <FDM/JSBsim.hxx>
65 #include <FDM/LaRCsim.hxx>
66 #include <FDM/MagicCarpet.hxx>
67 #include <Include/general.hxx>
68 #include <Joystick/joystick.hxx>
69 #include <Scenery/scenery.hxx>
70 #include <Scenery/tilemgr.hxx>
71 #include <Time/event.hxx>
72 #include <Time/fg_time.hxx>
73 #include <Time/light.hxx>
74 #include <Time/sunpos.hxx>
75 #include <Time/moonpos.hxx>
76
77 #ifndef FG_OLD_WEATHER
78 #  include <WeatherCM/FGLocalWeatherDatabase.h>
79 #else
80 #  include <Weather/weather.hxx>
81 #endif
82
83 #include "fg_init.hxx"
84 #include "fg_io.hxx"
85 #include "options.hxx"
86 #include "views.hxx"
87
88 #if defined(FX) && defined(XMESA)
89 #include <GL/xmesa.h>
90 #endif
91
92 FG_USING_STD(string);
93
94 extern const char *default_root;
95
96
97 // Read in configuration (file and command line)
98 bool fgInitConfig ( int argc, char **argv ) {
99     // Attempt to locate and parse a config file
100     // First check fg_root
101     FGPath config( current_options.get_fg_root() );
102     config.append( "system.fgfsrc" );
103     current_options.parse_config_file( config.str() );
104
105     // Next check home directory
106     char* envp = ::getenv( "HOME" );
107     if ( envp != NULL ) {
108         config.set( envp );
109         config.append( ".fgfsrc" );
110         current_options.parse_config_file( config.str() );
111     }
112
113     // Parse remaining command line options
114     // These will override anything specified in a config file
115     if ( current_options.parse_command_line(argc, argv) !=
116          fgOPTIONS::FG_OPTIONS_OK )
117     {
118         // Something must have gone horribly wrong with the command
119         // line parsing or maybe the user just requested help ... :-)
120         current_options.usage();
121         FG_LOG( FG_GENERAL, FG_ALERT, "\nExiting ...");
122         return false;
123     }
124
125    return true;
126 }
127
128
129 // Set initial position and orientation
130 bool fgInitPosition( void ) {
131     string id;
132     FGInterface *f;
133
134     f = current_aircraft.fdm_state;
135
136     id = current_options.get_airport_id();
137     if ( id.length() ) {
138         // set initial position from airport id
139
140         FGPath path( current_options.get_fg_root() );
141         path.append( "Airports" );
142         path.append( "simple.gdbm" );
143         FGAirports airports( path.c_str() );
144         FGAirport a;
145
146         FG_LOG( FG_GENERAL, FG_INFO,
147                 "Attempting to set starting position from airport code "
148                 << id );
149
150         // FGPath inpath( current_options.get_fg_root() );
151         // inpath.append( "Airports" );
152         // inpath.append( "apt_simple" );
153         // airports.load( inpath.c_str() );
154
155         // FGPath outpath( current_options.get_fg_root() );
156         // outpath.append( "Airports" );
157         // outpath.append( "simple.gdbm" );
158         // airports.dump_gdbm( outpath.c_str() );
159
160         if ( ! airports.search( id, &a ) ) {
161             FG_LOG( FG_GENERAL, FG_ALERT,
162                     "Failed to find " << id << " in database." );
163             exit(-1);
164         } else {
165             f->set_Longitude( a.longitude * DEG_TO_RAD );
166             f->set_Latitude( a.latitude * DEG_TO_RAD );
167         }
168     } else {
169         // set initial position from default or command line coordinates
170
171         f->set_Longitude( current_options.get_lon() * DEG_TO_RAD );
172         f->set_Latitude( current_options.get_lat() * DEG_TO_RAD );
173     }
174
175     FG_LOG( FG_GENERAL, FG_INFO,
176             "starting altitude is = " << current_options.get_altitude() );
177
178     f->set_Altitude( current_options.get_altitude() * METER_TO_FEET );
179     fgFDMSetGroundElevation( current_options.get_flight_model(),
180                              (f->get_Altitude() - 3.758099) * FEET_TO_METER );
181
182     FG_LOG( FG_GENERAL, FG_INFO,
183             "Initial position is: ("
184             << (f->get_Longitude() * RAD_TO_DEG) << ", "
185             << (f->get_Latitude() * RAD_TO_DEG) << ", "
186             << (f->get_Altitude() * FEET_TO_METER) << ")" );
187
188     return true;
189 }
190
191
192 // General house keeping initializations
193 bool fgInitGeneral( void ) {
194     string root;
195
196 #if defined(FX) && defined(XMESA)
197     char *mesa_win_state;
198 #endif
199
200     FG_LOG( FG_GENERAL, FG_INFO, "General Initialization" );
201     FG_LOG( FG_GENERAL, FG_INFO, "======= ==============" );
202
203     root = current_options.get_fg_root();
204     if ( ! root.length() ) {
205         // No root path set? Then bail ...
206         FG_LOG( FG_GENERAL, FG_ALERT,
207                 "Cannot continue without environment variable FG_ROOT"
208                 << "being defined." );
209         exit(-1);
210     }
211     FG_LOG( FG_GENERAL, FG_INFO, "FG_ROOT = " << '"' << root << '"' << endl );
212
213 #if defined(FX) && defined(XMESA)
214     // initialize full screen flag
215     global_fullscreen = false;
216     if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
217         // Test for the MESA_GLX_FX env variable
218         if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
219             // test if we are fullscreen mesa/glide
220             if ( (mesa_win_state[0] == 'f') ||
221                  (mesa_win_state[0] == 'F') ) {
222                 global_fullscreen = true;
223             }
224         }
225     }
226 #endif
227
228     return true;
229 }
230
231
232 // This is the top level init routine which calls all the other
233 // initialization routines.  If you are adding a subsystem to flight
234 // gear, its initialization call should located in this routine.
235 // Returns non-zero if a problem encountered.
236 bool fgInitSubsystems( void ) {
237     fgLIGHT *l = &cur_light_params;
238     FGTime *t = FGTime::cur_time_params;
239
240     FG_LOG( FG_GENERAL, FG_INFO, "Initialize Subsystems");
241     FG_LOG( FG_GENERAL, FG_INFO, "========== ==========");
242
243     if ( current_options.get_flight_model() == FGInterface::FG_LARCSIM ) {
244         cur_fdm_state = new FGLaRCsim;
245     } else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) {
246         cur_fdm_state = new FGJSBsim;
247     } else if ( current_options.get_flight_model() == 
248                 FGInterface::FG_BALLOONSIM ) {
249         cur_fdm_state = new FGBalloonSim;
250     } else if ( current_options.get_flight_model() == 
251                 FGInterface::FG_MAGICCARPET ) {
252         cur_fdm_state = new FGMagicCarpet;
253     } else if ( current_options.get_flight_model() == 
254                 FGInterface::FG_EXTERNAL ) {
255         cur_fdm_state = new FGExternal;
256     } else {
257         FG_LOG( FG_GENERAL, FG_ALERT,
258                 "No flight model, can't init aircraft" );
259         exit(-1);
260     }
261
262     // allocates structures so must happen before any of the flight
263     // model or control parameters are set
264     fgAircraftInit();   // In the future this might not be the case.
265
266     // set the initial position
267     fgInitPosition();
268
269     // Initialize the Scenery Management subsystem
270     if ( fgSceneryInit() ) {
271         // Scenery initialized ok.
272     } else {
273         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Scenery initialization!" );
274         exit(-1);
275     }
276
277     if( global_tile_mgr.init() ) {
278         // Load the local scenery data
279         global_tile_mgr.update();
280     } else {
281         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
282         exit(-1);
283     }
284
285     FG_LOG( FG_GENERAL, FG_DEBUG,
286             "Current terrain elevation after tile mgr init " <<
287             scenery.cur_elev );
288
289     // Calculate ground elevation at starting point (we didn't have
290     // tmp_abs_view_pos calculated when fgTileMgrUpdate() was called above
291     //
292     // calculalate a cartesian point somewhere along the line between
293     // the center of the earth and our view position.  Doesn't have to
294     // be the exact elevation (this is good because we don't know it
295     // yet :-)
296
297     // now handled inside of the fgTileMgrUpdate()
298
299     /*
300     geod_pos = Point3D( cur_fdm_state->get_Longitude(), cur_fdm_state->get_Latitude(), 0.0);
301     tmp_abs_view_pos = fgGeodToCart(geod_pos);
302
303     FG_LOG( FG_GENERAL, FG_DEBUG,
304             "Initial abs_view_pos = " << tmp_abs_view_pos );
305     scenery.cur_elev =
306         fgTileMgrCurElev( cur_fdm_state->get_Longitude(), cur_fdm_state->get_Latitude(),
307                           tmp_abs_view_pos );
308     FG_LOG( FG_GENERAL, FG_DEBUG,
309             "Altitude after update " << scenery.cur_elev );
310     */
311
312     fgFDMSetGroundElevation( current_options.get_flight_model(),
313                              scenery.cur_elev );
314
315     // Reset our altitude if we are below ground
316     FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << cur_fdm_state->get_Altitude() );
317     FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " <<
318             cur_fdm_state->get_Runway_altitude() );
319
320     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
321         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
322     }
323
324     FG_LOG( FG_GENERAL, FG_INFO,
325             "Updated position (after elevation adj): ("
326             << (cur_fdm_state->get_Latitude() * RAD_TO_DEG) << ", "
327             << (cur_fdm_state->get_Longitude() * RAD_TO_DEG) << ", "
328             << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" );
329
330     // We need to calculate a few more values here that would normally
331     // be calculated by the FDM so that the current_view.UpdateViewMath()
332     // routine doesn't get hosed.
333
334     double sea_level_radius_meters;
335     double lat_geoc;
336     // Set the FG variables first
337     fgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(),
338                   &sea_level_radius_meters, &lat_geoc);
339     cur_fdm_state->set_Geocentric_Position( lat_geoc, cur_fdm_state->get_Longitude(),
340                                 cur_fdm_state->get_Altitude() +
341                                 (sea_level_radius_meters * METER_TO_FEET) );
342     cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
343
344     cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
345     cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
346         
347     cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
348     cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc));
349
350     // The following section sets up the flight model EOM parameters
351     // and should really be read in from one or more files.
352
353     // Initial Velocity
354     cur_fdm_state->set_Velocities_Local( current_options.get_uBody(),
355                              current_options.get_vBody(),
356                              current_options.get_wBody());
357
358     // Initial Orientation
359     cur_fdm_state->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
360                          current_options.get_pitch() * DEG_TO_RAD,
361                          current_options.get_heading() * DEG_TO_RAD );
362
363     // Initial Angular Body rates
364     cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
365
366     cur_fdm_state->set_Earth_position_angle( 0.0 );
367
368     // Mass properties and geometry values
369     cur_fdm_state->set_Inertias( 8.547270E+01,
370                      1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
371
372     // CG position w.r.t. ref. point
373     cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
374
375     // Initialize the event manager
376     global_events.Init();
377
378     // Output event stats every 60 seconds
379     global_events.Register( "fgEVENT_MGR::PrintStats()",
380                             fgMethodCallback<fgEVENT_MGR>( &global_events,
381                                                    &fgEVENT_MGR::PrintStats),
382                             fgEVENT::FG_EVENT_READY, 60000 );
383
384     // Initialize view parameters
385     FG_LOG( FG_GENERAL, FG_DEBUG, "Before current_view.init()");
386     current_view.Init();
387     pilot_view.Init();
388     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
389     current_view.UpdateViewMath(*cur_fdm_state);
390     pilot_view.UpdateViewMath(*cur_fdm_state);
391     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << current_view.get_abs_view_pos());
392     // current_view.UpdateWorldToEye(f);
393
394     // Initialize the planetary subsystem
395     // global_events.Register( "fgPlanetsInit()", fgPlanetsInit,
396     //                      fgEVENT::FG_EVENT_READY, 600000);
397
398     // Initialize the sun's position
399     // global_events.Register( "fgSunInit()", fgSunInit,
400     //                      fgEVENT::FG_EVENT_READY, 30000 );
401
402     // Intialize the moon's position
403     // global_events.Register( "fgMoonInit()", fgMoonInit,
404     //                      fgEVENT::FG_EVENT_READY, 600000 );
405
406     // fgUpdateSunPos() needs a few position and view parameters set
407     // so it can calculate local relative sun angle and a few other
408     // things for correctly orienting the sky.
409     fgUpdateSunPos();
410     fgUpdateMoonPos();
411     global_events.Register( "fgUpdateSunPos()", fgUpdateSunPos,
412                             fgEVENT::FG_EVENT_READY, 60000);
413     global_events.Register( "fgUpdateMoonPos()", fgUpdateMoonPos,
414                             fgEVENT::FG_EVENT_READY, 60000);
415
416     // Initialize Lighting interpolation tables
417     l->Init();
418
419     // update the lighting parameters (based on sun angle)
420     global_events.Register( "fgLight::Update()",
421                             fgMethodCallback<fgLIGHT>( &cur_light_params,
422                                                        &fgLIGHT::Update),
423                             fgEVENT::FG_EVENT_READY, 30000 );
424     // update the current timezone each 30 minutes
425     global_events.Register( "fgTIME::updateLocal()",
426                             fgMethodCallback<FGTime>(FGTime::cur_time_params, 
427                                                      &FGTime::updateLocal),
428                             fgEVENT::FG_EVENT_READY, 1800000);
429
430     // Initialize the weather modeling subsystem
431 #ifndef FG_OLD_WEATHER
432     // Initialize the WeatherDatabase
433     FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase");
434     sgVec3 position;
435     sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
436                current_aircraft.fdm_state->get_Longitude(),
437                current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER );
438     FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 
439         new FGLocalWeatherDatabase( position );
440     // cout << theFGLocalWeatherDatabase << endl;
441     // cout << "visibility = " 
442     //      << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
443
444     WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
445      
446     // register the periodic update of the weather
447     global_events.Register( "weather update", fgUpdateWeatherDatabase,
448                             fgEVENT::FG_EVENT_READY, 30000);
449 #else
450     current_weather.Init();
451 #endif
452
453     // Initialize the Cockpit subsystem
454     if( fgCockpitInit( &current_aircraft )) {
455         // Cockpit initialized ok.
456     } else {
457         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Cockpit initialization!" );
458         exit(-1);
459     }
460
461     // Initialize the flight model subsystem data structures base on
462     // above values
463
464     // fgFDMInit( current_options.get_flight_model(), cur_fdm_state,
465     //            1.0 / current_options.get_model_hz() );
466     cur_fdm_state->init( 1.0 / current_options.get_model_hz() );
467
468     // I'm just sticking this here for now, it should probably move
469     // eventually
470     scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
471
472     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
473         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
474     }
475
476     FG_LOG( FG_GENERAL, FG_INFO,
477             "Updated position (after elevation adj): ("
478             << (cur_fdm_state->get_Latitude() * RAD_TO_DEG) << ", "
479             << (cur_fdm_state->get_Longitude() * RAD_TO_DEG) << ", "
480             << (cur_fdm_state->get_Altitude() * FEET_TO_METER) << ")" );
481     // end of thing that I just stuck in that I should probably move
482
483     // Joystick support
484     if ( fgJoystickInit() ) {
485         // Joystick initialized ok.
486     } else {
487         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Joystick initialization!" );
488     }
489
490     // Autopilot init added here, by Jeff Goeke-Smith
491     fgAPInit(&current_aircraft);
492
493     // Initialize I/O channels
494 #if ! defined( MACOS )
495     fgIOInit();
496 #endif
497
498     FG_LOG( FG_GENERAL, FG_INFO, endl);
499
500     return true;
501 }
502
503
504 void fgReInitSubsystems( void )
505 {
506     FGTime *t = FGTime::cur_time_params;
507     
508     int toggle_pause = t->getPause();
509     
510     if( !toggle_pause )
511         t->togglePauseMode();
512     
513     fgInitPosition();
514     if( global_tile_mgr.init() ) {
515         // Load the local scenery data
516         global_tile_mgr.update();
517     } else {
518         FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
519                 exit(-1);
520     }
521     fgFDMSetGroundElevation( current_options.get_flight_model(), 
522                              scenery.cur_elev );
523
524     // Reset our altitude if we are below ground
525     FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << cur_fdm_state->get_Altitude() );
526     FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " << 
527             cur_fdm_state->get_Runway_altitude() );
528
529     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
530         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
531     }
532     double sea_level_radius_meters;
533     double lat_geoc;
534     // Set the FG variables first
535     fgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(), 
536                   &sea_level_radius_meters, &lat_geoc);
537     cur_fdm_state->set_Geocentric_Position( lat_geoc, cur_fdm_state->get_Longitude(), 
538                                 cur_fdm_state->get_Altitude() + 
539                                 (sea_level_radius_meters * METER_TO_FEET) );
540     cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
541         
542     cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
543     cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
544         
545     cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
546     cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc));
547
548     // The following section sets up the flight model EOM parameters
549     // and should really be read in from one or more files.
550
551     // Initial Velocity
552     cur_fdm_state->set_Velocities_Local( current_options.get_uBody(),
553                              current_options.get_vBody(),
554                              current_options.get_wBody());
555
556     // Initial Orientation
557     cur_fdm_state->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
558                          current_options.get_pitch() * DEG_TO_RAD,
559                          current_options.get_heading() * DEG_TO_RAD );
560
561     // Initial Angular Body rates
562     cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
563
564     cur_fdm_state->set_Earth_position_angle( 0.0 );
565
566     // Mass properties and geometry values
567     cur_fdm_state->set_Inertias( 8.547270E+01, 
568                      1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
569
570     // CG position w.r.t. ref. point
571     cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
572
573     // Initialize view parameters
574     current_view.set_view_offset( 0.0 );
575     current_view.set_goal_view_offset( 0.0 );
576     pilot_view.set_view_offset( 0.0 );
577     pilot_view.set_goal_view_offset( 0.0 );
578
579     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
580     current_view.UpdateViewMath(*cur_fdm_state);
581     pilot_view.UpdateViewMath(*cur_fdm_state);
582     FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << current_view.get_abs_view_pos());
583
584     // fgFDMInit( current_options.get_flight_model(), cur_fdm_state, 
585     //            1.0 / current_options.get_model_hz() );
586     cur_fdm_state->init( 1.0 / current_options.get_model_hz() );
587
588     scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
589
590     if ( cur_fdm_state->get_Altitude() < cur_fdm_state->get_Runway_altitude() + 3.758099) {
591         cur_fdm_state->set_Altitude( cur_fdm_state->get_Runway_altitude() + 3.758099 );
592     }
593
594     controls.reset_all();
595     fgAPReset();
596
597     if( !toggle_pause )
598         t->togglePauseMode();
599 }