Skip to content

Commit 49b9543

Browse files
authored
2 parents e76166a + b24ab3d commit 49b9543

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,6 +3215,16 @@ public virtual void UpdateFollowingState(float elapsedClockSeconds, int presentT
32153215
AdjustControlsAccelMore(0.5f * MaxAccelMpSS, elapsedClockSeconds, 10);
32163216
}
32173217
}
3218+
if (OtherTrain.UncoupledFrom == this)
3219+
{
3220+
if (distanceToTrain > 5.0f)
3221+
{
3222+
UncoupledFrom = null;
3223+
OtherTrain.UncoupledFrom = null;
3224+
}
3225+
else
3226+
attachToTrain = false;
3227+
}
32183228
// if (distanceToTrain < keepDistanceStatTrainM_P - 4.0f || (distanceToTrain - brakingDistance) <= keepDistanceTrainM) // Other possibility
32193229
if ((distanceToTrain - brakingDistance) <= keepDistanceTrainM)
32203230
{
@@ -4600,6 +4610,7 @@ public void LeaveCarsToLivingTrain(Train attachTrain, bool thisTrainFront, bool
46004610
attachTrain.Cars.Insert(0, car);
46014611
car.Train = attachTrain;
46024612
car.Flipped = !car.Flipped;
4613+
if (attachTrain.IsActualPlayerTrain && attachTrain.LeadLocomotiveIndex != -1) attachTrain.LeadLocomotiveIndex++;
46034614
}
46044615
else
46054616
{
@@ -4635,6 +4646,7 @@ public void LeaveCarsToLivingTrain(Train attachTrain, bool thisTrainFront, bool
46354646
{
46364647
attachTrain.Cars.Insert(0, car);
46374648
car.Train = attachTrain;
4649+
if (attachTrain.IsActualPlayerTrain && attachTrain.LeadLocomotiveIndex != -1) attachTrain.LeadLocomotiveIndex++;
46384650
}
46394651
passedLength += car.CarLengthM;
46404652
attachTrain.Length += car.CarLengthM;
@@ -4683,6 +4695,7 @@ public void StealCarsToLivingTrain(Train attachTrain, bool thisTrainFront, bool
46834695
Length += car.CarLengthM;
46844696
attachTrain.Length -= car.CarLengthM;
46854697
attachTrain.Cars.Remove(car);
4698+
if (attachTrain.IsActualPlayerTrain && attachTrain.LeadLocomotiveIndex != -1) attachTrain.LeadLocomotiveIndex--;
46864699
}
46874700
}
46884701
attachTrain.Cars[0].SignalEvent(Event.Couple);

0 commit comments

Comments
 (0)