@@ -360,11 +360,25 @@ private void Enqueue(FlightCtrlState fs)
360360 var dfs = new DelayedFlightCtrlState ( fs ) ;
361361 dfs . TimeStamp += Delay ;
362362
363- if ( StockAutopilotCommand . IsAutoPilotEngaged ( this ) ) // remove the delay if the autopilot is engaged
364- dfs . TimeStamp -= Delay ;
363+ if ( StockAutopilotCommand . IsAutoPilotEngaged ( this ) ) // remove the delay if the autopilot is engaged
364+ {
365+ var autopilotfs = new DelayedFlightCtrlState ( fs ) ; // make copy of FS and apply no delay
365366
366- _flightCtrlQueue . Enqueue ( dfs ) ;
367+ //nullify autopilot inputs in the delayed fs
368+ dfs . State . roll = 0f ;
369+ dfs . State . rollTrim = 0f ;
370+ dfs . State . pitch = 0f ;
371+ dfs . State . pitchTrim = 0f ;
372+ dfs . State . yaw = 0f ;
373+ dfs . State . yawTrim = 0f ;
374+
375+ //nullify throttle
376+ autopilotfs . State . mainThrottle = 0f ;
377+
378+ _flightCtrlQueue . Enqueue ( autopilotfs ) ;
379+ }
367380
381+ _flightCtrlQueue . Enqueue ( dfs ) ;
368382 }
369383
370384 /// <summary>Remove a <see cref="FlightCtrlState"/> from the flight control queue.</summary>
@@ -373,20 +387,22 @@ private void Enqueue(FlightCtrlState fs)
373387 private void PopFlightCtrl ( FlightCtrlState fcs , ISatellite sat )
374388 {
375389 var delayed = new FlightCtrlState ( ) ;
376- delayed . mainThrottle = fcs . mainThrottle ;
390+ float maxThrottle = 0f ;
391+
392+ while ( _flightCtrlQueue . Count > 0 && _flightCtrlQueue . Peek ( ) . TimeStamp <= RTUtil . GameTime )
393+ {
394+ delayed = _flightCtrlQueue . Dequeue ( ) . State ;
395+ maxThrottle = Math . Max ( maxThrottle , delayed . mainThrottle ) ;
396+ }
397+ delayed . mainThrottle = maxThrottle ;
377398
378399 if ( ! KeepThrottleNoConnect && ! InputAllowed ) // enforce the rule of shutting throttle down on connection loss
379400 {
380401 delayed . mainThrottle = 0f ;
381402 }
382403 else if ( KeepThrottleNoConnect && LockedThrottleNoConnect ) // when connection is lost with the disabled rule of shutting throttle down, throttle is locked
383404 {
384- delayed . mainThrottle = LockedThrottlePositionNoConnect ;
385- }
386-
387- while ( _flightCtrlQueue . Count > 0 && _flightCtrlQueue . Peek ( ) . TimeStamp <= RTUtil . GameTime )
388- {
389- delayed = _flightCtrlQueue . Dequeue ( ) . State ;
405+ delayed . mainThrottle = LockedThrottlePositionNoConnect ;
390406 }
391407
392408 fcs . CopyFrom ( delayed ) ;
@@ -465,7 +481,7 @@ private void OnFlyByWirePre(FlightCtrlState fcs)
465481
466482 if ( ! satellite . HasLocalControl )
467483 {
468- if ( InputAllowed )
484+ if ( InputAllowed ) // working connection
469485 {
470486 LockedThrottleNoConnect = false ;
471487 }
0 commit comments