Skip to content

Commit a10de3a

Browse files
committed
Fix bugs introduced during post-review changes
1 parent 2353e0f commit a10de3a

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ locomotive (regardless of transmission type) are as follows:
425425
single: MaxPower
426426
single: MaxForce
427427
single: MaxContinuousForce
428+
single: ORTSTractiveForceIsPowerLimited
428429

429430
``ORTSDieselEngineMaxPower`` ==> sets the maximum power output at the
430431
shaft of the diesel engine (or prime mover).
@@ -438,6 +439,9 @@ wheels when starting.
438439
continuously supply to the wheels without exceeding the design specifications.
439440
Typically this is linked to a particular speed (see next parameter).
440441

442+
``ORTSTractiveForceIsPowerLimited`` ==> determines if tractive force curves
443+
shall be limited to the available output power from the diesel engine.
444+
441445
.. index::
442446
single: ORTSSpeedOfMaxContinuousForce
443447
single: MaxVelocity

Source/Orts.Simulation/Simulation/RollingStocks/MSTSDieselLocomotive.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public float DieselLevelL
9090
float InitialMassKg = 100000.0f;
9191

9292
public float LocomotiveMaxRailOutputPowerW;
93+
public bool TractiveForcePowerLimited = false;
9394

9495
public float EngineRPM;
9596
public SmoothedData ExhaustParticles = new SmoothedData(1);
@@ -170,6 +171,8 @@ public override void Parse(string lowercasetoken, STFReader stf)
170171
case "engine(dieselsmokeeffectmaxsmokerate": MaxExhaust = stf.ReadFloatBlock(STFReader.UNITS.None, null); break;
171172
case "engine(dieselsmokeeffectmaxmagnitude": MaxMagnitude = stf.ReadFloatBlock(STFReader.UNITS.None, null); break;
172173

174+
case "engine(ortstractiveforceispowerlimited": TractiveForcePowerLimited = stf.ReadBoolBlock(false); break;
175+
173176
case "engine(ortsdieseltransmissiontype":
174177
stf.MustMatch("(");
175178
var transmissionType = stf.ReadString();
@@ -437,6 +440,8 @@ public override void Copy(MSTSWagon copy)
437440
EngineRPMderivation = locoCopy.EngineRPMderivation;
438441
EngineRPMold = locoCopy.EngineRPMold;
439442

443+
TractiveForcePowerLimited = locoCopy.TractiveForcePowerLimited;
444+
440445
MaxDieselLevelL = locoCopy.MaxDieselLevelL;
441446
DieselUsedPerHourAtMaxPowerL = locoCopy.DieselUsedPerHourAtMaxPowerL;
442447
DieselUsedPerHourAtIdleL = locoCopy.DieselUsedPerHourAtIdleL;

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,7 @@ public void UpdateForceWithRamp(ref float forceN, float elapsedClockSeconds, flo
25262526
{
25272527
if (targetForceN > maxForceN) targetForceN = maxForceN;
25282528
if (forceN > maxForceN) forceN = maxForceN;
2529+
bool toZero = targetForceN == 0;
25292530
if (AbsTractionSpeedMpS > 0)
25302531
{
25312532
float powerW = forceN * PrevAbsTractionSpeedMpS;
@@ -2539,23 +2540,25 @@ public void UpdateForceWithRamp(ref float forceN, float elapsedClockSeconds, flo
25392540
targetForceN = Math.Min(targetForceN, targetPowerW / AbsTractionSpeedMpS);
25402541
}
25412542
}
2542-
if (targetPowerW < powerW && (targetPowerW == 0 ? rampZeroWpS : rampDownWpS) > 0)
2543+
if (targetPowerW < powerW && (toZero ? rampZeroWpS : rampDownWpS) > 0)
25432544
{
2544-
float maxChangeW = (targetPowerW == 0 ? rampZeroWpS : rampDownWpS) * elapsedClockSeconds;
2545+
float maxChangeW = (toZero ? rampZeroWpS : rampDownWpS) * elapsedClockSeconds;
25452546
if (powerW - maxChangeW > targetPowerW)
25462547
{
25472548
targetPowerW = powerW - maxChangeW;
25482549
targetForceN = Math.Max(targetForceN, Math.Min(forceN, targetPowerW / AbsTractionSpeedMpS));
25492550
}
25502551
}
25512552
}
2552-
if (targetForceN > forceN && rampUpNpS > 0)
2553+
if (targetForceN > forceN)
25532554
{
2554-
forceN = Math.Min(targetForceN, forceN + rampUpNpS * elapsedClockSeconds);
2555+
if (rampUpNpS > 0) forceN = Math.Min(forceN + rampUpNpS * elapsedClockSeconds, targetForceN);
2556+
else forceN = targetForceN;
25552557
}
2556-
else if (targetForceN < forceN && (targetForceN == 0 ? rampZeroNpS : rampDownNpS) > 0)
2558+
else if (targetForceN < forceN)
25572559
{
2558-
forceN = Math.Max(targetForceN, forceN - (targetForceN == 0 ? rampZeroNpS : rampDownNpS) * elapsedClockSeconds);
2560+
if ((toZero ? rampZeroNpS : rampDownNpS) > 0) forceN = Math.Max(forceN - (toZero ? rampZeroNpS : rampDownNpS) * elapsedClockSeconds, targetForceN);
2561+
else forceN = targetForceN;
25592562
}
25602563
}
25612564
/// <summary>
@@ -2611,7 +2614,7 @@ protected virtual void UpdateTractionForce(float elapsedClockSeconds)
26112614
// Ensure that throttle never exceeds the limits imposed by other subsystems
26122615
float maxthrottle = MaxThrottlePercent / 100;
26132616
// For diesel locomotives, also take into account the throttle setting associated to the current engine RPM
2614-
if (IsPlayerTrain && this is MSTSDieselLocomotive diesel) maxthrottle = Math.Min(maxthrottle, diesel.DieselEngines.ApparentThrottleSetting / 100.0f);
2617+
if (IsPlayerTrain && this is MSTSDieselLocomotive diesel && !diesel.TractiveForcePowerLimited) maxthrottle = Math.Min(maxthrottle, diesel.DieselEngines.ApparentThrottleSetting / 100.0f);
26152618
if (t > maxthrottle) t = maxthrottle;
26162619
t = MathHelper.Clamp(t, 0, 1);
26172620

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DieselPowerSupply.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ public override void Update(float elapsedClockSeconds)
259259
DieselEngineMinRpm = 0;
260260
}
261261

262-
AvailableTractionPowerW = Math.Max(DieselEngineOutputPowerW - ElectricTrainSupplyPowerW, 0);
262+
if (DieselLocomotive.TractiveForcePowerLimited)
263+
AvailableTractionPowerW = Math.Max(DieselEngineOutputPowerW - ElectricTrainSupplyPowerW, 0);
263264

264265
UpdateSounds();
265266
}

0 commit comments

Comments
 (0)