Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Csantucci committed Apr 4, 2022
1 parent 5b6d345 commit b24ab3d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Source/Orts.Simulation/Simulation/AIs/AITrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3215,6 +3215,16 @@ public virtual void UpdateFollowingState(float elapsedClockSeconds, int presentT
AdjustControlsAccelMore(0.5f * MaxAccelMpSS, elapsedClockSeconds, 10);
}
}
if (OtherTrain.UncoupledFrom == this)
{
if (distanceToTrain > 5.0f)
{
UncoupledFrom = null;
OtherTrain.UncoupledFrom = null;
}
else
attachToTrain = false;
}
// if (distanceToTrain < keepDistanceStatTrainM_P - 4.0f || (distanceToTrain - brakingDistance) <= keepDistanceTrainM) // Other possibility
if ((distanceToTrain - brakingDistance) <= keepDistanceTrainM)
{
Expand Down Expand Up @@ -4600,6 +4610,7 @@ public void LeaveCarsToLivingTrain(Train attachTrain, bool thisTrainFront, bool
attachTrain.Cars.Insert(0, car);
car.Train = attachTrain;
car.Flipped = !car.Flipped;
if (attachTrain.IsActualPlayerTrain && attachTrain.LeadLocomotiveIndex != -1) attachTrain.LeadLocomotiveIndex++;
}
else
{
Expand Down Expand Up @@ -4635,6 +4646,7 @@ public void LeaveCarsToLivingTrain(Train attachTrain, bool thisTrainFront, bool
{
attachTrain.Cars.Insert(0, car);
car.Train = attachTrain;
if (attachTrain.IsActualPlayerTrain && attachTrain.LeadLocomotiveIndex != -1) attachTrain.LeadLocomotiveIndex++;
}
passedLength += car.CarLengthM;
attachTrain.Length += car.CarLengthM;
Expand Down Expand Up @@ -4683,6 +4695,7 @@ public void StealCarsToLivingTrain(Train attachTrain, bool thisTrainFront, bool
Length += car.CarLengthM;
attachTrain.Length -= car.CarLengthM;
attachTrain.Cars.Remove(car);
if (attachTrain.IsActualPlayerTrain && attachTrain.LeadLocomotiveIndex != -1) attachTrain.LeadLocomotiveIndex--;
}
}
attachTrain.Cars[0].SignalEvent(Event.Couple);
Expand Down

0 comments on commit b24ab3d

Please sign in to comment.