Skip to content

Commit 3d4cf22

Browse files
committed
Automatic merge of T1.5.1-351-gc9abcd22b and 9 pull requests
- Pull request #570 at de7a14f: Experimental glTF 2.0 support with PBR lighting - Pull request #732 at 79e9c38: Improvements for air brakes - Pull request #751 at 00981a2: Web interface to control cab controls with external hardware - Pull request #767 at 82c5f1c: Refine sunrise and sunset - Pull request #799 at eb92d81: Consolidated wind simulation - Pull request #803 at 7157e08: Various adjustments to steam adhesion - Pull request #809 at f67822a: Some on-screen messages not suppressed, Bug #2008012 - Pull request #813 at 80789c6: Refactored garbage generators - Pull request #814 at b102c1c: Bug fix for https://bugs.launchpad.net/or/+bug/2013969 Crash after uncoupling player loco of a train with EOT
11 parents 623773c + c9abcd2 + de7a14f + 79e9c38 + 00981a2 + 82c5f1c + eb92d81 + 7157e08 + f67822a + 80789c6 + b102c1c commit 3d4cf22

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

Source/Orts.Simulation/MultiPlayer/Message.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,11 +1634,11 @@ public override void HandleMsg() //only client will get message, thus will set s
16341634

16351635
train.MUDirection = (Direction)mDirection;
16361636
train.RearTDBTraveller = traveller;
1637+
train.ReinitializeEOT();
16371638
train.CalculatePositionOfCars();
16381639
train.travelled = Travelled;
16391640
train.CheckFreight();
16401641
train.SetDPUnitIDs();
1641-
train.ReinitializeEOT();
16421642
}
16431643
// New train
16441644
else

