From e4de3411682f85ae6b2fb2f5faa787d3b3248247 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Thu, 17 Dec 2015 21:45:43 -0700 Subject: [PATCH 1/4] Preparing for MakeInstrument elimination. Instruments are now made individually, so this type of job no longer happens. Therefore, it will probably be removed from the job_type enum. --- plugins/devel/autolabor2.cpp | 1 - plugins/dwarfmonitor.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/devel/autolabor2.cpp b/plugins/devel/autolabor2.cpp index aca30ad3e..62bcc98d0 100644 --- a/plugins/devel/autolabor2.cpp +++ b/plugins/devel/autolabor2.cpp @@ -1222,7 +1222,6 @@ public: job_to_labor_table[df::job_type::MakeChain] = jlf_make_object; job_to_labor_table[df::job_type::MakeFlask] = jlf_make_object; job_to_labor_table[df::job_type::MakeGoblet] = jlf_make_object; - job_to_labor_table[df::job_type::MakeInstrument] = jlf_make_object; job_to_labor_table[df::job_type::MakeToy] = jlf_make_object; job_to_labor_table[df::job_type::MakeAnimalTrap] = jlf_const(df::unit_labor::TRAPPER); job_to_labor_table[df::job_type::MakeBarrel] = jlf_make_furniture; diff --git a/plugins/dwarfmonitor.cpp b/plugins/dwarfmonitor.cpp index ca61ddb2e..787c97fc0 100644 --- a/plugins/dwarfmonitor.cpp +++ b/plugins/dwarfmonitor.cpp @@ -706,7 +706,6 @@ public: case job_type::MakeChain: case job_type::MakeFlask: case job_type::MakeGoblet: - case job_type::MakeInstrument: case job_type::MakeToy: case job_type::MakeAnimalTrap: case job_type::MakeBarrel: From 45625318bb32896560d13c9e68df7ae753e7c382 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Thu, 17 Dec 2015 22:02:30 -0700 Subject: [PATCH 2/4] Stockflow reaction list repairs. Mostly, instruments and their pieces are made through generated custom reactions, instead of as tools. Depends on df-structures commit e551233 for full potency. --- plugins/lua/stockflow.lua | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 745427656..5a92666e5 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -127,8 +127,9 @@ function collect_orders() entry = entry, } else - -- It might be worth searching reaction_list for the name. - -- Then again, this should only happen in unusual situations. + -- Todo: Search reaction_list for the name. + -- This can happen when loading an old save in a new version. + -- It's even possible that the reaction has been removed. print("Mismatched stockflow entry for stockpile #"..stockpile.stockpile_number..": "..entry.value.." ("..order_number..")") end else @@ -398,6 +399,14 @@ function collect_reactions() local name = string.gsub(reaction.name, "^.", string.upper) reaction_entry(result, job_types.CustomReaction, {reaction_name = reaction.code}, name) end + + -- Reactions generated by the game. + for _, reaction in ipairs(df.global.world.raws.reactions) do + if reaction.source_enid == entity.id then + local name = string.gsub(reaction.name, "^.", string.upper) + reaction_entry(result, job_types.CustomReaction, {reaction_name = reaction.code}, name) + end + end -- Metal forging local itemdefs = df.global.world.raws.itemdefs @@ -465,19 +474,10 @@ function collect_reactions() clothing_reactions(result, mat_flags, metalclothing) end - if material.flags.ITEMS_HARD then - resource_reactions(result, job_types.MakeTool, mat_flags, entity.resources.tool_type, itemdefs.tools, { - permissible = (function(itemdef) return itemdef.flags.HARD_MAT end), - capitalize = true, - }) - end - - if material.flags.ITEMS_METAL then - resource_reactions(result, job_types.MakeTool, mat_flags, entity.resources.tool_type, itemdefs.tools, { - permissible = (function(itemdef) return itemdef.flags.METAL_MAT end), - capitalize = true, - }) - end + resource_reactions(result, job_types.MakeTool, mat_flags, entity.resources.tool_type, itemdefs.tools, { + permissible = (function(itemdef) return ((material.flags.ITEMS_HARD and itemdef.flags.HARD_MAT) or (material.flags.ITEMS_METAL and itemdef.flags.METAL_MAT)) and not itemdef.flags.NO_DEFAULT_JOB end), + capitalize = true, + }) if material.flags.ITEMS_HARD then material_reactions(result, { @@ -560,7 +560,8 @@ function collect_reactions() }, materials.wood) resource_reactions(result, job_types.MakeTool, materials.wood, entity.resources.tool_type, itemdefs.tools, { - -- permissible = (function(itemdef) return itemdef.flags.WOOD_MAT end), + -- permissible = (function(itemdef) return itemdef.flags.WOOD_MAT and not itemdef.flags.NO_DEFAULT_JOB end), + permissible = (function(itemdef) return not itemdef.flags.NO_DEFAULT_JOB end), capitalize = true, }) From 3c4bb6c7e3e29986d02fb823ef9ea04b31b93817 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Thu, 17 Dec 2015 22:13:09 -0700 Subject: [PATCH 3/4] Stockflow no longer needs to be singled out in the init file. --- dfhack.init-example | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/dfhack.init-example b/dfhack.init-example index db2bf1129..080bb1488 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -216,15 +216,13 @@ enable \ zone \ stocks \ autochop \ + stockflow \ stockpiles #end a line with a backslash to make it continue to the next line. The \ is deleted for the final command. # Multiline commands are ONLY supported for scripts like dfhack.init. You cannot do multiline command manually on the DFHack console. # You cannot extend a commented line. # You can comment out the extension of a line. -# allow the fortress bookkeeper to queue jobs through the manager -enable stockflow - # enable mouse controls and sand indicator in embark screen embark-tools enable sand mouse @@ -249,10 +247,3 @@ gui/load-screen enable ####################################################### # Apply binary patches at runtime # ####################################################### - -####################################################### -# Disable broken tools for v0.42.01 # -####################################################### - -disable stockflow -:lua dfhack.printerr("Some tools incompatible with v0.42.01 have been disabled") From 4dc94a565f8660b11b559a377f9c65908c9060cf Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Fri, 18 Dec 2015 07:02:29 -0700 Subject: [PATCH 4/4] Adjusting stockflow order numbers where possible. Loading 0.40 saves in 0.42 results in a different list of reactions. Fortunately, all but the instruments should still work. --- plugins/lua/stockflow.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 5a92666e5..6d3b3ba15 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -130,7 +130,25 @@ function collect_orders() -- Todo: Search reaction_list for the name. -- This can happen when loading an old save in a new version. -- It's even possible that the reaction has been removed. - print("Mismatched stockflow entry for stockpile #"..stockpile.stockpile_number..": "..entry.value.." ("..order_number..")") + local found = false + for number, reaction in ipairs(reaction_list) do + if reaction.name == entry.value then + print("Adjusting stockflow entry for stockpile #"..stockpile.stockpile_number..": "..entry.value.." ("..order_number.." => "..number..")") + entry.ints[entry_ints.order_number] = number + entry:save() + result[spid] = { + stockpile = stockpile, + entry = entry, + } + + found = true + break + end + end + + if not found then + print("Unmatched stockflow entry for stockpile #"..stockpile.stockpile_number..": "..entry.value.." ("..order_number..")") + end end else -- The stockpile no longer exists.