From 5be77fa63dcdba88e1418eeea50d81fa462a52fe Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Fri, 16 Dec 2016 08:09:53 -0600 Subject: [PATCH 1/4] stockflow: Fix "integer expected" problem in stockflow --- plugins/lua/stockflow.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 6027bb455..510718ff1 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1137,6 +1137,7 @@ function check_stockpiles(verbose) local filled, empty = check_pile(spec.stockpile, verbose) local amount = trigger.filled and filled or empty amount = (amount - (amount % trigger.divisor)) / trigger.divisor + amount = math.floor(amount) result[reaction] = (result[reaction] or 0) + amount end end From 1419d58b9a6d074edb0d56deda62f5f2e4f12852 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Fri, 16 Dec 2016 13:04:51 -0600 Subject: [PATCH 2/4] stockflow: Use "floor division" Per suggestion by @dscorbett --- plugins/lua/stockflow.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 510718ff1..32fc342fb 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1136,8 +1136,7 @@ function check_stockpiles(verbose) local reaction = spec.entry.ints[entry_ints.order_number] local filled, empty = check_pile(spec.stockpile, verbose) local amount = trigger.filled and filled or empty - amount = (amount - (amount % trigger.divisor)) / trigger.divisor - amount = math.floor(amount) + amount = (amount - (amount % trigger.divisor)) // trigger.divisor result[reaction] = (result[reaction] or 0) + amount end end From ba48afe9080fdba05a94fc7b66f31bda4264c749 Mon Sep 17 00:00:00 2001 From: Lethosor Date: Fri, 16 Dec 2016 14:22:00 -0500 Subject: [PATCH 3/4] stockflow: Simplify calculation See #1046 Use math.floor() for now until we can get Lua 5.3 working on Travis --- plugins/lua/stockflow.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 32fc342fb..dd83e65d9 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1135,8 +1135,7 @@ function check_stockpiles(verbose) if trigger and trigger.divisor then local reaction = spec.entry.ints[entry_ints.order_number] local filled, empty = check_pile(spec.stockpile, verbose) - local amount = trigger.filled and filled or empty - amount = (amount - (amount % trigger.divisor)) // trigger.divisor + local amount = math.floor((trigger.filled and filled or empty) / trigger.divisor) result[reaction] = (result[reaction] or 0) + amount end end From 3c7d2626e250a4128e2fa1a98f1480e40235ab33 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Sun, 18 Dec 2016 17:57:23 -0600 Subject: [PATCH 4/4] df::dfhack_material_category has no constructor, must be manually initialized see #1047 --- plugins/buildingplan-lib.h | 4 +++- plugins/workflow.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/buildingplan-lib.h b/plugins/buildingplan-lib.h index 7ec0c41d4..6975960d2 100644 --- a/plugins/buildingplan-lib.h +++ b/plugins/buildingplan-lib.h @@ -114,7 +114,9 @@ struct ItemFilter bool decorated_only; ItemFilter() : min_quality(df::item_quality::Ordinary), decorated_only(false), valid(true) - { } + { + clear(); // mat_mask is not cleared by default (see issue #1047) + } bool matchesMask(DFHack::MaterialInfo &mat); diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index 55f1dc504..f8f9e8231 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -357,7 +357,9 @@ public: : is_craft(false), min_quality(item_quality::Ordinary), is_local(false), weight(0), item_amount(0), item_count(0), item_inuse_amount(0), item_inuse_count(0), is_active(false), cant_resume_reported(false), low_stock_reported(-1) - {} + { + mat_mask.whole = 0; // see https://github.com/DFHack/dfhack/issues/1047 + } int goalCount() { return config.ival(0); } void setGoalCount(int v) { config.ival(0) = v; }