From c480b2b59966cc5bdeeb8c8285306825b950aaa8 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 19 May 2019 17:56:35 +0100 Subject: [PATCH] Prefer own service depots over allies. --- OpenRA.Mods.Common/Traits/Repairable.cs | 3 ++- OpenRA.Mods.Common/Traits/RepairableNear.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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;