Skip to content

Commit 2353e0f

Browse files
committed
Take into account maximum power from diesel engine
1 parent 2a36208 commit 2353e0f

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,20 +1376,13 @@ public void Update(float elapsedClockSeconds)
13761376

13771377
if (DieselPowerTab != null)
13781378
{
1379-
CurrentDieselOutputPowerW = (DieselPowerTab[RawRpM] * (1 - Locomotive.PowerReduction) <= MaximumDieselPowerW * (1 - Locomotive.PowerReduction) ? DieselPowerTab[RawRpM] * (1 - Locomotive.PowerReduction) : MaximumDieselPowerW * (1 - Locomotive.PowerReduction));
1379+
CurrentDieselOutputPowerW = Math.Min(DieselPowerTab[RawRpM], MaximumDieselPowerW) * (1 - Locomotive.PowerReduction);
13801380
}
13811381
else
13821382
{
13831383
CurrentDieselOutputPowerW = (RawRpM - IdleRPM) / (MaxRPM - IdleRPM) * MaximumDieselPowerW * (1 - Locomotive.PowerReduction);
13841384
}
13851385

1386-
if (Locomotive.DieselEngines.NumOfActiveEngines > 0)
1387-
{
1388-
1389-
CurrentDieselOutputPowerW -= Locomotive.DieselPowerSupply.ElectricTrainSupplyPowerW / Locomotive.DieselEngines.NumOfActiveEngines;
1390-
CurrentDieselOutputPowerW = CurrentDieselOutputPowerW < 0f ? 0f : CurrentDieselOutputPowerW;
1391-
}
1392-
13931386
CurrentDieselOutputPowerW = MathHelper.Clamp(CurrentDieselOutputPowerW, 0.0f, CurrentDieselOutputPowerW); // prevent power going -ve
13941387

13951388
// For geared locomotives the engine RpM can be higher then the throttle demanded rpm, and this gives an inflated value of power

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Orts.Common;
1919
using Orts.Parsers.Msts;
2020
using ORTS.Scripting.Api;
21+
using System;
2122
using System.IO;
2223

2324
namespace Orts.Simulation.RollingStocks.SubSystems.PowerSupplies
@@ -258,6 +259,8 @@ public override void Update(float elapsedClockSeconds)
258259
DieselEngineMinRpm = 0;
259260
}
260261

262+
AvailableTractionPowerW = Math.Max(DieselEngineOutputPowerW - ElectricTrainSupplyPowerW, 0);
263+
261264
UpdateSounds();
262265
}
263266

0 commit comments

Comments
 (0)