fix(kæde): slutprodukter gården selv bruger sælges aldrig straks; tidligere salg sættes tilbage (v1.61.6.0)

This commit is contained in:
2026-09-30 17:53:56 +02:00
parent e1f7b19fef
commit 0c21ba49a0
4 changed files with 31 additions and 7 deletions
+4 -2
View File
@@ -251,7 +251,8 @@ function ADChainRun.applyFinalSales(data, chain, edges)
if ProductionPoint == nil or ProductionPoint.OUTPUT_MODE == nil then return 0 end
local state, changed = ADChain.state, 0
local wanted = {}
for _, sale in ipairs(ADChainActions.finalSales(chain, data.recipes, edges, state.finalKeep)) do
local uses = ADChainActions.farmUses(data, ADChain.runsView(ADRunsController.store.runs))
for _, sale in ipairs(ADChainActions.finalSales(chain, data.recipes, edges, state.finalKeep, uses)) do
local id = sale.key .. "|" .. sale.fillType
wanted[id] = true
local entry, fillIndex = (data.points or {})[sale.key], data.fillIndex[sale.fillType]
@@ -265,7 +266,8 @@ function ADChainRun.applyFinalSales(data, chain, edges)
end
for id in pairs(state.soldByChain) do
local key, fillType = id:match("^(.*)|([^|]+)$")
if key ~= nil and state.finalKeep[key] and not wanted[id] then
-- sat til salg af kæden, men ikke længere ønsket (Behold, gården bruger varen, kæden væk): tilbage til Behold
if key ~= nil and not wanted[id] then
local entry, fillIndex = (data.points or {})[key], data.fillIndex[fillType]
if entry ~= nil and entry.point ~= nil and fillIndex ~= nil
and outputMode(entry.point, fillIndex) == ProductionPoint.OUTPUT_MODE.DIRECT_SELL then