Skip to content

Commit e088778

Browse files
committed
Fix calculation of control animations with reversed positions
1 parent 4ff58ac commit e088778

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,10 @@ public CVCDiscrete(STFReader stf, string basepath, DiscreteStates discreteState)
11501150
if (Positions.Count > 0 && Positions[0] > Positions[Positions.Count - 1])
11511151
{
11521152
Reversed ^= true;
1153+
int maxPos = Positions.Max();
11531154
// Recalculate positions in reverse
11541155
for (int i = 0; i < Positions.Count; i++)
1155-
Positions[i] = (FramesCount - 1) - Positions[i];
1156+
Positions[i] = maxPos - Positions[i];
11561157
}
11571158

11581159
// Check if eligible for filling

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4201,7 +4201,7 @@ public void StartThrottleToZero(float? target)
42014201
/// Returns the position of the throttle handle considering
42024202
/// whether it is used for cruise control or not
42034203
/// </summary>
4204-
/// <param name="intermediateValue">Whather asking for intermediate (for mouse operation) or notched (for displaying) value.</param>
4204+
/// <param name="intermediateValue">Whether asking for intermediate (for mouse operation) or notched (for displaying) value.</param>
42054205
/// <returns>Position into 0-1 range</returns>
42064206
public float GetThrottleHandleValue(bool intermediateValue)
42074207
{
@@ -4213,7 +4213,7 @@ public float GetThrottleHandleValue(bool intermediateValue)
42134213
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.UseThrottleAsSpeedSelector)
42144214
return CruiseControl.SelectedSpeedMpS / MaxSpeedMpS;
42154215

4216-
return intermediateValue ? ThrottleController.CurrentValue : ThrottleController.IntermediateValue;
4216+
return intermediateValue ? ThrottleController.IntermediateValue : ThrottleController.CurrentValue;
42174217
}
42184218

42194219
#endregion

0 commit comments

Comments
 (0)