From 71083445011d0d3a5cb463978cc237bdd1477460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 23 Aug 2015 19:21:13 +0200 Subject: [PATCH] bail out early before trying impossible paths --- OpenRA.Mods.Common/Activities/FindResources.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Activities/FindResources.cs b/OpenRA.Mods.Common/Activities/FindResources.cs index 49205a5997..55fce8ca29 100644 --- a/OpenRA.Mods.Common/Activities/FindResources.cs +++ b/OpenRA.Mods.Common/Activities/FindResources.cs @@ -27,6 +27,7 @@ namespace OpenRA.Mods.Common.Activities readonly ResourceLayer resLayer; readonly ResourceClaimLayer territory; readonly IPathFinder pathFinder; + readonly DomainIndex domainIndex; CPos? avoidCell; @@ -39,6 +40,7 @@ namespace OpenRA.Mods.Common.Activities resLayer = self.World.WorldActor.Trait(); territory = self.World.WorldActor.TraitOrDefault(); pathFinder = self.World.WorldActor.Trait(); + domainIndex = self.World.WorldActor.Trait(); } public FindResources(Actor self, CPos avoidCell) @@ -142,8 +144,9 @@ namespace OpenRA.Mods.Common.Activities var searchRadius = harv.LastOrderLocation.HasValue ? harvInfo.SearchFromOrderRadius : harvInfo.SearchFromProcRadius; var searchRadiusSquared = searchRadius * searchRadius; + var passable = (uint)mobileInfo.GetMovementClass(self.World.TileSet); var search = PathSearch.Search(self.World, mobileInfo, self, true, - loc => IsHarvestable(self, loc)) + loc => domainIndex.IsPassable(self.Location, loc, passable) && IsHarvestable(self, loc)) .WithCustomCost(loc => { if ((avoidCell.HasValue && loc == avoidCell.Value) ||