fix: paller til palleskur køres til unload-markøren frem for load (v1.62.57)
This commit is contained in:
@@ -760,7 +760,22 @@ function ADSources.findPalletStore(adEnv, vehicle, fillType, excludedPlaceables,
|
||||
table.insert(candidates, {marker = marker, source = source, distance = distance2(x, z, wayPoint.x, wayPoint.z)})
|
||||
end
|
||||
end
|
||||
table.sort(candidates, function(a, b) return a.distance < b.distance end)
|
||||
-- nærmeste skur først; ved samme skur går en "unload"-markør forud for "load" (in-game 7/10: Pallebil 1 kørte æg
|
||||
-- til "Palleskur 1 load", der lå nærmest)
|
||||
local nearestOf = {}
|
||||
for _, candidate in ipairs(candidates) do
|
||||
local placeable = candidate.source.placeable
|
||||
nearestOf[placeable] = math.min(nearestOf[placeable] or math.huge, candidate.distance)
|
||||
end
|
||||
local function isUnload(candidate)
|
||||
return ADBuildings ~= nil and ADBuildings.nameRole ~= nil and ADBuildings.nameRole(candidate.marker.name) == "unload"
|
||||
end
|
||||
table.sort(candidates, function(a, b)
|
||||
local da, db = nearestOf[a.source.placeable], nearestOf[b.source.placeable]
|
||||
if da ~= db then return da < db end
|
||||
if isUnload(a) ~= isUnload(b) then return isUnload(a) end
|
||||
return a.distance < b.distance
|
||||
end)
|
||||
for _, candidate in ipairs(candidates) do
|
||||
if isReachable == nil or isReachable(candidate.marker.id) then
|
||||
return {wayPointId = candidate.marker.id, name = tostring(candidate.marker.name), free = ADSources.objectStorageFreeSlots(candidate.source.placeable)}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.56.0</version>
|
||||
<version>1.62.57.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user