Skip to content

Commit

Permalink
Bug fix for https://bugs.launchpad.net/or/+bug/1983511 When an AI tra…
Browse files Browse the repository at this point in the history
…in disappears at end of run, containers remain visible
  • Loading branch information
Csantucci committed Aug 7, 2022
1 parent a6c0f04 commit 9664141
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/Orts.Simulation/Simulation/AIs/AI.cs
Expand Up @@ -1328,6 +1328,9 @@ private void RemoveTrains()
{
car.Train = null; // WorldPosition.XNAMatrix.M42 -= 1000;
car.IsPartOfActiveTrain = false; // to stop sounds
// remove continers if any
if (car.FreightAnimations?.Animations != null)
car.FreightAnimations?.RemoveDiscreteFreightAnimations(car as MSTSWagon);
}
}
}
Expand Down
Expand Up @@ -863,6 +863,22 @@ public bool CheckForMerge(int i)
}
return false;
}

/// <summary>
/// Removes discrete freight animations and containers when AI train is deleted
/// </summary>

public void RemoveDiscreteFreightAnimations(MSTSWagon wagon)
{
foreach (var animation in Animations)
{
if (animation is FreightAnimationDiscrete discreteAnimation && discreteAnimation.Container != null)
{
wagon.Simulator.ContainerManager.Containers.Remove(discreteAnimation.Container);
}
}

}
}


Expand Down

0 comments on commit 9664141

Please sign in to comment.