fix: udkørsel trækker andres igangværende læs fra kildens lager (v1.62.119)

This commit is contained in:
2026-10-09 01:23:13 +02:00
parent 0c195c8490
commit bb02bb2031
3 changed files with 28 additions and 2 deletions
+26 -1
View File
@@ -37,6 +37,27 @@ ADOutbound.UNSTRAP_BEFORE_M = 25
-- køretøj -> {run, trip, sources, queue, visited, current, lastFill, noProgressMs, spawn, done}
local trips = setmetatable({}, {__mode = "k"})
local function listHas(list, value)
for _, item in ipairs(list or {}) do if item == value then return true end end
return false
end
-- Liter af varen ved kilden, som ANDRE køretøjer er på vej efter (endnu ikke besøgt på deres tur).
ADOutbound.CLAIMS_ENABLED = true
local function claimedLiters(vehicle, wayPointId, fillType)
local total = 0
if not ADOutbound.CLAIMS_ENABLED then return total end
for other, t in pairs(trips) do
local state = other.ad ~= nil and other.ad.stateModule or nil
local active = state == nil or state.isActive == nil or state:isActive() == true
if other ~= vehicle and active and t.trip ~= nil and not (t.visited or {})[wayPointId] and listHas(t.queue, wayPointId)
and listHas(t.trip.fillTypes, fillType) then
total = total + (t.claimLiters or 0)
end
end
return total
end
-- køretøj -> {markerId, markerName, reasons, timerMs, lastLogged}
local holds = setmetatable({}, {__mode = "k"})
-- run-id -> {reasons, warning}
@@ -303,6 +324,9 @@ function ADOutbound.buildPlanInput(adEnv, run, vehicle)
if usePallets and not item.isPallet then
available = item.palletLiters or 0
end
-- andre køretøjer der allerede er på vej efter varen ved samme kilde: deres læs er taget (in-game 9/10:
-- begge mælkebiler planlagde samme sekund på de samme 30.000 l; den anden stod ved triggeren uden mælk)
if not usePallets then available = math.max(0, available - claimedLiters(vehicle, source.wayPointId, item.fillType)) end
local emptyKey = tostring(source.wayPointId) .. ":" .. tostring(item.fillType)
local isMarkedEmpty = emptyUntil[emptyKey] ~= nil and emptyUntil[emptyKey] > time
if policy ~= "off" and canCarry and not isMarkedEmpty then
@@ -444,7 +468,8 @@ local function applyTrip(adEnv, vehicle, run, trip, sourcesById)
if stateModule.raiseDirtyFlag ~= nil then
stateModule:raiseDirtyFlag()
end
trips[vehicle] = {run = run, trip = trip, sources = sourcesById, queue = copyList(trip.sourceIds), visited = {}, current = trip.sourceIds[1], noProgressMs = 0}
trips[vehicle] = {run = run, trip = trip, sources = sourcesById, queue = copyList(trip.sourceIds), visited = {}, current = trip.sourceIds[1], noProgressMs = 0,
claimLiters = getVehicleCapacity(adEnv, vehicle)}
local names = {}
for _, fillType in ipairs(trip.fillTypes) do table.insert(names, fillTypeName(fillType)) end
local sourceNames = {}