diff --git a/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs b/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs index a66f71d8fd..6d83ec0765 100644 --- a/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs +++ b/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs @@ -177,13 +177,8 @@ namespace OpenRA.Mods.Common.Activities // Determine where to search from and how far to search: var procLoc = GetSearchFromProcLocation(self); - var searchFromLoc = lastHarvestedCell ?? procLoc; + var searchFromLoc = lastHarvestedCell ?? procLoc ?? self.Location; var searchRadius = lastHarvestedCell.HasValue ? harvInfo.SearchFromHarvesterRadius : harvInfo.SearchFromProcRadius; - if (!searchFromLoc.HasValue) - { - searchFromLoc = self.Location; - searchRadius = harvInfo.SearchFromHarvesterRadius; - } var searchRadiusSquared = searchRadius * searchRadius; @@ -196,7 +191,7 @@ namespace OpenRA.Mods.Common.Activities domainIndex.IsPassable(self.Location, loc, mobile.Locomotor) && harv.CanHarvestCell(self, loc) && claimLayer.CanClaimCell(self, loc)) .WithCustomCost(loc => { - if ((loc - searchFromLoc.Value).LengthSquared > searchRadiusSquared) + if ((loc - searchFromLoc).LengthSquared > searchRadiusSquared) return int.MaxValue; // Add a cost modifier to harvestable cells to prefer resources that are closer to the refinery. @@ -221,7 +216,7 @@ namespace OpenRA.Mods.Common.Activities return 0; }) - .FromPoint(searchFromLoc.Value) + .FromPoint(searchFromLoc) .FromPoint(self.Location)) path = pathFinder.FindPath(search); diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index b5922800df..44b1bc7576 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -148,8 +148,6 @@ namespace OpenRA.Mods.Common.Traits resourceMultipliers = self.TraitsImplementing().ToArray(); UpdateCondition(self); - self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null))); - // Note: This is queued in a FrameEndTask because otherwise the activity is dropped/overridden while moving out of a factory. if (Info.SearchOnCreation) self.World.AddFrameEndTask(w => self.QueueActivity(new FindAndDeliverResources(self)));