From de8317d9b816116e2504e7bb8de696daf52298b7 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Wed, 5 Mar 2025 17:29:53 +0000 Subject: [PATCH] Harvesters prefer ore near to the refinery. When searching for ore, harvesters will prefer ore close to their refinery, the dockPos. However this only works when this is set, and is was not being set when expected. Fixing this prevents harvesters moving in straight lines, particularly when the ore is to the left of the refinery, which is the default path search direction. Fixes a regression from d0974cfdd2702db9b52125467b8a5ca4ebffd588. --- OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs b/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs index 0ed51925f7..6bb9652f21 100644 --- a/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs +++ b/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs @@ -173,7 +173,8 @@ namespace OpenRA.Mods.Common.Activities // Prioritise search by these locations in this order: lastHarvestedCell -> lastLinkedDock -> self. CPos searchFromLoc; int searchRadius; - WPos? dockPos = null; + var dockPos = harv.DockClientManager?.LastReservedHost?.DockPosition; + if (lastHarvestedCell.HasValue) { searchRadius = harvInfo.SearchFromHarvesterRadius; @@ -182,12 +183,8 @@ namespace OpenRA.Mods.Common.Activities else { searchRadius = harvInfo.SearchFromProcRadius; - var dock = harv.DockClientManager?.LastReservedHost; - if (dock != null) - { - dockPos = dock.DockPosition; + if (dockPos != null) searchFromLoc = self.World.Map.CellContaining(dockPos.Value); - } else searchFromLoc = self.Location; }