fix: opvågning bruger egen traktor med flowets vogn; byt aldrig mens vognen sidder på (v1.62.69)
This commit is contained in:
@@ -110,6 +110,12 @@ function ADFlowSleep.isOwnTrip(wagonStatus)
|
||||
return wagonStatus == "homing" or wagonStatus == "emptying"
|
||||
end
|
||||
|
||||
-- Må flowets egen traktor køre turen? s = {exists, lentOut, onOwnTrip, carriesOwnWagon}. Kun lånt ud (markopgave,
|
||||
-- Courseplay, marksilo, et andet flow) er optaget; flowets egen vogn på eller egen hjemtur er netop rigtigt.
|
||||
function ADFlowSleep.ownUsable(s)
|
||||
return s.exists == true and not s.lentOut
|
||||
end
|
||||
|
||||
-- ---- spil-adapter ----
|
||||
|
||||
local idleSince = {} -- runId -> ms
|
||||
@@ -199,13 +205,17 @@ local function positionOf(vehicle)
|
||||
return x, z
|
||||
end
|
||||
|
||||
local function isOwnFree(vehicle, tractorId)
|
||||
local function isOwnFree(vehicle, tractorId, run)
|
||||
if vehicle == nil then return false end
|
||||
-- egen hjemtur efter dvalen: startVehicle afbryder den (ADFlowWagons.abortHomeTripOnStart)
|
||||
if ADFlowWagons ~= nil and ADFlowWagons.statusOf ~= nil and ADFlowSleep.isOwnTrip(ADFlowWagons.statusOf(vehicle)) then return true end
|
||||
if ADPool ~= nil and ADPool.isFreeFromFlows ~= nil and not ADPool.isFreeFromFlows(vehicle) then return false end
|
||||
if ADFieldWork ~= nil and ADFieldWork.isBusyVehicle ~= nil and ADFieldWork.isBusyVehicle(vehicle, tractorId) then return false end
|
||||
return not (ADFlowWagons ~= nil and ADFlowWagons.isPoolBusy ~= nil and ADFlowWagons.isPoolBusy(vehicle, tractorId))
|
||||
local status = ADFlowWagons ~= nil and ADFlowWagons.statusOf ~= nil and ADFlowWagons.statusOf(vehicle) or nil
|
||||
local onOwnTrip = ADFlowSleep.isOwnTrip(status)
|
||||
local otherRun = ADRunsController.getRunForVehicle(vehicle)
|
||||
local lentOut = (otherRun ~= nil and otherRun ~= run)
|
||||
or (ADFieldJobs ~= nil and ADFieldJobs.state ~= nil and ADFieldJobs.state.assignments ~= nil and ADFieldJobs.state.assignments[tractorId] ~= nil)
|
||||
or (ADCpBridge ~= nil and ADCpBridge.isWorking ~= nil and ADCpBridge.isWorking(vehicle) == true)
|
||||
or (ADFieldSilos ~= nil and ADFieldSilos.isLoaned ~= nil and ADFieldSilos.isLoaned(vehicle) == true)
|
||||
or (not onOwnTrip and ADPool ~= nil and ADPool.isReturning ~= nil and ADPool.isReturning(vehicle) == true)
|
||||
return ADFlowSleep.ownUsable({exists = true, lentOut = lentOut, onOwnTrip = onOwnTrip})
|
||||
end
|
||||
|
||||
-- Ledige puljetraktorer der ikke hører til noget flow (heller ikke et sovende/stoppet) og ikke er reserveret.
|
||||
@@ -227,8 +237,14 @@ local function wake(adEnv, run, byId, why)
|
||||
local taken = {}
|
||||
for _, tractorId in ipairs(run.vehicleIds or {}) do
|
||||
local own = byId[tractorId]
|
||||
if not isOwnFree(own, tractorId) then
|
||||
local wagon = findVehicle((run.wagons or {})[tractorId])
|
||||
local wagonId = (run.wagons or {})[tractorId]
|
||||
local wagonOnOwn = false
|
||||
for _, implement in ipairs(own ~= nil and ADHitch.rearImplementsOf(own) or {}) do
|
||||
if wagonId ~= nil and ADRunsController.getVehicleId(implement.object) == wagonId then wagonOnOwn = true end
|
||||
end
|
||||
-- vognen sidder på den egne traktor: aldrig byt (en anden traktor ville vente på vognen for evigt)
|
||||
if not wagonOnOwn and not isOwnFree(own, tractorId, run) then
|
||||
local wagon = findVehicle(wagonId)
|
||||
local x, z = positionOf(wagon or own)
|
||||
local okHp, neededHp = pcall(ADPool.readNeededHp, wagon)
|
||||
local okFree, candidates = pcall(freeTractors, adEnv, taken)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.68.0</version>
|
||||
<version>1.62.69.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user