Skip to content

Commit de91cc4

Browse files
committed
Fix bug with calculating limits when switching trains.
When switching from a train with low limits for the coupler strength and derail force to a train with higher limits, the limits in the popup window text line were not updated.
1 parent 3b18c48 commit de91cc4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Source/RunActivity/Viewer3D/Popups/TrainForcesWindow.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ public class TrainForcesWindow : Window
9494
private int LastPlayerTrainCars;
9595
private bool LastPlayerLocomotiveFlippedState;
9696

97-
private float LimitForCouplerStrengthN = 2.2e6f; // 500k lbf, used for graph scale only
97+
private static readonly float HighestRealisticCouplerStrengthN = 2.2e6f; // 500k lbf, used for graph scale only
98+
private float LimitForCouplerStrengthN = HighestRealisticCouplerStrengthN;
9899
private float CouplerStrengthScaleN;
99100

100-
private float LimitForDerailForceN = 1.55e5f; // 35k lbf, used for graph scale only
101+
private static readonly float HighestRealisticDerailForceN = 1.55e5f; // 35k lbf, used for graph scale only
102+
private float LimitForDerailForceN = HighestRealisticDerailForceN;
101103
private float DerailForceScaleN;
102104

103-
private float LimitForBrakeForceN = 2.0e5f; // 45k lbf, used for graph scale only
105+
private static readonly float HighestRealisticBrakeForceN = 2.0e5f; // 45k lbf, used for graph scale only
106+
private float LimitForBrakeForceN = HighestRealisticBrakeForceN;
104107
private float BrakeForceScaleN;
105108

106109
private Image[] CouplerForceBarGraph;
@@ -312,9 +315,9 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
312315
/// </summary>
313316
private void SetConsistProperties(Train theTrain)
314317
{
315-
float lowestCouplerBreakN = LimitForCouplerStrengthN;
316-
float lowestDerailForceN = LimitForDerailForceN;
317-
float lowestMaxBrakeForceN = LimitForBrakeForceN;
318+
float lowestCouplerBreakN = HighestRealisticCouplerStrengthN;
319+
float lowestDerailForceN = HighestRealisticDerailForceN;
320+
float lowestMaxBrakeForceN = HighestRealisticBrakeForceN;
318321

319322
foreach (var car in theTrain.Cars)
320323
{

0 commit comments

Comments
 (0)