Source/Orts.Simulation/Simulation/AIs/AITrain.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,6 +4420,8 @@ public void CoupleAI(Train attachTrain, bool thisTrainFront, bool attachTrainFro
44204420
Cars.Clear();
44214421
attachTrain.Length += Length;
44224422

4423+
attachTrain.ReinitializeEOT();
4424+
44234425
// recalculate position of formed train
44244426
if (attachTrainFront) // coupled to front, so rear position is still valid
44254427
{
@@ -4448,7 +4450,6 @@ public void CoupleAI(Train attachTrain, bool thisTrainFront, bool attachTrainFro
44484450
// set various items
44494451
attachTrain.CheckFreight();
44504452
attachTrain.SetDPUnitIDs();
4451-
attachTrain.ReinitializeEOT();
44524453
attachTrain.activityClearingDistanceM = attachTrain.Cars.Count < standardTrainMinCarNo ? shortClearingDistanceM : standardClearingDistanceM;
44534454
attachCar.SignalEvent(Event.Couple);
44544455

@@ -4534,6 +4535,8 @@ public void CoupleAIToStatic(Train attachTrain, bool thisTrainFront, bool attach
45344535
Length += attachTrain.Length;
45354536
attachTrain.Cars.Clear();
45364537

4538+
ReinitializeEOT();
4539+
45374540
// recalculate position of formed train
45384541
if (thisTrainFront) // coupled to front, so rear position is still valid
45394542
{
@@ -4582,7 +4585,6 @@ public void CoupleAIToStatic(Train attachTrain, bool thisTrainFront, bool attach
45824585
UpdateOccupancies();
45834586
AddTrackSections();
45844587
ResetActions(true);
4585-
ReinitializeEOT();
45864588
physicsUpdate(0);
45874589

45884590
}
@@ -4750,6 +4752,8 @@ public void TerminateCoupling(Train attachTrain, bool thisTrainFront, bool attac
47504752
UncoupledFrom = attachTrain;
47514753
attachTrain.UncoupledFrom = this;
47524754

4755+
ReinitializeEOT();
4756+
attachTrain.ReinitializeEOT();
47534757

47544758
// recalculate position of coupling train
47554759
if (thisTrainFront) // coupled to front, so rear position is still valid
@@ -4810,11 +4814,9 @@ public void TerminateCoupling(Train attachTrain, bool thisTrainFront, bool attac
48104814
// set various items
48114815
CheckFreight();
48124816
SetDPUnitIDs();
4813-
ReinitializeEOT();
48144817
activityClearingDistanceM = Cars.Count < standardTrainMinCarNo ? shortClearingDistanceM : standardClearingDistanceM;
48154818
attachTrain.CheckFreight();
48164819
attachTrain.SetDPUnitIDs();
4817-
attachTrain.ReinitializeEOT();
48184820
attachTrain.activityClearingDistanceM = attachTrain.Cars.Count < standardTrainMinCarNo ? shortClearingDistanceM : standardClearingDistanceM;
48194821
// anticipate reversal point and remove active action
48204822
TCRoute.ReversalInfo[TCRoute.activeSubpath].ReverseReversalOffset = Math.Max(PresentPosition[0].TCOffset - 10f, 0.3f);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2983,7 +2983,7 @@ internal void UpdateVibrationAndTilting(Traveller traveler, float elapsedTimeS,
29832983

29842984
// Don't add vibrations to train cars less than 2.5 meter in length; they're unsuitable for these calculations.
29852985
// Don't let vibrate car before EOT to avoid EOT not moving together with that car
2986-
if (CarLengthM < 2.5f || Train.EOT != null && Train.Cars[Train.Cars.Count - 2] == this) return;
2986+
if (CarLengthM < 2.5f || Train.EOT != null && Train.Cars.Count > 1 && Train.Cars[Train.Cars.Count - 2] == this) return;
29872987
if (Simulator.Settings.CarVibratingLevel != 0)
29882988
{
29892989

Source/Orts.Simulation/Simulation/Simulator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,10 @@ public void UncoupleBehind(TrainCar car, bool keepFront)
17491749

17501750
}
17511751

1752+
// update EOT state
1753+
train.ReinitializeEOT();
1754+
train2.ReinitializeEOT();
1755+
17521756
// and fix up the travellers
17531757
if (train.IsActualPlayerTrain && j >= i || !keepFront)
17541758
{
@@ -1846,10 +1850,8 @@ public void UncoupleBehind(TrainCar car, bool keepFront)
18461850

18471851
train.CheckFreight();
18481852
train.SetDPUnitIDs();
1849-
train.ReinitializeEOT();
18501853
train2.CheckFreight();
18511854
train2.SetDPUnitIDs();
1852-
train2.ReinitializeEOT();
18531855

18541856
train.Update(0); // stop the wheels from moving etc
18551857
train2.Update(0); // stop the wheels from moving etc

Source/Orts.Simulation/Simulation/Timetables/TTTrain.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11705,6 +11705,8 @@ public void TTCouple(TTTrain attachTrain, bool thisTrainFront, bool attachTrainF
1170511705
attachTrain.Length += Length;
1170611706
float distanceTravelledCorrection = 0;
1170711707

11708+
attachTrain.ReinitializeEOT();
11709+
1170811710
// recalculate position of formed train
1170911711
if (attachTrainFront) // coupled to front, so rear position is still valid
1171011712
{
@@ -11769,7 +11771,6 @@ public void TTCouple(TTTrain attachTrain, bool thisTrainFront, bool attachTrainF
1176911771
// set various items
1177011772
attachTrain.CheckFreight();
1177111773
attachTrain.SetDPUnitIDs();
11772-
attachTrain.ReinitializeEOT();
1177311774
attachCar.SignalEvent(Event.Couple);
1177411775
attachTrain.ProcessSpeedSettings();
1177511776

@@ -12105,6 +12106,9 @@ public int TTUncoupleBehind(TTTrain newTrain, bool reverseTrain, int leadLocomot
1210512106

1210612107
}
1210712108

12109+
ReinitializeEOT();
12110+
newTrain.ReinitializeEOT();
12111+
1210812112
// and fix up the travellers
1210912113
if (DetachPosition)
1211012114
{
@@ -12153,10 +12157,8 @@ public int TTUncoupleBehind(TTTrain newTrain, bool reverseTrain, int leadLocomot
1215312157
// check freight for both trains
1215412158
CheckFreight();
1215512159
SetDPUnitIDs();
12156-
ReinitializeEOT();
1215712160
newTrain.CheckFreight();
1215812161
newTrain.SetDPUnitIDs();
12159-
newTrain.ReinitializeEOT();
1216012162

1216112163
// check speed values for both trains
1216212164
ProcessSpeedSettings();

0 commit comments

Comments
 (0)