Eradicate ☠ Mono ☠
Co-Authored-By: Gustas <37534529+punkpun@users.noreply.github.com>
This commit is contained in:
@@ -159,15 +159,8 @@ namespace OpenRA.Mods.Common.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<IIssueOrder>()
|
||||
.SelectMany(trait => trait.Orders.Select(x => new { Trait = trait, Order = x }))
|
||||
.Select(x => x)
|
||||
.OrderByDescending(x => x.Order.OrderPriority)
|
||||
.ToList();
|
||||
|
||||
|
||||
@@ -48,14 +48,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public static Exit NearestExitOrDefault(this Actor actor, WPos pos, string productionType = null, Func<Exit, bool> p = null)
|
||||
{
|
||||
// The .ToList() is required to work around a bug/unexpected behaviour in mono, where
|
||||
// the ThenBy clause makes the FirstOrDefault behave differently than under .NET.
|
||||
// This is important because p may have side-effects that trigger a desync if not
|
||||
// called on the same exits in the same order!
|
||||
var all = Exits(actor, productionType)
|
||||
.OrderByDescending(e => e.Info.Priority)
|
||||
.ThenBy(e => (actor.World.Map.CenterOfCell(actor.Location + e.Info.ExitCell) - pos).LengthSquared)
|
||||
.ToList();
|
||||
.ThenBy(e => (actor.World.Map.CenterOfCell(actor.Location + e.Info.ExitCell) - pos).LengthSquared);
|
||||
|
||||
#pragma warning disable RCS1077 // Optimize LINQ method call.
|
||||
return p != null ? all.FirstOrDefault(p) : all.FirstOrDefault();
|
||||
|
||||
Reference in New Issue
Block a user