From 773d9e3e9ef829c2fac95e0af3740fe504880403 Mon Sep 17 00:00:00 2001 From: silverflyone Date: Sun, 19 Nov 2023 12:34:53 +1100 Subject: [PATCH 1/9] realistic limits for combine --- combine.lua | 97 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 38 deletions(-) diff --git a/combine.lua b/combine.lua index fa9b299ea6..98318744b6 100644 --- a/combine.lua +++ b/combine.lua @@ -10,12 +10,11 @@ local opts, args = { dry_run = false, types = nil, quiet = false, + unlimited_stack = false, verbose = 0, }, {...} -- default max stack size of 30 -local MAX_ITEM_STACK=30 -local MAX_AMMO_STACK=25 local MAX_CONT_ITEMS=30 local MAX_MAT_AMT=30 @@ -25,24 +24,23 @@ local typesThatUseMaterial=utils.invert{'CORPSEPIECE'} -- list of valid item types for merging -- Notes: 1. mergeable stacks are ones with the same type_id+race+caste or type_id+mat_type+mat_index --- 2. the maximum stack size is calcuated at run time: the highest value of MAX_ITEM_STACK or largest current stack size. --- 3. even though powders are specified, sand and plaster types items are excluded from merging. --- 4. seeds cannot be combined in stacks > 1. +-- 2. even though powders are specified, sand and plaster types items are excluded from merging. +-- 3. seeds cannot be combined in stacks > 1. local valid_types_map = { ['all'] = { }, - ['ammo'] = {[df.item_type.AMMO] ={type_id=df.item_type.AMMO, max_size=MAX_AMMO_STACK}}, + ['ammo'] = {[df.item_type.AMMO] ={type_id=df.item_type.AMMO, max_size=25}}, ['parts'] = {[df.item_type.CORPSEPIECE] ={type_id=df.item_type.CORPSEPIECE, max_size=1}}, - ['drink'] = {[df.item_type.DRINK] ={type_id=df.item_type.DRINK, max_size=MAX_ITEM_STACK}}, - ['fat'] = {[df.item_type.GLOB] ={type_id=df.item_type.GLOB, max_size=MAX_ITEM_STACK}, - [df.item_type.CHEESE] ={type_id=df.item_type.CHEESE, max_size=MAX_ITEM_STACK}}, - ['fish'] = {[df.item_type.FISH] ={type_id=df.item_type.FISH, max_size=MAX_ITEM_STACK}, - [df.item_type.FISH_RAW] ={type_id=df.item_type.FISH_RAW, max_size=MAX_ITEM_STACK}, - [df.item_type.EGG] ={type_id=df.item_type.EGG, max_size=MAX_ITEM_STACK}}, - ['food'] = {[df.item_type.FOOD] ={type_id=df.item_type.FOOD, max_size=MAX_ITEM_STACK}}, - ['meat'] = {[df.item_type.MEAT] ={type_id=df.item_type.MEAT, max_size=MAX_ITEM_STACK}}, - ['plant'] = {[df.item_type.PLANT] ={type_id=df.item_type.PLANT, max_size=MAX_ITEM_STACK}, - [df.item_type.PLANT_GROWTH]={type_id=df.item_type.PLANT_GROWTH, max_size=MAX_ITEM_STACK}}, - ['powder'] = {[df.item_type.POWDER_MISC] ={type_id=df.item_type.POWDER_MISC, max_size=MAX_ITEM_STACK}}, + ['drink'] = {[df.item_type.DRINK] ={type_id=df.item_type.DRINK, max_size=math.huge}}, + ['fat'] = {[df.item_type.GLOB] ={type_id=df.item_type.GLOB, max_size=5}, + [df.item_type.CHEESE] ={type_id=df.item_type.CHEESE, max_size=5}}, + ['fish'] = {[df.item_type.FISH] ={type_id=df.item_type.FISH, max_size=5}, + [df.item_type.FISH_RAW] ={type_id=df.item_type.FISH_RAW, max_size=5}, + [df.item_type.EGG] ={type_id=df.item_type.EGG, max_size=5}}, + ['food'] = {[df.item_type.FOOD] ={type_id=df.item_type.FOOD, max_size=20}}, + ['meat'] = {[df.item_type.MEAT] ={type_id=df.item_type.MEAT, max_size=5}}, + ['plant'] = {[df.item_type.PLANT] ={type_id=df.item_type.PLANT, max_size=5}, + [df.item_type.PLANT_GROWTH]={type_id=df.item_type.PLANT_GROWTH, max_size=5}}, + ['powder'] = {[df.item_type.POWDER_MISC] ={type_id=df.item_type.POWDER_MISC, max_size=10}}, ['seed'] = {[df.item_type.SEEDS] ={type_id=df.item_type.SEEDS, max_size=1}}, } @@ -110,9 +108,9 @@ local function comp_item_add_item(stockpile, stack_type, comp_item, item, contai comp_item.before_stacks = comp_item.before_stacks + 1 comp_item.description = utils.getItemDescription(item, 1) - if item.stack_size > comp_item.max_size then - comp_item.max_size = item.stack_size - end +-- if item.stack_size > comp_item.max_size then +-- comp_item.max_size = item.stack_size +-- end local new_item = {} new_item.item = item @@ -213,9 +211,9 @@ local function stacks_add_item(stockpile, stacks, stack_type, item, container) stacks.item_qty = stacks.item_qty + item.stack_size stacks.material_amt = stacks.material_amt + new_comp_item_item.before_mat_amt.Qty - if item.stack_size > stack_type.max_size then - stack_type.max_size = item.stack_size - end +-- if item.stack_size > stack_type.max_size then +-- stack_type.max_size = item.stack_size +-- end -- item is in a container if container then @@ -318,19 +316,19 @@ local function print_stacks_details(stacks, quiet) if #stacks.containers > 0 then log(1, 'Summary:\nContainers:%5d before:%5d after:%5d\n', #stacks.containers, #stacks.before_cont_ids, #stacks.after_cont_ids) for cont_id, cont in sorted_desc(stacks.containers, stacks.before_cont_ids) do - log(2, (' Cont: %50s <%6d> bef:%5d aft:%5d\n'):format(cont.description, cont_id, cont.before_size, cont.after_size)) + log(2, (' Cont: %50s <%6d> bef:%5d aft:%5d cap:%5d\n'):format(cont.description, cont_id, cont.before_size, cont.after_size, cont.capacity)) end end if stacks.item_qty > 0 then log(1, ('Items: #Qty: %6d sizes: bef:%5d aft:%5d Mat amt:%6d\n'):format(stacks.item_qty, stacks.before_stacks, stacks.after_stacks, stacks.material_amt)) for key, stack_type in pairs(stacks.stack_types) do if stack_type.item_qty > 0 then - log(1, (' Type: %12s <%d> #Qty:%6d sizes: max:%5d bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks, #stack_type.before_cont_ids, #stack_type.after_cont_ids, stack_type.material_amt)) + log(1, (' Type: %12s <%d> #Qty:%6d sizes: max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks, #stack_type.before_cont_ids, #stack_type.after_cont_ids, stack_type.material_amt)) for _, comp_item in sorted_desc(stack_type.comp_items, stack_type.comp_items) do if comp_item.item_qty > 0 then - log(2, (' Comp item:%40s <%12s> #Qty:%6d #stacks:%5d max:%5d bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids, comp_item.material_amt)) + log(2, (' Comp item:%40s <%12s> #Qty:%6d #stacks:%5d max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids, comp_item.material_amt)) for _, item in sorted_items_qty(comp_item.items) do - log(3, (' Item:%40s <%6d> Qty: bef:%6d aft:%6d Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d stockpile:%s'):format(utils.getItemDescription(item.item), item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name)) + log(3, (' Item:%40s <%6d> Qty: bef:%6d aft:%6.0f Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d stockpile:%s'):format(utils.getItemDescription(item.item), item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name)) log(4, (' stackable: %s'):format(df.item_type.attrs[stack_type.type_id].is_stackable)) log(3, ('\n')) end @@ -406,7 +404,7 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) -- item type in list of included types? if stack_type and not item:isSand() and not item:isPlaster() and isValidPart(item) then - if not isRestrictedItem(item) then + if not isRestrictedItem(item) and item.stack_size < stack_type.max_size then stacks_add_item(stockpile, stacks, stack_type, item, container) @@ -424,7 +422,7 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) else -- restricted; such as marked for action or dump. - log(4, (' %sitem:%40s <%6d> is restricted\n'):format(ind, utils.getItemDescription(item), item.id)) + log(5, (' %sitem:%40s <%6d> is restricted\n'):format(ind, utils.getItemDescription(item), item.id)) end -- add contained items @@ -435,7 +433,8 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) stacks.containers[item.id].container = item stacks.containers[item.id].before_size = #contained_items stacks.containers[item.id].description = utils.getItemDescription(item, 1) - log(4, (' %sContainer:%s <%6d> #items:%5d\n'):format(ind, utils.getItemDescription(item), item.id, count, item:isSandBearing())) + stacks.containers[item.id].capacity = dfhack.items.getCapacity(item) + log(4, (' %sContainer:%s <%6d> #items:%5d #capacity:%5d\n'):format(ind, utils.getItemDescription(item), item.id, count, dfhack.items.getCapacity(item))) stacks_add_items(stockpile, stacks, contained_items, item, ind .. ' ') -- excluded item types @@ -445,6 +444,20 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) end end +local function unlimited_stacks(types) + log(4, 'Unlimited stacks\n') + + if opts.unlimited_stack then + for type_id, type_vals in pairs(types) do + print(type_id, type_vals ) + if types[type_id].max_size > 1 then + types[type_id].max_size = math.huge + end + print(type_id, type_vals) + end + end +end + local function populate_stacks(stacks, stockpiles, types) -- 1. loop through the specified types and add them to the stacks table. stacks[type_id] -- 2. loop through the table of stockpiles, get each item in the stockpile, then add them to stacks if the type_id matches @@ -452,13 +465,15 @@ local function populate_stacks(stacks, stockpiles, types) -- comp_key is a compound key comprised of type_id+race+caste or type_id+mat_type+mat_index log(4, 'Populating phase\n') + unlimited_stacks(types) + -- iterate across the types log(4, 'stack types\n') for type_id, type_vals in pairs(types) do if not stacks.stack_types[type_id] then stacks.stack_types[type_id] = stack_type_new(type_vals) local stack_type = stacks.stack_types[type_id] - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %5d bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) end end @@ -483,10 +498,10 @@ local function preview_stacks(stacks) log(4, '\nPreview phase\n') for _, stack_type in pairs(stacks.stack_types) do - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %5d bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) for comp_key, comp_item in pairs(stack_type.comp_items) do - log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max:%5d bef:%5d aft:%5d Cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) + log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d Cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) -- item qty used? if not typesThatUseMaterial[df.item_type[stack_type.type_id]] then @@ -496,13 +511,16 @@ local function preview_stacks(stacks) comp_item.max_size = stack_type.max_size end - -- how many stacks are needed? + -- how many stacks are needed? For math.huge, this will be 0. local stacks_needed = math.floor(comp_item.item_qty / comp_item.max_size) - -- how many items are left over after the max stacks are allocated? - local stack_remainder = comp_item.item_qty - stacks_needed * comp_item.max_size + local stack_remainder = comp_item.item_qty + if comp_item.max_size < math.huge then + stack_remainder = comp_item.item_qty - stacks_needed * comp_item.max_size + end if stack_remainder > 0 then + -- if have remainder items, then need an additional stack. comp_item.after_stacks = stacks_needed + 1 else comp_item.after_stacks = stacks_needed @@ -510,6 +528,8 @@ local function preview_stacks(stacks) stack_type.after_stacks = stack_type.after_stacks + comp_item.after_stacks stacks.after_stacks = stacks.after_stacks + comp_item.after_stacks + log(4, (' comp item:%40s <%12s> stacks needed:%.0f stacks remainder: %.0f after stacks: %.0f \n'):format(comp_item.description, comp_item.comp_key, stacks_needed, stack_remainder, stacks.after_stacks)) + -- Update the after stack sizes. for _, item in sorted_items_qty(comp_item.items) do @@ -619,9 +639,9 @@ local function preview_stacks(stacks) before_cont.after_size = (before_cont.after_size or before_cont.before_size) - 1 end end - log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max:%5d bef:%5d aft:%5d cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) + log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) end - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %5d bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) end end @@ -738,6 +758,7 @@ local function parse_commandline(opts, args) {'t', 'types', hasArg=true, handler=function(optarg) opts.types=parse_types_opts(optarg) end}, {'d', 'dry-run', handler=function() opts.dry_run = true end}, {'q', 'quiet', handler=function() opts.quiet = true end}, + {'u','unlimited-stack',handler=function() opts.unlimited_stack = true end}, {'v', 'verbose', hasArg=true, handler=function(optarg) opts.verbose = math.tointeger(optarg) or 0 end}, }) From 9add898902e9ae09413fece522c4abbd8cf288fb Mon Sep 17 00:00:00 2001 From: silverflyone Date: Sun, 19 Nov 2023 12:34:53 +1100 Subject: [PATCH 2/9] realistic limits for combine --- combine.lua | 93 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/combine.lua b/combine.lua index fa9b299ea6..1f0cf388d4 100644 --- a/combine.lua +++ b/combine.lua @@ -10,12 +10,11 @@ local opts, args = { dry_run = false, types = nil, quiet = false, + unlimited_stack = false, verbose = 0, }, {...} -- default max stack size of 30 -local MAX_ITEM_STACK=30 -local MAX_AMMO_STACK=25 local MAX_CONT_ITEMS=30 local MAX_MAT_AMT=30 @@ -25,24 +24,23 @@ local typesThatUseMaterial=utils.invert{'CORPSEPIECE'} -- list of valid item types for merging -- Notes: 1. mergeable stacks are ones with the same type_id+race+caste or type_id+mat_type+mat_index --- 2. the maximum stack size is calcuated at run time: the highest value of MAX_ITEM_STACK or largest current stack size. --- 3. even though powders are specified, sand and plaster types items are excluded from merging. --- 4. seeds cannot be combined in stacks > 1. +-- 2. even though powders are specified, sand and plaster types items are excluded from merging. +-- 3. seeds cannot be combined in stacks > 1. local valid_types_map = { ['all'] = { }, - ['ammo'] = {[df.item_type.AMMO] ={type_id=df.item_type.AMMO, max_size=MAX_AMMO_STACK}}, + ['ammo'] = {[df.item_type.AMMO] ={type_id=df.item_type.AMMO, max_size=25}}, ['parts'] = {[df.item_type.CORPSEPIECE] ={type_id=df.item_type.CORPSEPIECE, max_size=1}}, - ['drink'] = {[df.item_type.DRINK] ={type_id=df.item_type.DRINK, max_size=MAX_ITEM_STACK}}, - ['fat'] = {[df.item_type.GLOB] ={type_id=df.item_type.GLOB, max_size=MAX_ITEM_STACK}, - [df.item_type.CHEESE] ={type_id=df.item_type.CHEESE, max_size=MAX_ITEM_STACK}}, - ['fish'] = {[df.item_type.FISH] ={type_id=df.item_type.FISH, max_size=MAX_ITEM_STACK}, - [df.item_type.FISH_RAW] ={type_id=df.item_type.FISH_RAW, max_size=MAX_ITEM_STACK}, - [df.item_type.EGG] ={type_id=df.item_type.EGG, max_size=MAX_ITEM_STACK}}, - ['food'] = {[df.item_type.FOOD] ={type_id=df.item_type.FOOD, max_size=MAX_ITEM_STACK}}, - ['meat'] = {[df.item_type.MEAT] ={type_id=df.item_type.MEAT, max_size=MAX_ITEM_STACK}}, - ['plant'] = {[df.item_type.PLANT] ={type_id=df.item_type.PLANT, max_size=MAX_ITEM_STACK}, - [df.item_type.PLANT_GROWTH]={type_id=df.item_type.PLANT_GROWTH, max_size=MAX_ITEM_STACK}}, - ['powder'] = {[df.item_type.POWDER_MISC] ={type_id=df.item_type.POWDER_MISC, max_size=MAX_ITEM_STACK}}, + ['drink'] = {[df.item_type.DRINK] ={type_id=df.item_type.DRINK, max_size=math.huge}}, + ['fat'] = {[df.item_type.GLOB] ={type_id=df.item_type.GLOB, max_size=5}, + [df.item_type.CHEESE] ={type_id=df.item_type.CHEESE, max_size=5}}, + ['fish'] = {[df.item_type.FISH] ={type_id=df.item_type.FISH, max_size=5}, + [df.item_type.FISH_RAW] ={type_id=df.item_type.FISH_RAW, max_size=5}, + [df.item_type.EGG] ={type_id=df.item_type.EGG, max_size=5}}, + ['food'] = {[df.item_type.FOOD] ={type_id=df.item_type.FOOD, max_size=20}}, + ['meat'] = {[df.item_type.MEAT] ={type_id=df.item_type.MEAT, max_size=5}}, + ['plant'] = {[df.item_type.PLANT] ={type_id=df.item_type.PLANT, max_size=5}, + [df.item_type.PLANT_GROWTH]={type_id=df.item_type.PLANT_GROWTH, max_size=5}}, + ['powder'] = {[df.item_type.POWDER_MISC] ={type_id=df.item_type.POWDER_MISC, max_size=10}}, ['seed'] = {[df.item_type.SEEDS] ={type_id=df.item_type.SEEDS, max_size=1}}, } @@ -110,10 +108,6 @@ local function comp_item_add_item(stockpile, stack_type, comp_item, item, contai comp_item.before_stacks = comp_item.before_stacks + 1 comp_item.description = utils.getItemDescription(item, 1) - if item.stack_size > comp_item.max_size then - comp_item.max_size = item.stack_size - end - local new_item = {} new_item.item = item new_item.before_size = item.stack_size @@ -213,10 +207,6 @@ local function stacks_add_item(stockpile, stacks, stack_type, item, container) stacks.item_qty = stacks.item_qty + item.stack_size stacks.material_amt = stacks.material_amt + new_comp_item_item.before_mat_amt.Qty - if item.stack_size > stack_type.max_size then - stack_type.max_size = item.stack_size - end - -- item is in a container if container then @@ -318,19 +308,19 @@ local function print_stacks_details(stacks, quiet) if #stacks.containers > 0 then log(1, 'Summary:\nContainers:%5d before:%5d after:%5d\n', #stacks.containers, #stacks.before_cont_ids, #stacks.after_cont_ids) for cont_id, cont in sorted_desc(stacks.containers, stacks.before_cont_ids) do - log(2, (' Cont: %50s <%6d> bef:%5d aft:%5d\n'):format(cont.description, cont_id, cont.before_size, cont.after_size)) + log(2, (' Cont: %50s <%6d> bef:%5d aft:%5d cap:%5d\n'):format(cont.description, cont_id, cont.before_size, cont.after_size, cont.capacity)) end end if stacks.item_qty > 0 then log(1, ('Items: #Qty: %6d sizes: bef:%5d aft:%5d Mat amt:%6d\n'):format(stacks.item_qty, stacks.before_stacks, stacks.after_stacks, stacks.material_amt)) for key, stack_type in pairs(stacks.stack_types) do if stack_type.item_qty > 0 then - log(1, (' Type: %12s <%d> #Qty:%6d sizes: max:%5d bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks, #stack_type.before_cont_ids, #stack_type.after_cont_ids, stack_type.material_amt)) + log(1, (' Type: %12s <%d> #Qty:%6d sizes: max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks, #stack_type.before_cont_ids, #stack_type.after_cont_ids, stack_type.material_amt)) for _, comp_item in sorted_desc(stack_type.comp_items, stack_type.comp_items) do if comp_item.item_qty > 0 then - log(2, (' Comp item:%40s <%12s> #Qty:%6d #stacks:%5d max:%5d bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids, comp_item.material_amt)) + log(2, (' Comp item:%40s <%12s> #Qty:%6d #stacks:%5d max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids, comp_item.material_amt)) for _, item in sorted_items_qty(comp_item.items) do - log(3, (' Item:%40s <%6d> Qty: bef:%6d aft:%6d Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d stockpile:%s'):format(utils.getItemDescription(item.item), item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name)) + log(3, (' Item:%40s <%6d> Qty: bef:%6d aft:%6.0f Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d stockpile:%s'):format(utils.getItemDescription(item.item), item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name)) log(4, (' stackable: %s'):format(df.item_type.attrs[stack_type.type_id].is_stackable)) log(3, ('\n')) end @@ -406,7 +396,7 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) -- item type in list of included types? if stack_type and not item:isSand() and not item:isPlaster() and isValidPart(item) then - if not isRestrictedItem(item) then + if not isRestrictedItem(item) and item.stack_size < stack_type.max_size then stacks_add_item(stockpile, stacks, stack_type, item, container) @@ -424,7 +414,7 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) else -- restricted; such as marked for action or dump. - log(4, (' %sitem:%40s <%6d> is restricted\n'):format(ind, utils.getItemDescription(item), item.id)) + log(5, (' %sitem:%40s <%6d> is restricted\n'):format(ind, utils.getItemDescription(item), item.id)) end -- add contained items @@ -435,7 +425,8 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) stacks.containers[item.id].container = item stacks.containers[item.id].before_size = #contained_items stacks.containers[item.id].description = utils.getItemDescription(item, 1) - log(4, (' %sContainer:%s <%6d> #items:%5d\n'):format(ind, utils.getItemDescription(item), item.id, count, item:isSandBearing())) + stacks.containers[item.id].capacity = dfhack.items.getCapacity(item) + log(4, (' %sContainer:%s <%6d> #items:%5d #capacity:%5d\n'):format(ind, utils.getItemDescription(item), item.id, count, dfhack.items.getCapacity(item))) stacks_add_items(stockpile, stacks, contained_items, item, ind .. ' ') -- excluded item types @@ -445,6 +436,20 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) end end +local function unlimited_stacks(types) + log(4, 'Unlimited stacks\n') + + if opts.unlimited_stack then + for type_id, type_vals in pairs(types) do + print(type_id, type_vals ) + if types[type_id].max_size > 1 then + types[type_id].max_size = math.huge + end + print(type_id, type_vals) + end + end +end + local function populate_stacks(stacks, stockpiles, types) -- 1. loop through the specified types and add them to the stacks table. stacks[type_id] -- 2. loop through the table of stockpiles, get each item in the stockpile, then add them to stacks if the type_id matches @@ -452,13 +457,15 @@ local function populate_stacks(stacks, stockpiles, types) -- comp_key is a compound key comprised of type_id+race+caste or type_id+mat_type+mat_index log(4, 'Populating phase\n') + unlimited_stacks(types) + -- iterate across the types log(4, 'stack types\n') for type_id, type_vals in pairs(types) do if not stacks.stack_types[type_id] then stacks.stack_types[type_id] = stack_type_new(type_vals) local stack_type = stacks.stack_types[type_id] - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %5d bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) end end @@ -483,10 +490,10 @@ local function preview_stacks(stacks) log(4, '\nPreview phase\n') for _, stack_type in pairs(stacks.stack_types) do - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %5d bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) for comp_key, comp_item in pairs(stack_type.comp_items) do - log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max:%5d bef:%5d aft:%5d Cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) + log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d Cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) -- item qty used? if not typesThatUseMaterial[df.item_type[stack_type.type_id]] then @@ -496,13 +503,16 @@ local function preview_stacks(stacks) comp_item.max_size = stack_type.max_size end - -- how many stacks are needed? + -- how many stacks are needed? For math.huge, this will be 0. local stacks_needed = math.floor(comp_item.item_qty / comp_item.max_size) - -- how many items are left over after the max stacks are allocated? - local stack_remainder = comp_item.item_qty - stacks_needed * comp_item.max_size + local stack_remainder = comp_item.item_qty + if comp_item.max_size < math.huge then + stack_remainder = comp_item.item_qty - stacks_needed * comp_item.max_size + end if stack_remainder > 0 then + -- if have remainder items, then need an additional stack. comp_item.after_stacks = stacks_needed + 1 else comp_item.after_stacks = stacks_needed @@ -510,6 +520,8 @@ local function preview_stacks(stacks) stack_type.after_stacks = stack_type.after_stacks + comp_item.after_stacks stacks.after_stacks = stacks.after_stacks + comp_item.after_stacks + log(4, (' comp item:%40s <%12s> stacks needed:%.0f stacks remainder: %.0f after stacks: %.0f \n'):format(comp_item.description, comp_item.comp_key, stacks_needed, stack_remainder, stacks.after_stacks)) + -- Update the after stack sizes. for _, item in sorted_items_qty(comp_item.items) do @@ -619,9 +631,9 @@ local function preview_stacks(stacks) before_cont.after_size = (before_cont.after_size or before_cont.before_size) - 1 end end - log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max:%5d bef:%5d aft:%5d cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) + log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) end - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %5d bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) end end @@ -738,6 +750,7 @@ local function parse_commandline(opts, args) {'t', 'types', hasArg=true, handler=function(optarg) opts.types=parse_types_opts(optarg) end}, {'d', 'dry-run', handler=function() opts.dry_run = true end}, {'q', 'quiet', handler=function() opts.quiet = true end}, + {'u','unlimited-stack',handler=function() opts.unlimited_stack = true end}, {'v', 'verbose', hasArg=true, handler=function(optarg) opts.verbose = math.tointeger(optarg) or 0 end}, }) From db6d0059996fb7c135c48de1a714c8eda8331e33 Mon Sep 17 00:00:00 2001 From: silverflyone Date: Sun, 19 Nov 2023 22:19:23 +1100 Subject: [PATCH 3/9] review changes and started vol change for cont --- combine.lua | 184 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 107 insertions(+), 77 deletions(-) diff --git a/combine.lua b/combine.lua index c557522c83..71639bab07 100644 --- a/combine.lua +++ b/combine.lua @@ -28,20 +28,20 @@ local typesThatUseMaterial=utils.invert{'CORPSEPIECE'} -- 3. seeds cannot be combined in stacks > 1. local valid_types_map = { ['all'] = { }, - ['ammo'] = {[df.item_type.AMMO] ={type_id=df.item_type.AMMO, max_size=25}}, - ['parts'] = {[df.item_type.CORPSEPIECE] ={type_id=df.item_type.CORPSEPIECE, max_size=1}}, - ['drink'] = {[df.item_type.DRINK] ={type_id=df.item_type.DRINK, max_size=math.huge}}, - ['fat'] = {[df.item_type.GLOB] ={type_id=df.item_type.GLOB, max_size=5}, - [df.item_type.CHEESE] ={type_id=df.item_type.CHEESE, max_size=5}}, - ['fish'] = {[df.item_type.FISH] ={type_id=df.item_type.FISH, max_size=5}, - [df.item_type.FISH_RAW] ={type_id=df.item_type.FISH_RAW, max_size=5}, - [df.item_type.EGG] ={type_id=df.item_type.EGG, max_size=5}}, - ['food'] = {[df.item_type.FOOD] ={type_id=df.item_type.FOOD, max_size=20}}, - ['meat'] = {[df.item_type.MEAT] ={type_id=df.item_type.MEAT, max_size=5}}, - ['plant'] = {[df.item_type.PLANT] ={type_id=df.item_type.PLANT, max_size=5}, - [df.item_type.PLANT_GROWTH]={type_id=df.item_type.PLANT_GROWTH, max_size=5}}, - ['powder'] = {[df.item_type.POWDER_MISC] ={type_id=df.item_type.POWDER_MISC, max_size=10}}, - ['seed'] = {[df.item_type.SEEDS] ={type_id=df.item_type.SEEDS, max_size=1}}, + ['ammo'] = {[df.item_type.AMMO] ={type_id=df.item_type.AMMO, max_stack_qty=25}}, + ['parts'] = {[df.item_type.CORPSEPIECE] ={type_id=df.item_type.CORPSEPIECE, max_stack_qty=1}}, + ['drink'] = {[df.item_type.DRINK] ={type_id=df.item_type.DRINK, max_stack_qty=math.huge}}, + ['fat'] = {[df.item_type.GLOB] ={type_id=df.item_type.GLOB, max_stack_qty=5}, + [df.item_type.CHEESE] ={type_id=df.item_type.CHEESE, max_stack_qty=5}}, + ['fish'] = {[df.item_type.FISH] ={type_id=df.item_type.FISH, max_stack_qty=5}, + [df.item_type.FISH_RAW] ={type_id=df.item_type.FISH_RAW, max_stack_qty=5}, + [df.item_type.EGG] ={type_id=df.item_type.EGG, max_stack_qty=5}}, + ['food'] = {[df.item_type.FOOD] ={type_id=df.item_type.FOOD, max_stack_qty=20}}, + ['meat'] = {[df.item_type.MEAT] ={type_id=df.item_type.MEAT, max_stack_qty=5}}, + ['plant'] = {[df.item_type.PLANT] ={type_id=df.item_type.PLANT, max_stack_qty=5}, + [df.item_type.PLANT_GROWTH]={type_id=df.item_type.PLANT_GROWTH, max_stack_qty=5}}, + ['powder'] = {[df.item_type.POWDER_MISC] ={type_id=df.item_type.POWDER_MISC, max_stack_qty=10}}, + ['seed'] = {[df.item_type.SEEDS] ={type_id=df.item_type.SEEDS, max_stack_qty=1}}, } @@ -75,43 +75,61 @@ function CList:new(o) return o end -local function comp_item_new(comp_key, max_size) +local function comp_item_new(comp_key, max_stack_qty) -- create a new comp_item entry to be added to a comp_items table. local comp_item = {} if not comp_key then qerror('new_comp_item: comp_key is nil') end comp_item.comp_key = comp_key -- key used to index comparable items for merging comp_item.description = '' -- description of the comp item for output - comp_item.max_size = max_size or 0 -- how many of a comp item can be in one stack + comp_item.max_stack_qty = max_stack_qty or 0 -- how many of a comp item can be in one stack -- item info comp_item.items = CList:new(nil) -- key:item.id, - -- val:{item, - -- before_size, after_size, before_cont_id, after_cont_id, + -- val:{item, base_weight, density, + -- before_stack_qty, after_stack_qty, + -- before_cont_id, after_cont_id, + -- before_volume, after_volume, -- stockpile_id, stockpile_name, -- before_mat_amt {Leather, Bone, Shell, Tooth, Horn, HairWool, Yarn} -- after_mat_amt {Leather, Bone, Shell, Tooth, Horn, HairWool, Yarn} -- } comp_item.item_qty = 0 -- total quantity of items + comp_item.base_weight = 0 -- base weight of an item + comp_item.density = 0 -- density of an item + comp_item.volume = 0 -- volume = qty * base weight + comp_item.weight = 0 -- weight = density * volume * 10 / 1,000,000 comp_item.material_amt = 0 -- total amount of materials comp_item.max_mat_amt = MAX_MAT_AMT -- max amount of materials in one stack comp_item.before_stacks = 0 -- the number of stacks of the items before... comp_item.after_stacks = 0 -- ...and after the merge --container info - comp_item.before_cont_ids = CList:new(nil) -- key:container.id, val:container.id - comp_item.after_cont_ids = CList:new(nil) -- key:container.id, val:container.id + comp_item.before_cont_ids = CList:new(nil) -- key:container.id, val:container.id + comp_item.after_cont_ids = CList:new(nil) -- key:container.id, val:container.id return comp_item end local function comp_item_add_item(stockpile, stack_type, comp_item, item, container) -- add an item into the comp_items table, setting the comp_item attributes. if not comp_item.items[item.id] then - comp_item.item_qty = comp_item.item_qty + item.stack_size + local item_qty = item.stack_size + local item_base_weight = item:getBaseWeight() + local item_volume = item:getVolume() + local item_density = item:getSolidDensity() + + comp_item.item_qty = comp_item.item_qty + item_qty comp_item.before_stacks = comp_item.before_stacks + 1 comp_item.description = utils.getItemDescription(item, 1) + comp_item.base_weight = item_base_weight + comp_item.volume = item_qty * item_base_weight + comp_item.density = item_density local new_item = {} new_item.item = item - new_item.before_size = item.stack_size + new_item.base_weight = item_base_weight + new_item.density = item_density + + new_item.before_stack_qty = item_qty + new_item.before_volume = item_qty * item_base_weight new_item.stockpile_id = stockpile.id new_item.stockpile_name = stockpile.name @@ -131,10 +149,16 @@ local function comp_item_add_item(stockpile, stack_type, comp_item, item, contai new_item.before_mat_amt.Horn = item.material_amount.Horn new_item.before_mat_amt.HairWool = item.material_amount.HairWool new_item.before_mat_amt.Yarn = item.material_amount.Yarn - for _, v in pairs(new_item.before_mat_amt) do if new_item.before_mat_amt.Qty < v then new_item.before_mat_amt.Qty = v end end + for _, v in pairs(new_item.before_mat_amt) do + if new_item.before_mat_amt.Qty < v then + new_item.before_mat_amt.Qty = v + end + end comp_item.material_amt = comp_item.material_amt + new_item.before_mat_amt.Qty - if new_item.before_mat_amt.Qty > comp_item.max_mat_amt then comp_item.max_mat_amt = new_item.before_mat_amt.Qty end + if new_item.before_mat_amt.Qty > comp_item.max_mat_amt then + comp_item.max_mat_amt = new_item.before_mat_amt.Qty + end end -- item is in a container @@ -162,15 +186,15 @@ local function stack_type_new(type_vals) end -- item info - stack_type.comp_items = CList:new(nil) -- key:comp_key, val:comp_item + stack_type.comp_items = CList:new(nil) -- key:comp_key, val:comp_item stack_type.item_qty = 0 -- total quantity of items types stack_type.material_amt = 0 -- total amount of materials stack_type.before_stacks = 0 -- the number of stacks of the item types before ... stack_type.after_stacks = 0 -- ...and after the merge --container info - stack_type.before_cont_ids = CList:new(nil) -- key:container.id, val:container.id - stack_type.after_cont_ids = CList:new(nil) -- key:container.id, val:container.id + stack_type.before_cont_ids = CList:new(nil) -- key:container.id, val:container.id + stack_type.after_cont_ids = CList:new(nil) -- key:container.id, val:container.id return stack_type end @@ -195,7 +219,7 @@ local function stacks_add_item(stockpile, stacks, stack_type, item, container) end if not stack_type.comp_items[comp_key] then - stack_type.comp_items[comp_key] = comp_item_new(comp_key, stack_type.max_size) + stack_type.comp_items[comp_key] = comp_item_new(comp_key, stack_type.max_stack_qty) end local new_comp_item_item = comp_item_add_item(stockpile, stack_type, stack_type.comp_items[comp_key], item, container) @@ -221,17 +245,17 @@ local function stacks_add_item(stockpile, stacks, stack_type, item, container) end local function sorted_items_qty(tab) - -- used to sort the comp_items by contained, then size. Important for combining containers. + -- used to sort the comp_items by contained, then qty. Important for combining containers. local tmp = {} for id, val in pairs(tab) do - local val = {id=id, before_cont_id=val.before_cont_id, before_size=val.before_size} + local val = {id=id, before_cont_id=val.before_cont_id, before_stack_qty=val.before_stack_qty} table.insert(tmp, val) end table.sort(tmp, function(a, b) if not a.before_cont_id and not b.before_cont_id or a.before_cont_id and b.before_cont_id then - return a.before_size > b.before_size + return a.before_stack_qty > b.before_stack_qty else return a.before_cont_id and not b.before_cont_id end @@ -309,19 +333,20 @@ local function print_stacks_details(stacks, quiet) if #stacks.containers > 0 then log(1, 'Summary:\nContainers:%5d before:%5d after:%5d\n', #stacks.containers, #stacks.before_cont_ids, #stacks.after_cont_ids) for cont_id, cont in sorted_desc(stacks.containers, stacks.before_cont_ids) do - log(2, (' Cont: %50s <%6d> bef:%5d aft:%5d cap:%5d\n'):format(cont.description, cont_id, cont.before_size, cont.after_size, cont.capacity)) + log(2, (' Cont: %50s <%6d> bef:%5d aft:%5d cap:%5d\n'):format(cont.description, cont_id, cont.before_stack_qty, cont.after_stack_qty, cont.capacity)) end end if stacks.item_qty > 0 then - log(1, ('Items: #Qty: %6d sizes: bef:%5d aft:%5d Mat amt:%6d\n'):format(stacks.item_qty, stacks.before_stacks, stacks.after_stacks, stacks.material_amt)) + log(1, ('Items: #Qty: %6d Stacks: bef:%5d aft:%5d Mat amt:%6d\n'):format(stacks.item_qty, stacks.before_stacks, stacks.after_stacks, stacks.material_amt)) for key, stack_type in pairs(stacks.stack_types) do if stack_type.item_qty > 0 then - log(1, (' Type: %12s <%d> #Qty:%6d sizes: max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks, #stack_type.before_cont_ids, #stack_type.after_cont_ids, stack_type.material_amt)) + log(1, (' Type: %12s <%d> #Qty:%6d Stacks: max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_stack_qty, stack_type.before_stacks, stack_type.after_stacks, #stack_type.before_cont_ids, #stack_type.after_cont_ids, stack_type.material_amt)) for _, comp_item in sorted_desc(stack_type.comp_items, stack_type.comp_items) do if comp_item.item_qty > 0 then - log(2, (' Comp item:%40s <%12s> #Qty:%6d #stacks:%5d max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids, comp_item.material_amt)) + log(2, ('G Comp item:%40s <%12s> #Qty:%6d #stacks:%5d max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_stack_qty, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids, comp_item.material_amt)) for _, item in sorted_items_qty(comp_item.items) do - log(3, (' Item:%40s <%6d> Qty: bef:%6d aft:%6.0f Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d stockpile:%s'):format(utils.getItemDescription(item.item), item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name)) + log(3, (' Item:%40s <%6d> Qty: bef:%6d aft:%6.0f Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d stockpile:%s'):format(utils.getItemDescription(item.item), item.item.id, item.before_stack_qty or 0, item.after_stack_qty or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name)) + log(2, (' Item:%40s <%6d> Qty: bef:%6d aft:%6.0f Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d sp:%s den: %6d s size: %6d liq:%s b wt:%6d vol:%6d\n'):format(utils.getItemDescription(item.item), item.item.id, item.before_stack_qty or 0, item.after_stack_qty or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name, item.item:getSolidDensity(), item.item:getStackSize(), item.item:isLiquid(), item.item:getBaseWeight(), item.item:getVolume())) log(4, (' stackable: %s'):format(df.item_type.attrs[stack_type.type_id].is_stackable)) log(3, ('\n')) end @@ -353,7 +378,7 @@ local function stacks_new() local stacks = {} stacks.stack_types = CList:new(nil) -- key=type_id, val=stack_type - stacks.containers = CList:new(nil) -- key=container.id, val={container, description, before_size, after_size} + stacks.containers = CList:new(nil) -- key=container.id, val={container, description, before_stack_qty, after_stack_qty} stacks.before_cont_ids = CList:new(nil) -- key=container.id, val=container.id stacks.after_cont_ids = CList:new(nil) -- key=container.id, val=container.id stacks.item_qty = 0 @@ -394,10 +419,11 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) local type_id = item:getType() local subtype_id = item:getSubtype() local stack_type = stacks.stack_types[type_id] + local item_qty = item.stack_size -- stack size is actually a qty in this context. -- item type in list of included types? if stack_type and not item:isSand() and not item:isPlaster() and isValidPart(item) then - if not isRestrictedItem(item) and item.stack_size < stack_type.max_size then + if not isRestrictedItem(item) and item_qty < stack_type.max_stack_qty then stacks_add_item(stockpile, stacks, stack_type, item, container) @@ -424,7 +450,7 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) local count = #contained_items stacks.containers[item.id] = {} stacks.containers[item.id].container = item - stacks.containers[item.id].before_size = #contained_items + stacks.containers[item.id].before_stack_qty = #contained_items stacks.containers[item.id].description = utils.getItemDescription(item, 1) stacks.containers[item.id].capacity = dfhack.items.getCapacity(item) log(4, (' %sContainer:%s <%6d> #items:%5d #capacity:%5d\n'):format(ind, utils.getItemDescription(item), item.id, count, dfhack.items.getCapacity(item))) @@ -438,15 +464,16 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) end local function unlimited_stacks(types) - log(4, 'Unlimited stacks\n') + -- Override the realistic limits of stack sizes. This is armok behaviour for those that want it. + -- Note: large stack sizes causes bottle neck effects for production of constructed items. + -- Need to determine how this interacts with container capacities. + -- There are certain types such as seeds that don't like being in stacks + -- greater than 1, so exclude these ones. + log(4, 'Unlimited stacks applied\n') - if opts.unlimited_stack then - for type_id, type_vals in pairs(types) do - print(type_id, type_vals ) - if types[type_id].max_size > 1 then - types[type_id].max_size = math.huge - end - print(type_id, type_vals) + for type_id, type_vals in pairs(types) do + if types[type_id].max_stack_qty > 1 then + types[type_id].max_stack_qty = math.huge end end end @@ -458,7 +485,10 @@ local function populate_stacks(stacks, stockpiles, types) -- comp_key is a compound key comprised of type_id+race+caste or type_id+mat_type+mat_index log(4, 'Populating phase\n') - unlimited_stacks(types) + -- unlimited stack sizes option enabled = Armok. Note that this is disabled by default. + if opts.unlimited_stack then + unlimited_stacks(types) + end -- iterate across the types log(4, 'stack types\n') @@ -466,7 +496,7 @@ local function populate_stacks(stacks, stockpiles, types) if not stacks.stack_types[type_id] then stacks.stack_types[type_id] = stack_type_new(type_vals) local stack_type = stacks.stack_types[type_id] - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_stack_qty, stack_type.before_stacks, stack_type.after_stacks)) end end @@ -491,25 +521,25 @@ local function preview_stacks(stacks) log(4, '\nPreview phase\n') for _, stack_type in pairs(stacks.stack_types) do - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_stack_qty, stack_type.before_stacks, stack_type.after_stacks)) for comp_key, comp_item in pairs(stack_type.comp_items) do - log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d Cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) + log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d Cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_stack_qty, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) -- item qty used? if not typesThatUseMaterial[df.item_type[stack_type.type_id]] then -- max size comparison - if stack_type.max_size > comp_item.max_size then - comp_item.max_size = stack_type.max_size + if stack_type.max_stack_qty > comp_item.max_stack_qty then + comp_item.max_stack_qty = stack_type.max_stack_qty end -- how many stacks are needed? For math.huge, this will be 0. - local stacks_needed = math.floor(comp_item.item_qty / comp_item.max_size) + local stacks_needed = math.floor(comp_item.item_qty / comp_item.max_stack_qty) local stack_remainder = comp_item.item_qty - if comp_item.max_size < math.huge then - stack_remainder = comp_item.item_qty - stacks_needed * comp_item.max_size + if comp_item.max_stack_qty < math.huge then + stack_remainder = comp_item.item_qty - stacks_needed * comp_item.max_stack_qty end if stack_remainder > 0 then @@ -528,12 +558,12 @@ local function preview_stacks(stacks) for _, item in sorted_items_qty(comp_item.items) do if stacks_needed > 0 then stacks_needed = stacks_needed - 1 - item.after_size = comp_item.max_size + item.after_stack_qty = comp_item.max_stack_qty elseif stack_remainder > 0 then - item.after_size = stack_remainder + item.after_stack_qty = stack_remainder stack_remainder = 0 else - item.after_size = 0 + item.after_stack_qty = 0 end end @@ -555,7 +585,7 @@ local function preview_stacks(stacks) item.after_mat_amt = {} if stacks_needed > 0 then stacks_needed = stacks_needed - 1 - item.after_size = item.before_size + item.after_stack_qty = item.before_stack_qty for k2, v in pairs(item.before_mat_amt) do if v > 0 then item.after_mat_amt[k2] = comp_item.max_mat_amt @@ -564,7 +594,7 @@ local function preview_stacks(stacks) end end elseif stack_remainder > 0 then - item.after_size = item.before_size + item.after_stack_qty = item.before_stack_qty for k2, v in pairs(item.before_mat_amt) do if v > 0 then item.after_mat_amt[k2] = stack_remainder @@ -577,7 +607,7 @@ local function preview_stacks(stacks) for k2, v in pairs(item.before_mat_amt) do item.after_mat_amt[k2] = 0 end - item.after_size = 0 + item.after_stack_qty = 0 end end end @@ -589,7 +619,7 @@ local function preview_stacks(stacks) for item_id, item in sorted_items_qty(comp_item.items) do -- non-zero quantity? - if item.after_size > 0 then + if item.after_stack_qty > 0 then -- in a container before merge? if item.before_cont_id then @@ -600,7 +630,7 @@ local function preview_stacks(stacks) if not curr_cont or curr_size >= MAX_CONT_ITEMS then curr_cont = before_cont - curr_size = curr_cont.before_size + curr_size = curr_cont.before_stack_qty stacks.after_cont_ids[item.before_cont_id] = item.before_cont_id stack_type.after_cont_ids[item.before_cont_id] = item.before_cont_id comp_item.after_cont_ids[item.before_cont_id] = item.before_cont_id @@ -608,17 +638,17 @@ local function preview_stacks(stacks) -- enough room in current container else curr_size = curr_size + 1 - before_cont.after_size = (before_cont.after_size or before_cont.before_size) - 1 + before_cont.after_stack_qty = (before_cont.after_stack_qty or before_cont.before_stack_qty) - 1 end - curr_cont.after_size = curr_size + curr_cont.after_stack_qty = curr_size item.after_cont_id = curr_cont.container.id -- not in a container before merge, container exists, and has space elseif curr_cont and curr_size < MAX_CONT_ITEMS then curr_size = curr_size + 1 - curr_cont.after_size = curr_size + curr_cont.after_stack_qty = curr_size item.after_cont_id = curr_cont.container.id -- not in a container, no container exists or no space in container @@ -629,34 +659,34 @@ local function preview_stacks(stacks) -- zero after size, reduce the number of stacks in the container elseif item.before_cont_id then local before_cont = stacks.containers[item.before_cont_id] - before_cont.after_size = (before_cont.after_size or before_cont.before_size) - 1 + before_cont.after_stack_qty = (before_cont.after_stack_qty or before_cont.before_stack_qty) - 1 end end - log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) + log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_stack_qty, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) end - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_stack_qty, stack_type.before_stacks, stack_type.after_stacks)) end end local function merge_stacks(stacks) - -- apply the stack size changes in the after_item_stack_size - -- if the after_item_stack_size is zero, then remove the item + -- apply the stack size changes in the item.after_stack_qty + -- if the item.after_stack_qty is zero, then remove the item log(4, 'Merge phase\n') for _, stack_type in pairs(stacks.stack_types) do for comp_key, comp_item in pairs(stack_type.comp_items) do for item_id, item in pairs(comp_item.items) do - log(4, (' item amt:%40s <%6d> bef:%5d aft:%5d cont: bef:<%5d> aft:<%5d> mat: bef:%5d aft:%5d '):format(comp_item.description, item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0)) + log(4, (' item amt:%40s <%6d> bef:%5d aft:%5d cont: bef:<%5d> aft:<%5d> mat: bef:%5d aft:%5d '):format(comp_item.description, item.item.id, item.before_stack_qty or 0, item.after_stack_qty or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0)) -- no items left in stack? - if item.after_size == 0 then + if item.after_stack_qty == 0 then log(4, ' removing\n') dfhack.items.remove(item.item) -- some items left in stack - elseif not typesThatUseMaterial[df.item_type[stack_type.type_id]] and item.before_size ~= item.after_size then + elseif not typesThatUseMaterial[df.item_type[stack_type.type_id]] and item.before_stack_qty ~= item.after_stack_qty then log(4, ' updating qty\n') - item.item.stack_size = item.after_size + item.item.stack_size = item.after_stack_qty elseif typesThatUseMaterial[df.item_type[stack_type.type_id]] and item.before_mat_amt.Qty ~= item.after_mat_amt.Qty then log(4, ' updating material\n') @@ -674,7 +704,7 @@ local function merge_stacks(stacks) -- move to a container? if item.after_cont_id then if (item.before_cont_id or 0) ~= item.after_cont_id then - log(4, (' moving item:%40s <%6d> bef:%5d aft:%5d cont: bef:<%5d> aft:<%5d>\n'):format(comp_item.description, item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0)) + log(4, (' moving item:%40s <%6d> bef:%5d aft:%5d cont: bef:<%5d> aft:<%5d>\n'):format(comp_item.description, item.item.id, item.before_stack_qty or 0, item.after_stack_qty or 0, item.before_cont_id or 0, item.after_cont_id or 0)) dfhack.items.moveToContainer(item.item, stacks.containers[item.after_cont_id].container) end end From 809845f6b591e7ff8f7e46e580718249195b03b7 Mon Sep 17 00:00:00 2001 From: silverflyone Date: Sun, 19 Nov 2023 22:19:23 +1100 Subject: [PATCH 4/9] review comments + cont capacity started --- combine.lua | 184 +++++++++++++++++++++++++++-------------------- docs/combine.rst | 28 ++++---- 2 files changed, 121 insertions(+), 91 deletions(-) diff --git a/combine.lua b/combine.lua index c557522c83..71639bab07 100644 --- a/combine.lua +++ b/combine.lua @@ -28,20 +28,20 @@ local typesThatUseMaterial=utils.invert{'CORPSEPIECE'} -- 3. seeds cannot be combined in stacks > 1. local valid_types_map = { ['all'] = { }, - ['ammo'] = {[df.item_type.AMMO] ={type_id=df.item_type.AMMO, max_size=25}}, - ['parts'] = {[df.item_type.CORPSEPIECE] ={type_id=df.item_type.CORPSEPIECE, max_size=1}}, - ['drink'] = {[df.item_type.DRINK] ={type_id=df.item_type.DRINK, max_size=math.huge}}, - ['fat'] = {[df.item_type.GLOB] ={type_id=df.item_type.GLOB, max_size=5}, - [df.item_type.CHEESE] ={type_id=df.item_type.CHEESE, max_size=5}}, - ['fish'] = {[df.item_type.FISH] ={type_id=df.item_type.FISH, max_size=5}, - [df.item_type.FISH_RAW] ={type_id=df.item_type.FISH_RAW, max_size=5}, - [df.item_type.EGG] ={type_id=df.item_type.EGG, max_size=5}}, - ['food'] = {[df.item_type.FOOD] ={type_id=df.item_type.FOOD, max_size=20}}, - ['meat'] = {[df.item_type.MEAT] ={type_id=df.item_type.MEAT, max_size=5}}, - ['plant'] = {[df.item_type.PLANT] ={type_id=df.item_type.PLANT, max_size=5}, - [df.item_type.PLANT_GROWTH]={type_id=df.item_type.PLANT_GROWTH, max_size=5}}, - ['powder'] = {[df.item_type.POWDER_MISC] ={type_id=df.item_type.POWDER_MISC, max_size=10}}, - ['seed'] = {[df.item_type.SEEDS] ={type_id=df.item_type.SEEDS, max_size=1}}, + ['ammo'] = {[df.item_type.AMMO] ={type_id=df.item_type.AMMO, max_stack_qty=25}}, + ['parts'] = {[df.item_type.CORPSEPIECE] ={type_id=df.item_type.CORPSEPIECE, max_stack_qty=1}}, + ['drink'] = {[df.item_type.DRINK] ={type_id=df.item_type.DRINK, max_stack_qty=math.huge}}, + ['fat'] = {[df.item_type.GLOB] ={type_id=df.item_type.GLOB, max_stack_qty=5}, + [df.item_type.CHEESE] ={type_id=df.item_type.CHEESE, max_stack_qty=5}}, + ['fish'] = {[df.item_type.FISH] ={type_id=df.item_type.FISH, max_stack_qty=5}, + [df.item_type.FISH_RAW] ={type_id=df.item_type.FISH_RAW, max_stack_qty=5}, + [df.item_type.EGG] ={type_id=df.item_type.EGG, max_stack_qty=5}}, + ['food'] = {[df.item_type.FOOD] ={type_id=df.item_type.FOOD, max_stack_qty=20}}, + ['meat'] = {[df.item_type.MEAT] ={type_id=df.item_type.MEAT, max_stack_qty=5}}, + ['plant'] = {[df.item_type.PLANT] ={type_id=df.item_type.PLANT, max_stack_qty=5}, + [df.item_type.PLANT_GROWTH]={type_id=df.item_type.PLANT_GROWTH, max_stack_qty=5}}, + ['powder'] = {[df.item_type.POWDER_MISC] ={type_id=df.item_type.POWDER_MISC, max_stack_qty=10}}, + ['seed'] = {[df.item_type.SEEDS] ={type_id=df.item_type.SEEDS, max_stack_qty=1}}, } @@ -75,43 +75,61 @@ function CList:new(o) return o end -local function comp_item_new(comp_key, max_size) +local function comp_item_new(comp_key, max_stack_qty) -- create a new comp_item entry to be added to a comp_items table. local comp_item = {} if not comp_key then qerror('new_comp_item: comp_key is nil') end comp_item.comp_key = comp_key -- key used to index comparable items for merging comp_item.description = '' -- description of the comp item for output - comp_item.max_size = max_size or 0 -- how many of a comp item can be in one stack + comp_item.max_stack_qty = max_stack_qty or 0 -- how many of a comp item can be in one stack -- item info comp_item.items = CList:new(nil) -- key:item.id, - -- val:{item, - -- before_size, after_size, before_cont_id, after_cont_id, + -- val:{item, base_weight, density, + -- before_stack_qty, after_stack_qty, + -- before_cont_id, after_cont_id, + -- before_volume, after_volume, -- stockpile_id, stockpile_name, -- before_mat_amt {Leather, Bone, Shell, Tooth, Horn, HairWool, Yarn} -- after_mat_amt {Leather, Bone, Shell, Tooth, Horn, HairWool, Yarn} -- } comp_item.item_qty = 0 -- total quantity of items + comp_item.base_weight = 0 -- base weight of an item + comp_item.density = 0 -- density of an item + comp_item.volume = 0 -- volume = qty * base weight + comp_item.weight = 0 -- weight = density * volume * 10 / 1,000,000 comp_item.material_amt = 0 -- total amount of materials comp_item.max_mat_amt = MAX_MAT_AMT -- max amount of materials in one stack comp_item.before_stacks = 0 -- the number of stacks of the items before... comp_item.after_stacks = 0 -- ...and after the merge --container info - comp_item.before_cont_ids = CList:new(nil) -- key:container.id, val:container.id - comp_item.after_cont_ids = CList:new(nil) -- key:container.id, val:container.id + comp_item.before_cont_ids = CList:new(nil) -- key:container.id, val:container.id + comp_item.after_cont_ids = CList:new(nil) -- key:container.id, val:container.id return comp_item end local function comp_item_add_item(stockpile, stack_type, comp_item, item, container) -- add an item into the comp_items table, setting the comp_item attributes. if not comp_item.items[item.id] then - comp_item.item_qty = comp_item.item_qty + item.stack_size + local item_qty = item.stack_size + local item_base_weight = item:getBaseWeight() + local item_volume = item:getVolume() + local item_density = item:getSolidDensity() + + comp_item.item_qty = comp_item.item_qty + item_qty comp_item.before_stacks = comp_item.before_stacks + 1 comp_item.description = utils.getItemDescription(item, 1) + comp_item.base_weight = item_base_weight + comp_item.volume = item_qty * item_base_weight + comp_item.density = item_density local new_item = {} new_item.item = item - new_item.before_size = item.stack_size + new_item.base_weight = item_base_weight + new_item.density = item_density + + new_item.before_stack_qty = item_qty + new_item.before_volume = item_qty * item_base_weight new_item.stockpile_id = stockpile.id new_item.stockpile_name = stockpile.name @@ -131,10 +149,16 @@ local function comp_item_add_item(stockpile, stack_type, comp_item, item, contai new_item.before_mat_amt.Horn = item.material_amount.Horn new_item.before_mat_amt.HairWool = item.material_amount.HairWool new_item.before_mat_amt.Yarn = item.material_amount.Yarn - for _, v in pairs(new_item.before_mat_amt) do if new_item.before_mat_amt.Qty < v then new_item.before_mat_amt.Qty = v end end + for _, v in pairs(new_item.before_mat_amt) do + if new_item.before_mat_amt.Qty < v then + new_item.before_mat_amt.Qty = v + end + end comp_item.material_amt = comp_item.material_amt + new_item.before_mat_amt.Qty - if new_item.before_mat_amt.Qty > comp_item.max_mat_amt then comp_item.max_mat_amt = new_item.before_mat_amt.Qty end + if new_item.before_mat_amt.Qty > comp_item.max_mat_amt then + comp_item.max_mat_amt = new_item.before_mat_amt.Qty + end end -- item is in a container @@ -162,15 +186,15 @@ local function stack_type_new(type_vals) end -- item info - stack_type.comp_items = CList:new(nil) -- key:comp_key, val:comp_item + stack_type.comp_items = CList:new(nil) -- key:comp_key, val:comp_item stack_type.item_qty = 0 -- total quantity of items types stack_type.material_amt = 0 -- total amount of materials stack_type.before_stacks = 0 -- the number of stacks of the item types before ... stack_type.after_stacks = 0 -- ...and after the merge --container info - stack_type.before_cont_ids = CList:new(nil) -- key:container.id, val:container.id - stack_type.after_cont_ids = CList:new(nil) -- key:container.id, val:container.id + stack_type.before_cont_ids = CList:new(nil) -- key:container.id, val:container.id + stack_type.after_cont_ids = CList:new(nil) -- key:container.id, val:container.id return stack_type end @@ -195,7 +219,7 @@ local function stacks_add_item(stockpile, stacks, stack_type, item, container) end if not stack_type.comp_items[comp_key] then - stack_type.comp_items[comp_key] = comp_item_new(comp_key, stack_type.max_size) + stack_type.comp_items[comp_key] = comp_item_new(comp_key, stack_type.max_stack_qty) end local new_comp_item_item = comp_item_add_item(stockpile, stack_type, stack_type.comp_items[comp_key], item, container) @@ -221,17 +245,17 @@ local function stacks_add_item(stockpile, stacks, stack_type, item, container) end local function sorted_items_qty(tab) - -- used to sort the comp_items by contained, then size. Important for combining containers. + -- used to sort the comp_items by contained, then qty. Important for combining containers. local tmp = {} for id, val in pairs(tab) do - local val = {id=id, before_cont_id=val.before_cont_id, before_size=val.before_size} + local val = {id=id, before_cont_id=val.before_cont_id, before_stack_qty=val.before_stack_qty} table.insert(tmp, val) end table.sort(tmp, function(a, b) if not a.before_cont_id and not b.before_cont_id or a.before_cont_id and b.before_cont_id then - return a.before_size > b.before_size + return a.before_stack_qty > b.before_stack_qty else return a.before_cont_id and not b.before_cont_id end @@ -309,19 +333,20 @@ local function print_stacks_details(stacks, quiet) if #stacks.containers > 0 then log(1, 'Summary:\nContainers:%5d before:%5d after:%5d\n', #stacks.containers, #stacks.before_cont_ids, #stacks.after_cont_ids) for cont_id, cont in sorted_desc(stacks.containers, stacks.before_cont_ids) do - log(2, (' Cont: %50s <%6d> bef:%5d aft:%5d cap:%5d\n'):format(cont.description, cont_id, cont.before_size, cont.after_size, cont.capacity)) + log(2, (' Cont: %50s <%6d> bef:%5d aft:%5d cap:%5d\n'):format(cont.description, cont_id, cont.before_stack_qty, cont.after_stack_qty, cont.capacity)) end end if stacks.item_qty > 0 then - log(1, ('Items: #Qty: %6d sizes: bef:%5d aft:%5d Mat amt:%6d\n'):format(stacks.item_qty, stacks.before_stacks, stacks.after_stacks, stacks.material_amt)) + log(1, ('Items: #Qty: %6d Stacks: bef:%5d aft:%5d Mat amt:%6d\n'):format(stacks.item_qty, stacks.before_stacks, stacks.after_stacks, stacks.material_amt)) for key, stack_type in pairs(stacks.stack_types) do if stack_type.item_qty > 0 then - log(1, (' Type: %12s <%d> #Qty:%6d sizes: max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks, #stack_type.before_cont_ids, #stack_type.after_cont_ids, stack_type.material_amt)) + log(1, (' Type: %12s <%d> #Qty:%6d Stacks: max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_stack_qty, stack_type.before_stacks, stack_type.after_stacks, #stack_type.before_cont_ids, #stack_type.after_cont_ids, stack_type.material_amt)) for _, comp_item in sorted_desc(stack_type.comp_items, stack_type.comp_items) do if comp_item.item_qty > 0 then - log(2, (' Comp item:%40s <%12s> #Qty:%6d #stacks:%5d max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids, comp_item.material_amt)) + log(2, ('G Comp item:%40s <%12s> #Qty:%6d #stacks:%5d max:%.0f bef:%6d aft:%6d Cont: bef:%5d aft:%5d Mat amt:%6d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_stack_qty, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids, comp_item.material_amt)) for _, item in sorted_items_qty(comp_item.items) do - log(3, (' Item:%40s <%6d> Qty: bef:%6d aft:%6.0f Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d stockpile:%s'):format(utils.getItemDescription(item.item), item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name)) + log(3, (' Item:%40s <%6d> Qty: bef:%6d aft:%6.0f Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d stockpile:%s'):format(utils.getItemDescription(item.item), item.item.id, item.before_stack_qty or 0, item.after_stack_qty or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name)) + log(2, (' Item:%40s <%6d> Qty: bef:%6d aft:%6.0f Cont: bef:<%5d> aft:<%5d> Mat Amt: bef: %6d aft:%6d sp:%s den: %6d s size: %6d liq:%s b wt:%6d vol:%6d\n'):format(utils.getItemDescription(item.item), item.item.id, item.before_stack_qty or 0, item.after_stack_qty or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0, item.stockpile_name, item.item:getSolidDensity(), item.item:getStackSize(), item.item:isLiquid(), item.item:getBaseWeight(), item.item:getVolume())) log(4, (' stackable: %s'):format(df.item_type.attrs[stack_type.type_id].is_stackable)) log(3, ('\n')) end @@ -353,7 +378,7 @@ local function stacks_new() local stacks = {} stacks.stack_types = CList:new(nil) -- key=type_id, val=stack_type - stacks.containers = CList:new(nil) -- key=container.id, val={container, description, before_size, after_size} + stacks.containers = CList:new(nil) -- key=container.id, val={container, description, before_stack_qty, after_stack_qty} stacks.before_cont_ids = CList:new(nil) -- key=container.id, val=container.id stacks.after_cont_ids = CList:new(nil) -- key=container.id, val=container.id stacks.item_qty = 0 @@ -394,10 +419,11 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) local type_id = item:getType() local subtype_id = item:getSubtype() local stack_type = stacks.stack_types[type_id] + local item_qty = item.stack_size -- stack size is actually a qty in this context. -- item type in list of included types? if stack_type and not item:isSand() and not item:isPlaster() and isValidPart(item) then - if not isRestrictedItem(item) and item.stack_size < stack_type.max_size then + if not isRestrictedItem(item) and item_qty < stack_type.max_stack_qty then stacks_add_item(stockpile, stacks, stack_type, item, container) @@ -424,7 +450,7 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) local count = #contained_items stacks.containers[item.id] = {} stacks.containers[item.id].container = item - stacks.containers[item.id].before_size = #contained_items + stacks.containers[item.id].before_stack_qty = #contained_items stacks.containers[item.id].description = utils.getItemDescription(item, 1) stacks.containers[item.id].capacity = dfhack.items.getCapacity(item) log(4, (' %sContainer:%s <%6d> #items:%5d #capacity:%5d\n'):format(ind, utils.getItemDescription(item), item.id, count, dfhack.items.getCapacity(item))) @@ -438,15 +464,16 @@ local function stacks_add_items(stockpile, stacks, items, container, ind) end local function unlimited_stacks(types) - log(4, 'Unlimited stacks\n') + -- Override the realistic limits of stack sizes. This is armok behaviour for those that want it. + -- Note: large stack sizes causes bottle neck effects for production of constructed items. + -- Need to determine how this interacts with container capacities. + -- There are certain types such as seeds that don't like being in stacks + -- greater than 1, so exclude these ones. + log(4, 'Unlimited stacks applied\n') - if opts.unlimited_stack then - for type_id, type_vals in pairs(types) do - print(type_id, type_vals ) - if types[type_id].max_size > 1 then - types[type_id].max_size = math.huge - end - print(type_id, type_vals) + for type_id, type_vals in pairs(types) do + if types[type_id].max_stack_qty > 1 then + types[type_id].max_stack_qty = math.huge end end end @@ -458,7 +485,10 @@ local function populate_stacks(stacks, stockpiles, types) -- comp_key is a compound key comprised of type_id+race+caste or type_id+mat_type+mat_index log(4, 'Populating phase\n') - unlimited_stacks(types) + -- unlimited stack sizes option enabled = Armok. Note that this is disabled by default. + if opts.unlimited_stack then + unlimited_stacks(types) + end -- iterate across the types log(4, 'stack types\n') @@ -466,7 +496,7 @@ local function populate_stacks(stacks, stockpiles, types) if not stacks.stack_types[type_id] then stacks.stack_types[type_id] = stack_type_new(type_vals) local stack_type = stacks.stack_types[type_id] - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_stack_qty, stack_type.before_stacks, stack_type.after_stacks)) end end @@ -491,25 +521,25 @@ local function preview_stacks(stacks) log(4, '\nPreview phase\n') for _, stack_type in pairs(stacks.stack_types) do - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_stack_qty, stack_type.before_stacks, stack_type.after_stacks)) for comp_key, comp_item in pairs(stack_type.comp_items) do - log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d Cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) + log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d Cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_stack_qty, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) -- item qty used? if not typesThatUseMaterial[df.item_type[stack_type.type_id]] then -- max size comparison - if stack_type.max_size > comp_item.max_size then - comp_item.max_size = stack_type.max_size + if stack_type.max_stack_qty > comp_item.max_stack_qty then + comp_item.max_stack_qty = stack_type.max_stack_qty end -- how many stacks are needed? For math.huge, this will be 0. - local stacks_needed = math.floor(comp_item.item_qty / comp_item.max_size) + local stacks_needed = math.floor(comp_item.item_qty / comp_item.max_stack_qty) local stack_remainder = comp_item.item_qty - if comp_item.max_size < math.huge then - stack_remainder = comp_item.item_qty - stacks_needed * comp_item.max_size + if comp_item.max_stack_qty < math.huge then + stack_remainder = comp_item.item_qty - stacks_needed * comp_item.max_stack_qty end if stack_remainder > 0 then @@ -528,12 +558,12 @@ local function preview_stacks(stacks) for _, item in sorted_items_qty(comp_item.items) do if stacks_needed > 0 then stacks_needed = stacks_needed - 1 - item.after_size = comp_item.max_size + item.after_stack_qty = comp_item.max_stack_qty elseif stack_remainder > 0 then - item.after_size = stack_remainder + item.after_stack_qty = stack_remainder stack_remainder = 0 else - item.after_size = 0 + item.after_stack_qty = 0 end end @@ -555,7 +585,7 @@ local function preview_stacks(stacks) item.after_mat_amt = {} if stacks_needed > 0 then stacks_needed = stacks_needed - 1 - item.after_size = item.before_size + item.after_stack_qty = item.before_stack_qty for k2, v in pairs(item.before_mat_amt) do if v > 0 then item.after_mat_amt[k2] = comp_item.max_mat_amt @@ -564,7 +594,7 @@ local function preview_stacks(stacks) end end elseif stack_remainder > 0 then - item.after_size = item.before_size + item.after_stack_qty = item.before_stack_qty for k2, v in pairs(item.before_mat_amt) do if v > 0 then item.after_mat_amt[k2] = stack_remainder @@ -577,7 +607,7 @@ local function preview_stacks(stacks) for k2, v in pairs(item.before_mat_amt) do item.after_mat_amt[k2] = 0 end - item.after_size = 0 + item.after_stack_qty = 0 end end end @@ -589,7 +619,7 @@ local function preview_stacks(stacks) for item_id, item in sorted_items_qty(comp_item.items) do -- non-zero quantity? - if item.after_size > 0 then + if item.after_stack_qty > 0 then -- in a container before merge? if item.before_cont_id then @@ -600,7 +630,7 @@ local function preview_stacks(stacks) if not curr_cont or curr_size >= MAX_CONT_ITEMS then curr_cont = before_cont - curr_size = curr_cont.before_size + curr_size = curr_cont.before_stack_qty stacks.after_cont_ids[item.before_cont_id] = item.before_cont_id stack_type.after_cont_ids[item.before_cont_id] = item.before_cont_id comp_item.after_cont_ids[item.before_cont_id] = item.before_cont_id @@ -608,17 +638,17 @@ local function preview_stacks(stacks) -- enough room in current container else curr_size = curr_size + 1 - before_cont.after_size = (before_cont.after_size or before_cont.before_size) - 1 + before_cont.after_stack_qty = (before_cont.after_stack_qty or before_cont.before_stack_qty) - 1 end - curr_cont.after_size = curr_size + curr_cont.after_stack_qty = curr_size item.after_cont_id = curr_cont.container.id -- not in a container before merge, container exists, and has space elseif curr_cont and curr_size < MAX_CONT_ITEMS then curr_size = curr_size + 1 - curr_cont.after_size = curr_size + curr_cont.after_stack_qty = curr_size item.after_cont_id = curr_cont.container.id -- not in a container, no container exists or no space in container @@ -629,34 +659,34 @@ local function preview_stacks(stacks) -- zero after size, reduce the number of stacks in the container elseif item.before_cont_id then local before_cont = stacks.containers[item.before_cont_id] - before_cont.after_size = (before_cont.after_size or before_cont.before_size) - 1 + before_cont.after_stack_qty = (before_cont.after_stack_qty or before_cont.before_stack_qty) - 1 end end - log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_size, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) + log(4, (' comp item:%40s <%12s> #qty:%5d #stacks:%5d sizes: max: %.0f bef:%5d aft:%5d cont: bef:%5d aft:%5d\n'):format(comp_item.description, comp_item.comp_key, comp_item.item_qty, #comp_item.items, comp_item.max_stack_qty, comp_item.before_stacks, comp_item.after_stacks, #comp_item.before_cont_ids, #comp_item.after_cont_ids)) end - log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_size, stack_type.before_stacks, stack_type.after_stacks)) + log(4, (' type: <%12s> <%d> #item_qty:%5d stack sizes: max: %.0f bef:%5d aft:%5d\n'):format(df.item_type[stack_type.type_id], stack_type.type_id, stack_type.item_qty, stack_type.max_stack_qty, stack_type.before_stacks, stack_type.after_stacks)) end end local function merge_stacks(stacks) - -- apply the stack size changes in the after_item_stack_size - -- if the after_item_stack_size is zero, then remove the item + -- apply the stack size changes in the item.after_stack_qty + -- if the item.after_stack_qty is zero, then remove the item log(4, 'Merge phase\n') for _, stack_type in pairs(stacks.stack_types) do for comp_key, comp_item in pairs(stack_type.comp_items) do for item_id, item in pairs(comp_item.items) do - log(4, (' item amt:%40s <%6d> bef:%5d aft:%5d cont: bef:<%5d> aft:<%5d> mat: bef:%5d aft:%5d '):format(comp_item.description, item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0)) + log(4, (' item amt:%40s <%6d> bef:%5d aft:%5d cont: bef:<%5d> aft:<%5d> mat: bef:%5d aft:%5d '):format(comp_item.description, item.item.id, item.before_stack_qty or 0, item.after_stack_qty or 0, item.before_cont_id or 0, item.after_cont_id or 0, item.before_mat_amt.Qty or 0, item.after_mat_amt.Qty or 0)) -- no items left in stack? - if item.after_size == 0 then + if item.after_stack_qty == 0 then log(4, ' removing\n') dfhack.items.remove(item.item) -- some items left in stack - elseif not typesThatUseMaterial[df.item_type[stack_type.type_id]] and item.before_size ~= item.after_size then + elseif not typesThatUseMaterial[df.item_type[stack_type.type_id]] and item.before_stack_qty ~= item.after_stack_qty then log(4, ' updating qty\n') - item.item.stack_size = item.after_size + item.item.stack_size = item.after_stack_qty elseif typesThatUseMaterial[df.item_type[stack_type.type_id]] and item.before_mat_amt.Qty ~= item.after_mat_amt.Qty then log(4, ' updating material\n') @@ -674,7 +704,7 @@ local function merge_stacks(stacks) -- move to a container? if item.after_cont_id then if (item.before_cont_id or 0) ~= item.after_cont_id then - log(4, (' moving item:%40s <%6d> bef:%5d aft:%5d cont: bef:<%5d> aft:<%5d>\n'):format(comp_item.description, item.item.id, item.before_size or 0, item.after_size or 0, item.before_cont_id or 0, item.after_cont_id or 0)) + log(4, (' moving item:%40s <%6d> bef:%5d aft:%5d cont: bef:<%5d> aft:<%5d>\n'):format(comp_item.description, item.item.id, item.before_stack_qty or 0, item.after_stack_qty or 0, item.before_cont_id or 0, item.after_cont_id or 0)) dfhack.items.moveToContainer(item.item, stacks.containers[item.after_cont_id].container) end end diff --git a/docs/combine.rst b/docs/combine.rst index 8f8889090a..67cb16100e 100644 --- a/docs/combine.rst +++ b/docs/combine.rst @@ -45,29 +45,32 @@ Options ``all``: all of the types listed here. - ``ammo``: AMMO + ``ammo``: AMMO. Max 25. - ``drink``: DRINK + ``drink``: DRINK. No Max. - ``fat``: GLOB and CHEESE + ``fat``: GLOB and CHEESE. Max 5. - ``fish``: FISH, FISH_RAW and EGG + ``fish``: FISH, FISH_RAW and EGG. Max 5. - ``food``: FOOD + ``food``: FOOD. Max 20. - ``meat``: MEAT + ``meat``: MEAT. Max 5. - ``parts``: CORPSEPIECE + ``parts``: CORPSEPIECE. Max 1. - ``plant``: PLANT and PLANT_GROWTH + ``plant``: PLANT and PLANT_GROWTH. Max 5. - ``powders``: POWDERS_MISC + ``powders``: POWDERS_MISC. Max 10. - ``seed``: SEEDS + ``seed``: SEEDS. Max 1. ``-q``, ``--quiet`` Only print changes instead of a summary of all processed stockpiles. +``-u``, ``--unlimited-stack`` + Use unlimited stack size (Armok). Default false. + ``-v``, ``--verbose n`` Print verbose output, n from 1 to 4. @@ -84,7 +87,4 @@ The following categories are defined: 2. Items that have an associated race/caste, grouped by item type, race, and caste 3. Ammo, grouped by ammo type, material, and quality. If the ammo is a masterwork, it is also grouped by who created it. 4. Anything else, grouped by item type and material - -Each category has a default stack size of 30 unless a larger stack already -exists "naturally" in your fort. In that case the largest existing stack size -is used. + \ No newline at end of file From 1105e29104b7527445520c569d29144faf66a6d4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 19 Nov 2023 11:30:19 +0000 Subject: [PATCH 5/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- combine.lua | 4 ++-- docs/combine.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/combine.lua b/combine.lua index 71639bab07..376f54cd56 100644 --- a/combine.lua +++ b/combine.lua @@ -85,7 +85,7 @@ local function comp_item_new(comp_key, max_stack_qty) -- item info comp_item.items = CList:new(nil) -- key:item.id, -- val:{item, base_weight, density, - -- before_stack_qty, after_stack_qty, + -- before_stack_qty, after_stack_qty, -- before_cont_id, after_cont_id, -- before_volume, after_volume, -- stockpile_id, stockpile_name, @@ -467,7 +467,7 @@ local function unlimited_stacks(types) -- Override the realistic limits of stack sizes. This is armok behaviour for those that want it. -- Note: large stack sizes causes bottle neck effects for production of constructed items. -- Need to determine how this interacts with container capacities. - -- There are certain types such as seeds that don't like being in stacks + -- There are certain types such as seeds that don't like being in stacks -- greater than 1, so exclude these ones. log(4, 'Unlimited stacks applied\n') diff --git a/docs/combine.rst b/docs/combine.rst index 67cb16100e..843f1b0dbb 100644 --- a/docs/combine.rst +++ b/docs/combine.rst @@ -87,4 +87,4 @@ The following categories are defined: 2. Items that have an associated race/caste, grouped by item type, race, and caste 3. Ammo, grouped by ammo type, material, and quality. If the ammo is a masterwork, it is also grouped by who created it. 4. Anything else, grouped by item type and material - \ No newline at end of file + From 1b28493bc2c641163e9ada7a212a825b78aacc98 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:44:36 +0000 Subject: [PATCH 6/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/combine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/combine.rst b/docs/combine.rst index 594463d058..928a9611ed 100644 --- a/docs/combine.rst +++ b/docs/combine.rst @@ -82,4 +82,4 @@ The following categories are defined: 2. Items that have an associated race/caste, grouped by item type, race, and caste 3. Ammo, grouped by ammo type, material, and quality. If the ammo is a masterwork, it is also grouped by who created it. 4. Anything else, grouped by item type and material. - \ No newline at end of file + From 6ad7b44c82a8ea7093e617a90007cb4e15801861 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 20:46:12 +0000 Subject: [PATCH 7/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/combine.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/combine.rst b/docs/combine.rst index 928a9611ed..32d5036d2e 100644 --- a/docs/combine.rst +++ b/docs/combine.rst @@ -82,4 +82,3 @@ The following categories are defined: 2. Items that have an associated race/caste, grouped by item type, race, and caste 3. Ammo, grouped by ammo type, material, and quality. If the ammo is a masterwork, it is also grouped by who created it. 4. Anything else, grouped by item type and material. - From da5f81a0eeee209e1341798c2470628f542cb2f4 Mon Sep 17 00:00:00 2001 From: Myk Date: Mon, 20 Nov 2023 15:42:23 -0800 Subject: [PATCH 8/9] Update combine.lua --- combine.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/combine.lua b/combine.lua index f45acf660a..cee95fcd47 100644 --- a/combine.lua +++ b/combine.lua @@ -17,7 +17,7 @@ local opts, args = { local MAX_CONT_ITEMS=30 -- TODO: --- 1. Combine plantable seeds only, currently removed seeds as option. +-- 1. Combine non-plantable seeds only, currently removed seeds as option. -- 2. Quality for food, currently ignoring. -- 3. Obey capacity limits for containers as default. Container quality? -- 4. Override stack size; armok option. From 9931992f102de553d75e1c9b3d99f6d18994479b Mon Sep 17 00:00:00 2001 From: Myk Date: Mon, 20 Nov 2023 15:44:24 -0800 Subject: [PATCH 9/9] Update changelog.txt --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 84329fa0c4..3626793bae 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,6 +33,7 @@ Template for new versions: ## Fixes ## Misc Improvements +- `combine`: prevent stack sizes from growing beyond quantities that you would normally see in vanilla gameplay ## Removed