fix: fuldt mål springer det fulde mål over ved tømning (1.62.371)

This commit is contained in:
2026-10-19 11:49:46 +02:00
parent d9ac0216ed
commit 686e52ed96
4 changed files with 15 additions and 9 deletions
+6 -6
View File
@@ -82,17 +82,17 @@ local function stuckAtFullTarget(adEnv, vehicle)
-- plansilo, station uden lager — er aldrig "fuldt"; review 19/10)
local free, capacity = ADSmartPickup.getTargetFreeCapacity(adEnv, vehicle, fillType, false, target.id)
if not ADStrayUnload.isFull(free, capacity) then return false end
return true, tostring(target.name), rest, fillType
return true, tostring(target.name), rest, fillType, target.id
end
local function act(adEnv, vehicle, targetName, rest, fillType, minutes)
local function act(adEnv, vehicle, targetName, rest, fillType, minutes, targetId)
pcall(function() vehicle:stopAutoDrive() end)
local fillName = g_fillTypeManager ~= nil and tostring(g_fillTypeManager:getFillTypeNameByIndex(fillType)) or tostring(fillType)
local text = string.format("'%s' holdt %d min ved fuldt mål '%s' med %.0f l %s — tømmes på et lager med plads (ellers sælges varen; kan intet tage den, køres den hjem med læsset)",
label(vehicle), minutes, targetName, rest, fillName)
Logging.info(ADStrayUnload.LOG_PREFIX .. "%s", text)
if ADFieldJobs ~= nil and ADFieldJobs.notify ~= nil then pcall(ADFieldJobs.notify, text, false) end
ADFlowWagons.homeVehicle(adEnv, vehicle, nil, "strayFull")
ADFlowWagons.homeVehicle(adEnv, vehicle, nil, "strayFull", targetId)
end
function ADStrayUnload.tick(adEnv, dt)
@@ -105,8 +105,8 @@ function ADStrayUnload.tick(adEnv, dt)
local farmId = g_currentMission ~= nil and g_currentMission.getFarmId ~= nil and g_currentMission:getFarmId() or nil
for _, vehicle in pairs(g_currentMission.vehicleSystem.vehicles or {}) do
local mine = farmId == nil or (vehicle.getOwnerFarmId ~= nil and vehicle:getOwnerFarmId() == farmId)
local ok, stuck, targetName, rest, fillType = false, false, nil, nil, nil
if mine and vehicle.ad ~= nil then ok, stuck, targetName, rest, fillType = pcall(stuckAtFullTarget, adEnv, vehicle) end
local ok, stuck, targetName, rest, fillType, targetId = false, false, nil, nil, nil, nil
if mine and vehicle.ad ~= nil then ok, stuck, targetName, rest, fillType, targetId = pcall(stuckAtFullTarget, adEnv, vehicle) end
stuck = ok and stuck == true
-- et kort hul (AD's tippe-flag blinker mellem tip) nulstiller ikke tiden — først efter GRACE_MS (review 19/10)
gap[vehicle] = (not stuck and held[vehicle] ~= nil) and (gap[vehicle] or 0) + elapsed or nil
@@ -121,7 +121,7 @@ function ADStrayUnload.tick(adEnv, dt)
local action = stuck and ADStrayUnload.step({stuck = true, heldMs = held[vehicle], limitMs = (tonumber(minutes) or 0) * 60000}) or "wait"
if action == "act" then
held[vehicle], restMark[vehicle], gap[vehicle] = nil, nil, nil
local okAct, err = pcall(act, adEnv, vehicle, targetName, rest, fillType, minutes)
local okAct, err = pcall(act, adEnv, vehicle, targetName, rest, fillType, minutes, targetId)
if not okAct then Logging.warning(ADStrayUnload.LOG_PREFIX .. "'%s': %s", label(vehicle), tostring(err)) end
end
end