]> git.mxchange.org Git - flightgear.git/blobdiff - src/Replay/replay.cxx
MSVC fix
[flightgear.git] / src / Replay / replay.cxx
index 88fc737072fc9300a55d497b22db5c0bb2cf3834..17cda3b711148eac967885f1c4391e21012dbd32 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started Juley 2003.
 //
-// Copyright (C) 2003  Curtis L. Olson  - curt@flightgear.org
+// Copyright (C) 2003  Curtis L. Olson  - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -102,7 +102,8 @@ void FGReplay::unbind() {
  */
 
 void FGReplay::update( double dt ) {
-    static SGPropertyNode *replay_master = fgGetNode( "/sim/freeze/replay" );
+    static SGPropertyNode *replay_master
+        = fgGetNode( "/sim/freeze/replay", true );
 
     if ( replay_master->getBoolValue() ) {
         // don't record the replay session
@@ -266,7 +267,8 @@ static FGReplayData interpolate( double time, FGReplayData f1, FGReplayData f2 )
         result.fdm.rpm[i] = weight( fdm1.rpm[i], fdm2.rpm[i], ratio );
         result.fdm.fuel_flow[i]
             = weight( fdm1.fuel_flow[i], fdm2.fuel_flow[i], ratio );
-        result.fdm.EGT[i] = weight( fdm1.EGT[i], fdm2.EGT[i], ratio );
+        result.fdm.egt[i] = weight( fdm1.egt[i], fdm2.egt[i], ratio );
+        result.fdm.mp_osi[i] = weight( fdm1.mp_osi[i], fdm2.mp_osi[i], ratio );
         result.fdm.oil_temp[i]
             = weight( fdm1.oil_temp[i], fdm2.oil_temp[i], ratio );
         result.fdm.oil_px[i] = weight( fdm1.oil_px[i], fdm2.oil_px[i], ratio );
@@ -280,8 +282,14 @@ static FGReplayData interpolate( double time, FGReplayData f1, FGReplayData f2 )
 
     // Gear status
     for ( i = 0; i < fdm1.num_wheels; ++i ) {
-        result.fdm.wow[i]
-            = weight( fdm1.wow[i], fdm2.wow[i], ratio );
+        result.fdm.wow[i] = weight( fdm1.wow[i], fdm2.wow[i], ratio );
+        result.fdm.gear_pos[i]
+            = weight( fdm1.gear_pos[i], fdm2.gear_pos[i], ratio );
+        result.fdm.gear_steer[i]
+            = weight( fdm1.gear_steer[i], fdm2.gear_steer[i], ratio );
+        result.fdm.gear_compression[i]
+            = weight( fdm1.gear_compression[i], fdm2.gear_compression[i],
+                      ratio );
     }
 
     // Environment
@@ -291,7 +299,8 @@ static FGReplayData interpolate( double time, FGReplayData f1, FGReplayData f2 )
 
     // Control surface positions (normalized values)
     result.fdm.elevator = weight( fdm1.elevator, fdm2.elevator, ratio );
-    result.fdm.flaps = weight( fdm1.flaps, fdm2.flaps, ratio );
+    result.fdm.left_flap = weight( fdm1.left_flap, fdm2.left_flap, ratio );
+    result.fdm.right_flap = weight( fdm1.right_flap, fdm2.right_flap, ratio );
     result.fdm.left_aileron
         = weight( fdm1.left_aileron, fdm2.left_aileron, ratio );
     result.fdm.right_aileron
@@ -309,11 +318,13 @@ static FGReplayData interpolate( double time, FGReplayData f1, FGReplayData f2 )
         = weight( ctrls1.elevator_trim, ctrls2.elevator_trim, ratio );
     result.ctrls.rudder = weight( ctrls1.rudder, ctrls2.rudder, ratio );
     result.ctrls.flaps = weight( ctrls1.flaps, ctrls2.flaps, ratio );
-    result.ctrls.flaps_power
-        = weight( ctrls1.flaps_power, ctrls2.flaps_power, ratio );
+    result.ctrls.flaps_power = ctrls1.flaps_power;
+    result.ctrls.flap_motor_ok = ctrls1.flap_motor_ok;
 
     // Engine controls
     for ( i = 0; i < ctrls1.num_engines; ++i ) {
+        result.ctrls.master_bat[i] = ctrls1.master_bat[i];
+        result.ctrls.master_alt[i] = ctrls1.master_alt[i];
         result.ctrls.magnetos[i] = ctrls1.magnetos[i];
         result.ctrls.starter_power[i] = ctrls1.starter_power[i];
         result.ctrls.throttle[i]
@@ -323,6 +334,12 @@ static FGReplayData interpolate( double time, FGReplayData f1, FGReplayData f2 )
         result.ctrls.fuel_pump_power[i] = ctrls1.fuel_pump_power[i];
         result.ctrls.prop_advance[i]
             = weight( ctrls1.prop_advance[i], ctrls2.prop_advance[i], ratio );
+        result.ctrls.engine_ok[i] = ctrls1.engine_ok[i];
+        result.ctrls.mag_left_ok[i] = ctrls1.mag_left_ok[i];
+        result.ctrls.mag_right_ok[i] = ctrls1.mag_right_ok[i];
+        result.ctrls.spark_plugs_ok[i] = ctrls1.spark_plugs_ok[i];
+        result.ctrls.oil_press_status[i] = ctrls1.oil_press_status[i];
+        result.ctrls.fuel_pump_ok[i] = ctrls1.fuel_pump_ok[i];
     }
 
     // Fuel management
@@ -331,17 +348,17 @@ static FGReplayData interpolate( double time, FGReplayData f1, FGReplayData f2 )
     }
 
     // Brake controls
-    for ( i = 0; i < ctrls1.num_wheels; ++i ) {
-        result.ctrls.brake[i]
-            = weight( ctrls1.brake[i], ctrls2.brake[i], ratio );
-    }
+    result.ctrls.brake_left
+            = weight( ctrls1.brake_left, ctrls2.brake_right, ratio );
+    result.ctrls.brake_right
+            = weight( ctrls1.brake_right, ctrls2.brake_right, ratio );
+    result.ctrls.brake_parking
+            = weight( ctrls1.brake_parking, ctrls2.brake_parking, ratio );
 
     // Landing Gear
     result.ctrls.gear_handle = ctrls1.gear_handle;
 
     // Switches
-    result.ctrls.master_bat = ctrls1.master_bat;
-    result.ctrls.master_alt = ctrls1.master_alt;
     result.ctrls.turbulence_norm = ctrls1.turbulence_norm;
 
     // wind and turbulance
@@ -366,7 +383,7 @@ static FGReplayData interpolate( double time, FGReplayData f1, FGReplayData f2 )
 /** 
  * interpolate a specific time from a specific list
  */
-static void interpolate( double time, replay_list_type list ) {
+static void interpolate( double time, const replay_list_type &list ) {
     // sanity checking
     if ( list.size() == 0 ) {
         // handle empty list
@@ -412,7 +429,7 @@ static void interpolate( double time, replay_list_type list ) {
  */
 
 void FGReplay::replay( double time ) {
-    cout << "replay: " << time << " ";
+    // cout << "replay: " << time << " ";
     // find the two frames to interpolate between
     double t1, t2;
 
@@ -422,10 +439,10 @@ void FGReplay::replay( double time ) {
         if ( time > t1 ) {
             // replay the most recent frame
             update_fdm( short_term.back() );
-            cout << "first frame" << endl;
+            // cout << "first frame" << endl;
         } else if ( time <= t1 && time >= t2 ) {
             interpolate( time, short_term );
-            cout << "from short term" << endl;
+            // cout << "from short term" << endl;
         } else if ( medium_term.size() > 0 ) {
             t1 = short_term.front().sim_time;
             t2 = medium_term.back().sim_time;
@@ -434,13 +451,13 @@ void FGReplay::replay( double time ) {
                                                    medium_term.back(),
                                                    short_term.front() );
                 update_fdm( result );
-                cout << "from short/medium term" << endl;
+                // cout << "from short/medium term" << endl;
             } else {
                 t1 = medium_term.back().sim_time;
                 t2 = medium_term.front().sim_time;
                 if ( time <= t1 && time >= t2 ) {
                     interpolate( time, medium_term );
-                    cout << "from medium term" << endl;
+                    // cout << "from medium term" << endl;
                 } else if ( long_term.size() > 0 ) {
                     t1 = medium_term.front().sim_time;
                     t2 = long_term.back().sim_time;
@@ -449,29 +466,29 @@ void FGReplay::replay( double time ) {
                                                            long_term.back(),
                                                            medium_term.front());
                         update_fdm( result );
-                       cout << "from medium/long term" << endl;
+                        // cout << "from medium/long term" << endl;
                     } else {
                         t1 = long_term.back().sim_time;
                         t2 = long_term.front().sim_time;
                         if ( time <= t1 && time >= t2 ) {
                             interpolate( time, long_term );
-                            cout << "from long term" << endl;
+                            // cout << "from long term" << endl;
                         } else {
                             // replay the oldest long term frame
                             update_fdm( long_term.front() );
-                            cout << "oldest long term frame" << endl;
+                            // cout << "oldest long term frame" << endl;
                         }
                     }
                 } else {
                     // replay the oldest medium term frame
                     update_fdm( medium_term.front() );
-                    cout << "oldest medium term frame" << endl;
+                    // cout << "oldest medium term frame" << endl;
                 }
             }
         } else {
             // replay the oldest short term frame
             update_fdm( short_term.front() );
-            cout << "oldest short term frame" << endl;
+            // cout << "oldest short term frame" << endl;
         }
     } else {
         // nothing to replay