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:
2026-09-24 00:41:19 +02:00
parent 25332184a8
commit c60510ae0e
3 changed files with 37 additions and 2 deletions
+21 -1
View File
@@ -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)