feat: én traktor, flere vogne i samme flow — skifter vogn mellem ture; kæden laver kombinerede flows (1.62.337)
Brugerønske 18/10 18:36: færre traktorer. spareWagons pr. traktor, ADWagonSwap vurderer vognene før hver tur og bruger flowets vognbytte.
This commit is contained in:
@@ -501,6 +501,7 @@ end
|
||||
-- Behov pr. vare lige nu (til retfærdig fordeling): køretøj -> {free, at}
|
||||
local demandRegistry = {}
|
||||
ADSmartPickup.DEMAND_FRESH_MS = 10 * 60 * 1000
|
||||
local probing = false -- ADSmartPickup.probeSupplyPickup: kun spørge, intet registreres
|
||||
local function registerDemand(fillType, driver, freeSpace)
|
||||
local now = g_currentMission ~= nil and g_currentMission.time or 0
|
||||
demandRegistry[fillType] = demandRegistry[fillType] or {}
|
||||
@@ -1215,6 +1216,16 @@ function ADSmartPickup.buyFeed(adEnv, driver, ranked, bestFood, targetWayPoint,
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Hvad kunne vognen hente? Som findSupplyPickup, men uden at registrere et behov (til parkerede vogne:
|
||||
-- ADWagonSwap og dvale-tjekket). -> valg eller nil
|
||||
function ADSmartPickup.probeSupplyPickup(adEnv, cargo, ingredients, targetWayPointId)
|
||||
probing = true
|
||||
local ok, choice = pcall(ADSmartPickup.findSupplyPickup, adEnv, cargo, ingredients, targetWayPointId)
|
||||
probing = false
|
||||
if not ok then error(choice, 0) end
|
||||
return choice
|
||||
end
|
||||
|
||||
function ADSmartPickup.findSupplyPickup(adEnv, driver, ingredients, targetWayPointId)
|
||||
-- med eksplicit mål bruges AD's tilstand ikke (dvale-tjekket kalder med flowets parkerede vogn, der ingen .ad har)
|
||||
local wayPointId = targetWayPointId
|
||||
@@ -1298,7 +1309,10 @@ function ADSmartPickup.findSupplyPickup(adEnv, driver, ingredients, targetWayPoi
|
||||
-- 20 mio. l-silo som ét kæmpe behov, og alle andre får smuler (in-game 10/10: 3.110 l af 334.730 l)
|
||||
local tripNeed = math.min(need.freeSpace or math.huge, loadCapacity or math.huge)
|
||||
if tripNeed == math.huge then tripNeed = need.freeSpace or 0 end
|
||||
local totalFree, others = registerDemand(need.fillType, driver, tripNeed)
|
||||
-- en prøve (parkeret vogn: ADWagonSwap/dvalen) registrerer intet behov — ellers deler de andre traktorer
|
||||
-- lageret med en vogn, der ikke kører (review 18/10)
|
||||
local totalFree, others = tripNeed, 0
|
||||
if not probing then totalFree, others = registerDemand(need.fillType, driver, tripNeed) end
|
||||
if choice.isOwn and others > 0 then
|
||||
local share = ADSupplyPlanner.fairShare(choice.level or 0, tripNeed, totalFree)
|
||||
if share < pending then
|
||||
@@ -1447,6 +1461,16 @@ function ADSmartPickup.choosePickup(adEnv, driver)
|
||||
if choice == nil then
|
||||
choice = tryOtherRunTargets(adEnv, driver, ingredients)
|
||||
end
|
||||
-- én traktor, flere vogne: skal en anden af traktorens vogne køre turen? Skiftet udføres i ADWagonSwap.tick
|
||||
if ADWagonSwap ~= nil and ADWagonSwap.consider ~= nil then
|
||||
local okSwap, swapped = pcall(ADWagonSwap.consider, adEnv, driver, activeRunOf(driver), choice)
|
||||
if not okSwap then
|
||||
Logging.warning(ADSmartPickup.LOG_PREFIX .. "vogneskift-tjek fejlede: %s", tostring(swapped))
|
||||
elseif swapped then
|
||||
supplyState[driver] = nil
|
||||
return nil
|
||||
end
|
||||
end
|
||||
if choice == nil then
|
||||
-- Traktor i et forsynings-run uden noget (tilladt) at hente: hold ved Wait og prøv igen, i stedet
|
||||
-- for at falde tilbage til mappe-logikken (den henter hvad som helst, fx ensilage i et halvfuldt trug).
|
||||
@@ -1891,6 +1915,10 @@ function ADSmartPickup:update(dt)
|
||||
local okFlow, errFlow = pcall(ADFlowWagons.tick, getAutoDriveEnv(), gameDt)
|
||||
if not okFlow then Logging.warning(ADSmartPickup.LOG_PREFIX .. "flow-vogne fejlede: %s", tostring(errFlow)) end
|
||||
end
|
||||
if ADWagonSwap ~= nil and getAutoDriveEnv() ~= nil then
|
||||
local okSwap, errSwap = pcall(ADWagonSwap.tick, getAutoDriveEnv(), gameDt)
|
||||
if not okSwap then Logging.warning(ADSmartPickup.LOG_PREFIX .. "vogneskift fejlede: %s", tostring(errSwap)) end
|
||||
end
|
||||
if ADBuildings ~= nil and ADBuildings.tickDump ~= nil then pcall(ADBuildings.tickDump, getAutoDriveEnv(), dt) end
|
||||
if ADMarkerGuard ~= nil and getAutoDriveEnv() ~= nil then
|
||||
local okGuard, errGuard = pcall(ADMarkerGuard.tick, ADMarkerGuard.gameEnv(getAutoDriveEnv()))
|
||||
|
||||
Reference in New Issue
Block a user