fix: aflæs-markør vinder over læs ved samme silo; lastbiler er ingen puljetraktorer (v1.62.20)

This commit is contained in:
2026-10-04 21:28:55 +02:00
parent a64a307ef8
commit 9ff92c0e34
4 changed files with 31 additions and 4 deletions
+19 -2
View File
@@ -110,6 +110,23 @@ function ADLoadSwap.isLiquid(fillType)
return ADLoadSwap.isLiquidName(name)
end
-- Silo med både en læs- og en aflæs-markør: aflæs-markøren ("aflæs"/"unload"/"drop") vinder, læs-markøren for
-- samme station fjernes (in-game 4/10: tømmevognen blev sendt til "Kornsilo 2 læs" — forkert spor forbi graven)
function ADLoadSwap.preferUnloadNamed(candidates)
if ADBuildings == nil or ADBuildings.nameRole == nil then return candidates end
local hasUnload = {}
for _, c in ipairs(candidates) do
if c.station ~= nil and ADBuildings.nameRole(c.marker.name) == "unload" then hasUnload[c.station] = true end
end
local result = {}
for _, c in ipairs(candidates) do
if not (c.station ~= nil and hasUnload[c.station] and ADBuildings.nameRole(c.marker.name) == "load") then
table.insert(result, c)
end
end
return result
end
function ADLoadSwap.findDumpMarker(adEnv, vehicle, fillType, rest, homeWayPointId, isReachable, excludedPlaceables, avoidMarkers, allowFactories)
if vehicle.rootNode == nil then
return nil, "køretøjet har ingen position"
@@ -130,7 +147,7 @@ function ADLoadSwap.findDumpMarker(adEnv, vehicle, fillType, rest, homeWayPointI
if wayPoint ~= nil then
local dx, dz = wayPoint.x - x, wayPoint.z - z
table.insert(candidates, {
marker = marker,
marker = marker, station = station.owningPlaceable or station,
hasFillType = ADSmartPickup.getOwnStorageLevel(station, {fillType}) > 0,
distance = dx * dx + dz * dz,
})
@@ -138,7 +155,7 @@ function ADLoadSwap.findDumpMarker(adEnv, vehicle, fillType, rest, homeWayPointI
end
end
end
candidates = ADLoadSwap.rankDumpCandidates(candidates, avoidMarkers)
candidates = ADLoadSwap.rankDumpCandidates(ADLoadSwap.preferUnloadNamed(candidates), avoidMarkers)
for _, candidate in ipairs(candidates) do
if isReachable(candidate.marker.id) then
return candidate.marker