feat: justerbar tid mellem udsendelser i markflåden, standard 15 s (v1.62.41)

This commit is contained in:
2026-10-06 15:06:59 +02:00
parent 71b8d8beef
commit 6f50e3d2a1
9 changed files with 43 additions and 5 deletions
+25 -3
View File
@@ -102,9 +102,30 @@ 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).
ADFieldJobs.DISPATCH_GAP_MS = 10000
function ADFieldJobs.mayDispatch(now, lastAt)
return lastAt == nil or now - lastAt >= ADFieldJobs.DISPATCH_GAP_MS
-- 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()
@@ -286,6 +307,7 @@ function ADFieldJobs.load()
ADFieldJobs.state.courseRecords = loaded.courseRecords or {}
ADFieldJobs.state.manual = loaded.manual or {}
ADFieldJobs.state.paused = loaded.paused == true
ADFieldJobs.state.dispatchGapS = ADFieldJobs.normalizeDispatchGap(loaded.dispatchGapS)
else
Logging.warning(ADFieldJobs.LOG_PREFIX .. "marker kunne ikke indlæses: %s", tostring(loaded))
end