fix(udsendelse): fælles udsendelsesport for Start alle, markarbejde, marksiloer og flow-genstart; én indstilling under Indstillinger (v1.62.237)

This commit is contained in:
2026-10-16 02:01:12 +02:00
parent 7f063cbb06
commit fbc0b448f5
13 changed files with 97 additions and 69 deletions
+3 -31
View File
@@ -300,34 +300,6 @@ function ADFieldJobs.stalledAtTarget(s)
return (s.stillMs or 0) >= ADFieldJobs.STALL_ARRIVE_MS
end
-- Højst én maskine sendt ud pr. DISPATCH_GAP_MS på tværs af alle marker (in-game 27/9: 6 maskiner kørte fra
-- parkeringen i samme sekund efter Start alle).
-- Justerbart pr. savegame (brugerønske 6/10): få maskiner kan nøjes med 1–5 s, mange har brug for 30 s eller mere.
ADFieldJobs.DISPATCH_GAP_CHOICES = {1, 5, 10, 15, 20, 30, 45, 60} -- sekunder
ADFieldJobs.DISPATCH_GAP_DEFAULT_S = 15
ADFieldJobs.DISPATCH_GAP_MS = ADFieldJobs.DISPATCH_GAP_DEFAULT_S * 1000
-- Gyldigt valg (sekunder) eller standarden.
function ADFieldJobs.normalizeDispatchGap(seconds)
for _, s in ipairs(ADFieldJobs.DISPATCH_GAP_CHOICES) do
if s == seconds then return s end
end
return ADFieldJobs.DISPATCH_GAP_DEFAULT_S
end
function ADFieldJobs.dispatchGapMs()
return ADFieldJobs.normalizeDispatchGap(ADFieldJobs.state ~= nil and ADFieldJobs.state.dispatchGapS or nil) * 1000
end
function ADFieldJobs.mayDispatch(now, lastAt, gapMs)
return lastAt == nil or now - lastAt >= (gapMs or ADFieldJobs.dispatchGapMs())
end
function ADFieldJobs.setDispatchGap(seconds)
ADFieldJobs.state.dispatchGapS = ADFieldJobs.normalizeDispatchGap(seconds)
ADFieldJobs.save()
end
function ADFieldJobs.assignmentCount()
local count = 0
for _ in pairs(ADFieldJobs.state.assignments) do count = count + 1 end
@@ -560,7 +532,6 @@ function ADFieldJobs.load()
ADFieldJobs.state.playerTrips = loaded.playerTrips or {}
ADFieldJobs.state.paused = loaded.paused == true
ADFieldJobs.state.resumed = loaded.resumed or {}
ADFieldJobs.state.dispatchGapS = ADFieldJobs.normalizeDispatchGap(loaded.dispatchGapS)
else
Logging.warning(ADFieldJobs.LOG_PREFIX .. "marker kunne ikke indlæses: %s", tostring(loaded))
end
@@ -796,11 +767,12 @@ local function stepField(adEnv, info, env)
end
elseif decision.action == "dispatch" then
-- én udsendelse ad gangen på tværs af markerne: marken prøver igen ved næste tick
if not ADFieldJobs.mayDispatch(ADFieldJobs.now, ADFieldJobs.lastDispatchAt) then return end
-- fælles port: også "Start alle", marksiloer og flows tæller med (in-game 16/10)
if ADLaunchGate ~= nil and not ADLaunchGate.isOpen() then return end
local before = ADFieldJobs.assignmentCount()
ADFieldWork.dispatch(adEnv, field, info, decision)
if ADFieldJobs.assignmentCount() > before then
ADFieldJobs.lastDispatchAt = ADFieldJobs.now
if ADLaunchGate ~= nil then ADLaunchGate.markLaunched() end
ADFieldJobs.waitingSince[info.id] = nil
elseif ADFieldJobs.waitingSince[info.id] == nil then
ADFieldJobs.waitingSince[info.id] = ADFieldJobs.now