Skip to content

Commit 7e949c3

Browse files
committed
fix: Separate switch and crossover detection for flexibility
1 parent efae37a commit 7e949c3

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3108,7 +3108,7 @@ public virtual void UpdateWaterTroughRefill(float elapsedClockSeconds, float abs
31083108
Simulator.Confirmer.Message(ConfirmLevel.Error, Simulator.Catalog.GetString("Scoop is broken, can't refill"));
31093109
RefillingFromTrough = false;
31103110
}
3111-
else if (IsOverJunction)
3111+
else if (IsOverSwitch || IsOverCrossover)
31123112
{
31133113
if (!ScoopIsBroken) // Only display message first time scoop is broken
31143114
{

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,7 +3093,8 @@ private void AddVibrations(float factor)
30933093
}
30943094
#endregion
30953095

3096-
public bool IsOverJunction { get; private set; }
3096+
public bool IsOverSwitch { get; private set; }
3097+
public bool IsOverCrossover { get; private set; }
30973098
public bool IsOverTrough { get; private set; }
30983099

30993100
void UpdatePositionFlags()
@@ -3107,7 +3108,8 @@ void UpdatePositionFlags()
31073108
rearOffsetM += Train.Cars[i - 1].CouplerSlackM + Train.Cars[i - 1].GetCouplerZeroLengthM() + Train.Cars[i].CarLengthM;
31083109
var frontOffsetM = rearOffsetM + CarLengthM;
31093110

3110-
var isOverJunction = false;
3111+
var isOverSwitch = false;
3112+
var isOverCrossover = false;
31113113
var isOverTrough = false;
31123114

31133115
// Scan through the track sections forwards from the REAR of the train (`Train.PresentPosition[1]`),
@@ -3122,7 +3124,8 @@ void UpdatePositionFlags()
31223124
// Does this car overlap this track section?
31233125
if (checkedM <= frontOffsetM && rearOffsetM <= checkedM + section.Length)
31243126
{
3125-
if (section.CircuitType == TrackCircuitSection.TrackCircuitType.Junction || section.CircuitType == TrackCircuitSection.TrackCircuitType.Crossover) isOverJunction = true;
3127+
if (section.CircuitType == TrackCircuitSection.TrackCircuitType.Junction) isOverSwitch = true;
3128+
if (section.CircuitType == TrackCircuitSection.TrackCircuitType.Crossover) isOverCrossover = true;
31263129
if (section.TroughInfo != null)
31273130
{
31283131
foreach (var troughs in section.TroughInfo)
@@ -3139,7 +3142,8 @@ void UpdatePositionFlags()
31393142
currentPin = nextPin;
31403143
}
31413144

3142-
IsOverJunction = isOverJunction;
3145+
IsOverSwitch = isOverSwitch;
3146+
IsOverCrossover = isOverCrossover;
31433147
IsOverTrough = isOverTrough;
31443148
}
31453149

Source/RunActivity/Viewer3D/Sound.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public bool UpdateCarOnSwitchAndCurve()
395395

396396
var CarBehind = Car.Train.Cars[CarNo + CarIncr];
397397
var carPreviouslyOnSwitch = CarOnSwitch;
398-
CarOnSwitch = Car.IsOverJunction;
398+
CarOnSwitch = Car.IsOverSwitch || Car.IsOverCrossover;
399399

400400
// here check for curve
401401
var carPreviouslyOnCurve = CarOnCurve;

0 commit comments

Comments
 (0)