Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stockflow repairs #770

Merged
merged 4 commits into from
Dec 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions dfhack.init-example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
1 change: 0 additions & 1 deletion plugins/devel/autolabor2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,6 @@ class JobLaborMapper {
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;
Expand Down
1 change: 0 additions & 1 deletion plugins/dwarfmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@ class ViewscreenFortStats : public dfhack_viewscreen
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:
Expand Down
53 changes: 36 additions & 17 deletions plugins/lua/stockflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,28 @@ 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.
print("Mismatched stockflow entry for stockpile #"..stockpile.stockpile_number..": "..entry.value.." ("..order_number..")")
-- 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.
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.
Expand Down Expand Up @@ -398,6 +417,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
Expand Down Expand Up @@ -465,19 +492,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, {
Expand Down Expand Up @@ -560,7 +578,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,
})

Expand Down