diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 92862b8eb3..0a5b459709 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -139,8 +139,15 @@ namespace OpenRA.Orders if (mi.Modifiers.HasModifier(Modifiers.Alt)) modifiers |= TargetModifiers.ForceMove; + // The Select(x => x) is required to work around an issue on mono 5.0 + // where calling OrderBy* on SelectManySingleSelectorIterator can in some + // circumstances (which we were unable to identify) replace entries in the + // enumeration with duplicates of other entries. + // Other action that replace the SelectManySingleSelectorIterator with a + // different enumerator type (e.g. .Where(true) or .ToList()) also work. var orders = self.TraitsImplementing() .SelectMany(trait => trait.Orders.Select(x => new { Trait = trait, Order = x })) + .Select(x => x) .OrderByDescending(x => x.Order.OrderPriority); for (var i = 0; i < 2; i++)