diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index f7269056ee..9fa38b8de0 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -155,7 +155,8 @@ namespace OpenRA.Mods.Common.Traits .Where(a => !a.Actor.IsDead && a.Actor.IsInWorld && a.Actor.Owner.IsAlliedWith(self.Owner) && Info.RepairActors.Contains(a.Actor.Info.Name)) - .OrderBy(p => (self.Location - p.Actor.Location).LengthSquared); + .OrderBy(a => a.Actor.Owner == self.Owner ? 0 : 1) + .ThenBy(p => (self.Location - p.Actor.Location).LengthSquared); // Worst case FirstOrDefault() will return a TraitPair, which is OK. return repairBuilding.FirstOrDefault().Actor; diff --git a/OpenRA.Mods.Common/Traits/RepairableNear.cs b/OpenRA.Mods.Common/Traits/RepairableNear.cs index d763da418a..ba9a3ff0d3 100644 --- a/OpenRA.Mods.Common/Traits/RepairableNear.cs +++ b/OpenRA.Mods.Common/Traits/RepairableNear.cs @@ -99,7 +99,8 @@ namespace OpenRA.Mods.Common.Traits .Where(a => !a.Actor.IsDead && a.Actor.IsInWorld && a.Actor.Owner.IsAlliedWith(self.Owner) && Info.RepairActors.Contains(a.Actor.Info.Name)) - .OrderBy(p => (self.Location - p.Actor.Location).LengthSquared); + .OrderBy(a => a.Actor.Owner == self.Owner ? 0 : 1) + .ThenBy(p => (self.Location - p.Actor.Location).LengthSquared); // Worst case FirstOrDefault() will return a TraitPair, which is OK. return repairBuilding.FirstOrDefault().Actor;