fix(bredde): forældet CP-bredde <1,5 m ignoreres -> AI-markører; diag: triggere ved mål der afvises (v1.62.244)

This commit is contained in:
2026-10-16 03:06:48 +02:00
parent 60010ee8ba
commit c55da307a1
5 changed files with 30 additions and 6 deletions
+5 -1
View File
@@ -772,7 +772,9 @@ function ADCpBridge.getMeasuredWorkWidth(vehicle)
if object.spec_vineCutter ~= nil then hasVine = true end
end
local cpWidth = courseplayWidth(vehicle)
if cpWidth ~= nil then return ADCpBridge.widthOrVine(cpWidth, hasVine) end
-- Courseplays indstilling opdateres ikke altid lige ved påkobling: under minimum er den forældet (in-game 16/10:
-- Omega-såmaskinen 0,5 m lige efter påkobling, 6 m en anden gang) — mål selv på redskabets AI-markører
if cpWidth ~= nil and cpWidth >= ADCpBridge.MIN_USABLE_WIDTH then return ADCpBridge.widthOrVine(cpWidth, hasVine) end
local best = 0
for _, object in ipairs(collect(vehicle)) do
local variable = variableWidth(object)
@@ -784,6 +786,8 @@ function ADCpBridge.getMeasuredWorkWidth(vehicle)
if ok and type(width) == "number" and width > best then best = width end
end
end
-- heller ingen brugbar markør-bredde: Courseplays (evt. lille) værdi som før
if best < ADCpBridge.MIN_USABLE_WIDTH and cpWidth ~= nil then best = math.max(best, cpWidth) end
return ADCpBridge.widthOrVine(best, hasVine)
end
+14 -2
View File
@@ -969,11 +969,20 @@ end
-- Tager triggeren ved markøren varen? Alle bygningens triggere tæller — også fodertruget, der i CM-freestallen ligger
-- som en egen kandidat ved siden af stationen med halm/gylle/mælk (in-game 16/10: rest-TMR blev ikke sendt til den
-- tomme Kostald 2, fordi kun stationens triggere blev set). De nærmeste afgør (1.62.229: TMR ikke til halm-markøren).
function ADSmartPickup.markerTriggerAccepts(adEnv, wayPointId, fillType, farmId)
-- diag (valgfri tabel): bygning og hver trigger (afstand, tager varen, trug) til loggen (in-game 16/10: Kostald 2)
function ADSmartPickup.markerTriggerAccepts(adEnv, wayPointId, fillType, farmId, diag)
local wayPoint = wayPointId ~= nil and adEnv.ADGraphManager:getWayPointById(wayPointId) or nil
local station = wayPoint ~= nil and getUnloadStationAtMarker(adEnv, wayPoint, farmId) or nil
if station == nil then return false end
if station == nil then
if diag ~= nil then table.insert(diag, "ingen station ved markøren") end
return false
end
local owner = station.owningPlaceable
if diag ~= nil then
local ownerName = owner ~= nil and owner.getName ~= nil and owner:getName() or "?"
table.insert(diag, string.format("bygning '%s'%s", tostring(ownerName), station.unloadTriggers ~= nil and station.unloadTriggers[1] ~= nil
and station.unloadTriggers[1].isFoodProxy and " (første trigger = trug)" or ""))
end
local entries = {}
for _, candidate in ipairs(getUnloadCandidates()) do
if candidate == station or (owner ~= nil and candidate.owningPlaceable == owner) then
@@ -989,6 +998,9 @@ function ADSmartPickup.markerTriggerAccepts(adEnv, wayPointId, fillType, farmId)
accepts = triggerAcceptsFillType(trigger, fillType)
end
table.insert(entries, {distance = distance, accepts = accepts})
if diag ~= nil then
table.insert(diag, string.format("%.1f m %s%s", distance, accepts and "tager" or "nej", trigger.isFoodProxy and " (trug)" or ""))
end
end
end
end
+9 -2
View File
@@ -166,10 +166,17 @@ local function findOtherTargetForRest(adEnv, vehicle, fillType, currentId, diag)
-- triggeren ved markøren skal tage varen, ikke bare stationen (foder til en halm-markør, in-game 14/10)
local enough = free ~= nil and free > bestFree
local takes = enough and markerTakes(adEnv, vehicle, targetId, fillType)
-- diagnose: hvorfor siger triggeren nej (bygning + triggere med afstand)
local triggerWhy = ""
if diag ~= nil and enough and not takes and ADSmartPickup.markerTriggerAccepts ~= nil then
local why = {}
pcall(ADSmartPickup.markerTriggerAccepts, adEnv, targetId, fillType, ADSmartPickup.getFarmId(vehicle), why)
triggerWhy = #why > 0 and (" [" .. table.concat(why, ", ") .. "]") or ""
end
local route = takes and hasRouteTo(adEnv, vehicle, targetId)
if diag ~= nil then
table.insert(diag, string.format("%s: fri %s, trigger %s, vej %s", name, free ~= nil and string.format("%.0f l", free) or "ukendt",
enough and tostring(takes) or "-", takes and tostring(route) or "-"))
table.insert(diag, string.format("%s: fri %s, trigger %s%s, vej %s", name, free ~= nil and string.format("%.0f l", free) or "ukendt",
enough and tostring(takes) or "-", triggerWhy, takes and tostring(route) or "-"))
end
if route then
best, bestFree = {id = targetId, name = name}, free
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.62.243.0</version>
<version>1.62.244.0</version>
<title>
<en>AD Smart Pickup</en>
</title>