fix: ødelagte køretøjer springes over og stoppes (kan ikke nulstilles midt i et job)

This commit is contained in:
2026-10-20 16:10:18 +02:00
parent 7384f23b47
commit 8cadbfffaf
12 changed files with 178 additions and 8 deletions
+14 -2
View File
@@ -433,12 +433,19 @@ local function release(adEnv, vehicle, reason)
local why = reason == "stuck" and "kom ikke i gang på 2 min — stoppet" or "AutoDrive stoppede turen med det samme (rute/læssested?)"
Logging.warning(ADFieldSilos.LOG_PREFIX .. "'%s' ved %s (%s): %s; siloen springes over i 10 min",
tostring(ADRuns.vehicleLabel(vehicle)), tostring(loan.siloName), fillTypeName(loan.fillType), why)
elseif reason == "stopped" then
elseif reason == "stopped" or reason == "broken" then
pcall(vehicle.stopAutoDrive, vehicle)
end
if reason == "broken" then
if ADCpBridge ~= nil then pcall(ADCpBridge.stop, vehicle) end
if ADFieldJobs ~= nil and ADFieldJobs.notify ~= nil then
ADFieldJobs.notify(ADPool.brokenText(vehicle), true)
end
end
logInfo(ADFieldSilos.LOG_PREFIX .. "'%s' frigivet (%s)", tostring(ADRuns.vehicleLabel(vehicle)), tostring(reason))
-- puljevogn bag traktoren: sæt den af på sin plads og kør hjem (ikke når spilleren har overtaget)
if reason ~= "player" and ADHitch ~= nil then
-- ødelagt: ikke hjem, den kan ikke køre (in-game 20/10)
if reason ~= "player" and reason ~= "broken" and ADHitch ~= nil then
local okHome, pooled = pcall(ADHitch.returnHome, adEnv, vehicle)
if not (okHome and pooled) and loan.fetching then
local park = ADFieldWork.parkMarkerId(adEnv, vehicle)
@@ -568,6 +575,11 @@ local function checkLoans(adEnv)
else
local ok, err = pcall(function()
local loan = loans[vehicle]
-- ødelagt undervejs (fx kørt i vandet, in-game 20/10): stop og slip lånet
if ADPool ~= nil and ADPool.isBroken ~= nil and ADPool.isBroken(vehicle) then
release(adEnv, vehicle, "broken")
return
end
-- henter puljevognen: AD holder stille under koblingen — ikke "færdig"; men spilleren kan overtage,
-- og en hentning der ikke bliver færdig (trafik, rute), opgives
if loan.fetching then