]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/main.cxx
Added code to put aircraft at the end of the runway closest to the desired
[flightgear.git] / src / Main / main.cxx
index 1afd19c32322348f903fb4caaba7e9a63b8810bb..4cd07e5a668198831b568f3a018719271c2a1b5f 100644 (file)
@@ -810,10 +810,10 @@ static void fgMainLoop( void ) {
     }
 
     // update magvar model
-    cur_magvar.update( cur_fdm_state->get_Longitude(),
-                      cur_fdm_state->get_Latitude(),
-                      cur_fdm_state->get_Altitude()* FEET_TO_METER,
-                      globals->get_time_params()->getJD() );
+    globals->get_mag()->update( cur_fdm_state->get_Longitude(),
+                               cur_fdm_state->get_Latitude(),
+                               cur_fdm_state->get_Altitude()* FEET_TO_METER,
+                               globals->get_time_params()->getJD() );
 
     // Get elapsed time (in usec) for this past frame
     elapsed = fgGetTimeInterval();
@@ -891,6 +891,8 @@ static void fgMainLoop( void ) {
 
 #   ifdef MICHAEL_JOHNSON_EXPERIMENTAL_ENGINE_AUDIO
 
+       static double kts_to_fts = NM_TO_METER * METER_TO_FEET / 3600.0;
+
        // note: all these factors are relative to the sample.  our
        // sample format should really contain a conversion factor so
        // that we can get prop speed right for arbitrary samples.
@@ -904,17 +906,17 @@ static void fgMainLoop( void ) {
        double pitch = log((controls.get_throttle(0) * 14.0) + 1.0);
        //fprintf(stderr, "pitch1: %f ", pitch);
        // if (controls.get_throttle(0) > 0.0 || 
-       //     cur_fdm_state->v_rel_wind > 40.0) {
+       //     cur_fdm_state->get_V_calibrated_kts() > 40.0) {
 
-       //fprintf(stderr, "rel_wind: %f ", cur_fdm_state->v_rel_wind);
+       //fprintf(stderr, "rel_wind: %f ", cur_fdm_state->get_V_calibrated_kts());
        // only add relative wind and AoA if prop is moving
        // or we're really flying at idle throttle
        if (pitch < 5.4) {  // this needs tuning
            // prop tips not breaking sound barrier
-           pitch += log(cur_fdm_state->v_rel_wind + 0.8)/2;
+           pitch += log(cur_fdm_state->get_V_calibrated_kts() * kts_to_fts + 0.8)/2;
        } else {
            // prop tips breaking sound barrier
-           pitch += log(cur_fdm_state->v_rel_wind + 0.8)/10;
+           pitch += log(cur_fdm_state->get_V_calibrated_kts() * kts_to_fts + 0.8)/10;
        }
        //fprintf(stderr, "pitch2: %f ", pitch);
        //fprintf(stderr, "AoA: %f ", FG_Gamma_vert_rad);
@@ -936,7 +938,7 @@ static void fgMainLoop( void ) {
        // fprintf(stderr, "pitch4: %f\n", pitch);
 
        double volume = controls.get_throttle(0) * 1.15 + 0.3 +
-           log(cur_fdm_state->v_rel_wind + 1.0)/14.0;
+           log(cur_fdm_state->get_V_calibrated_kts() * kts_to_fts + 1.0)/14.0;
        // fprintf(stderr, "volume: %f\n", volume);
 
        pitch_envelope.setStep  ( 0, 0.01, pitch );
@@ -1315,14 +1317,16 @@ int main( int argc, char **argv ) {
 
     // set current_options lon/lat if an airport id is specified
     if ( current_options.get_airport_id().length() ) {
-       fgSetPosFromAirportID( current_options.get_airport_id() );
+       // fgSetPosFromAirportID( current_options.get_airport_id() );
+       fgSetPosFromAirportIDandHdg( current_options.get_airport_id(),
+                                    current_options.get_heading() );
     }
 
     // Initialize time
     FGPath zone( current_options.get_fg_root() );
     zone.append( "Timezone" );
-    SGTime *t = new SGTime( current_options.get_lon(),
-                           current_options.get_lat(),
+    SGTime *t = new SGTime( current_options.get_lon() * DEG_TO_RAD,
+                           current_options.get_lat() * DEG_TO_RAD,
                            zone.str() );
 
     // Handle potential user specified time offsets
@@ -1428,6 +1432,10 @@ int main( int argc, char **argv ) {
     // thesky->add_cloud_layer( 1800.0, 400.0, 100.0, SG_CLOUD_OVERCAST );
     // thesky->add_cloud_layer( 5000.0, 20.0, 10.0, SG_CLOUD_CIRRUS );
 
+    // Initialize MagVar model
+    SGMagVar *magvar = new SGMagVar();
+    globals->set_mag( magvar );
+
     // Terrain branch
     terrain = new ssgBranch;
     terrain->setName( "Terrain" );