Better way to handle obsolete job types.

develop
Eric Wald 2014-10-16 16:01:57 -06:00
parent 81c2a6e79f
commit 6bfaa8d35d
2 changed files with 10 additions and 10 deletions

@ -20,6 +20,7 @@ DFHack Future
modtools/skill-change: made level granularity work properly. modtools/skill-change: made level granularity work properly.
show-unit-syndromes should work show-unit-syndromes should work
stockflow: Fixed error message in Arena mode stockflow: Fixed error message in Arena mode
stockflow: No longer checks the DF version
zone: Stopped crash when scrolling cage owner list zone: Stopped crash when scrolling cage owner list
New Plugins New Plugins
New Scripts New Scripts

@ -150,6 +150,12 @@ function select_order(stockpile)
end end
function reaction_entry(reactions, job_type, values, name) function reaction_entry(reactions, job_type, values, name)
if not job_type then
-- Perhaps df.job_type.something returned nil for an unknown job type.
-- We could warn about it; in any case, don't add it to the list.
return
end
local order = df.manager_order:new() local order = df.manager_order:new()
-- These defaults differ from the newly created order's. -- These defaults differ from the newly created order's.
order:assign{ order:assign{
@ -227,9 +233,6 @@ function collect_reactions()
-- Even that list doesn't seem to include their names. -- Even that list doesn't seem to include their names.
local result = {} local result = {}
-- A few task types are obsolete in newer DF versions.
local v34 = string.match(dfhack.getDFVersion(), "v0.34")
-- Caching the enumeration might not be important, but saves lookups. -- Caching the enumeration might not be important, but saves lookups.
local job_types = df.job_type local job_types = df.job_type
@ -355,10 +358,8 @@ function collect_reactions()
reaction_entry(result, job_types.PrepareMeal, {mat_type = 3}, "Prepare Fine Meal") reaction_entry(result, job_types.PrepareMeal, {mat_type = 3}, "Prepare Fine Meal")
reaction_entry(result, job_types.PrepareMeal, {mat_type = 4}, "Prepare Lavish Meal") reaction_entry(result, job_types.PrepareMeal, {mat_type = 4}, "Prepare Lavish Meal")
if v34 then
-- Brew Drink -- Brew Drink
reaction_entry(result, job_types.BrewDrink) reaction_entry(result, job_types.BrewDrink)
end
-- Weaving -- Weaving
reaction_entry(result, job_types.WeaveCloth, {material_category = {plant = true}}, "Weave Thread into Cloth") reaction_entry(result, job_types.WeaveCloth, {material_category = {plant = true}}, "Weave Thread into Cloth")
@ -376,9 +377,7 @@ function collect_reactions()
reaction_entry(result, job_types.SpinThread) reaction_entry(result, job_types.SpinThread)
reaction_entry(result, job_types.MakeLye) reaction_entry(result, job_types.MakeLye)
reaction_entry(result, job_types.ProcessPlants) reaction_entry(result, job_types.ProcessPlants)
if v34 then
reaction_entry(result, job_types.ProcessPlantsBag) reaction_entry(result, job_types.ProcessPlantsBag)
end
reaction_entry(result, job_types.ProcessPlantsVial) reaction_entry(result, job_types.ProcessPlantsVial)
reaction_entry(result, job_types.ProcessPlantsBarrel) reaction_entry(result, job_types.ProcessPlantsBarrel)
reaction_entry(result, job_types.MakeCharcoal) reaction_entry(result, job_types.MakeCharcoal)