fix(flows): gamle rå markører ryddes når de ikke er kilde eller dublerer en valgt bygning (v1.13.5.0)
This commit is contained in:
@@ -314,12 +314,32 @@ function ADRunsController.resolveMarkers(adEnv, run)
|
||||
table.insert(missing, building ~= nil and building.name or (tostring(buildingId) .. " (mangler)"))
|
||||
end
|
||||
end
|
||||
-- Rå markører (fra før flow-tavlen): beholdes kun hvis de er en genkendelig kilde og ikke hører til
|
||||
-- en bygning der allerede er valgt (så ville de dublere bygningens egne markører).
|
||||
local chosenPlaceables = {}
|
||||
for _, buildingId in ipairs(buildingIds or {}) do
|
||||
local building = ADBuildings.find(adEnv, farmId, buildingId)
|
||||
if building ~= nil and building.placeable ~= nil then chosenPlaceables[building.placeable] = true end
|
||||
end
|
||||
local pruned = {}
|
||||
for _, wayPointId in ipairs(existing or {}) do
|
||||
if not seen[wayPointId] and ADBuildings.byMarker(adEnv, farmId, wayPointId, role) == nil then
|
||||
local keep = true
|
||||
if role == "load" and ADSources ~= nil and ADSources.identify ~= nil then
|
||||
local source = ADSources.identify(adEnv, wayPointId, farmId)
|
||||
keep = source ~= nil and not (source.placeable ~= nil and chosenPlaceables[source.placeable])
|
||||
end
|
||||
seen[wayPointId] = true
|
||||
table.insert(resolved, wayPointId)
|
||||
if keep then
|
||||
table.insert(resolved, wayPointId)
|
||||
else
|
||||
table.insert(pruned, tostring(wayPointId))
|
||||
end
|
||||
end
|
||||
end
|
||||
if #pruned > 0 then
|
||||
Logging.info(ADRunsController.LOG_PREFIX .. "run '%s': gamle markører fjernet (ingen kilde eller dublet af valgt bygning): %s", tostring(run.name), table.concat(pruned, " "))
|
||||
end
|
||||
if not listEquals(resolved, existing or {}) then
|
||||
local changes = run.kind == "outbound" and {sourceWayPointIds = resolved} or {targetWayPointIds = resolved}
|
||||
ADRunsController.store = ADRuns.updateRun(ADRunsController.store, run.id, changes)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.13.4.0</version>
|
||||
<version>1.13.5.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user