fix: gennemløbsfabrikker (tørreri hvede->hvede) er ikke producenter i kæden ('Loop around Wheat'); pålæsnings-rulning måler til triggerens midte som diagnosen — 1.62.301

This commit is contained in:
2026-10-17 09:17:20 +02:00
parent 2fd40f5929
commit 42a8fb8dea
5 changed files with 40 additions and 16 deletions
+13 -3
View File
@@ -7,12 +7,19 @@ ADChainModel.MAX_DEPTH = 8
local function byKey(a, b) return tostring(a.key) < tostring(b.key) end
-- Ren: gennemløb — fabrikken laver varen AF varen selv (tørreri: hvede -> hvede). Den skaber intet og må ikke tælle
-- som producent, ellers bider kæden sig selv i halen (in-game 17/10: "Animals' feed: Loop around Wheat" via AGI Westeel
-- Silo With Dryer, der "kunne kun lave 2,4k af 34,5k/md").
function ADChainModel.isPassThrough(recipe, name)
return ((recipe.inputs or {})[name] or 0) > 0
end
-- producenter pr. vare: tændte først, så stabil rækkefølge
local function indexProducers(recipes)
local index = {}
for _, recipe in ipairs(recipes or {}) do
for name, amount in pairs(recipe.outputs or {}) do
if (amount or 0) > 0 and (recipe.cyclesPerMonth or 0) > 0 then
if (amount or 0) > 0 and (recipe.cyclesPerMonth or 0) > 0 and not ADChainModel.isPassThrough(recipe, name) then
index[name] = index[name] or {}
table.insert(index[name], recipe)
end
@@ -187,7 +194,8 @@ function ADChainModel.build(recipes, husbandry, crops, fieldGoods, goodCrops, an
if (root.outputModes or {})[name] == "sell" then sells = true end
-- også når behovet allerede er dækket af en anden rod (rest 0): så kører denne slet ikke for dyrene
-- (in-game 8/10: tmr1 dækkede køerne, tmr2 blev derfor regnet som ikke-foder og kørte fuldt)
if animalLeft[name] ~= nil and (perCycle or 0) > 0 then
-- gennemløb (tørreri hvede -> hvede) fodrer ikke dyrene: varen kom ind som input (review 17/10)
if animalLeft[name] ~= nil and (perCycle or 0) > 0 and not ADChainModel.isPassThrough(root, name) then
feeds = true
feedCycles = math.max(feedCycles, animalLeft[name] / perCycle)
end
@@ -196,7 +204,9 @@ function ADChainModel.build(recipes, husbandry, crops, fieldGoods, goodCrops, an
local cycles = sells and (root.cyclesPerMonth or 0) or math.min(root.cyclesPerMonth or 0, feedCycles)
rootCycles[root.key] = cycles
for name, perCycle in pairs(root.outputs or {}) do
if animalLeft[name] ~= nil then animalLeft[name] = math.max(0, animalLeft[name] - cycles * perCycle) end
if animalLeft[name] ~= nil and not ADChainModel.isPassThrough(root, name) then
animalLeft[name] = math.max(0, animalLeft[name] - cycles * perCycle)
end
end
-- rodens råvarer er nu også foder (afledt): den der laver dem, begrænses i næste runde
for name, amount in pairs(root.inputs or {}) do