From f5d50adf0de9ebbe222542252d5f9f342aa95eae Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Fri, 15 Aug 2014 21:39:57 -0600 Subject: [PATCH 1/3] Removing the leaves check for stockpile acceptability. That item type no longer exists in DF 0.40; such items will now always be considered properly stored by any stockpile they're on. --- plugins/lua/stockflow.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index e8bdc51d1..6e5876c2d 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1115,8 +1115,6 @@ function matches_stockpile(item, settings) return settings.flags.food elseif df.item_plantst:is_instance(item) then return settings.flags.food - elseif df.item_leavesst:is_instance(item) then - return settings.flags.food elseif df.item_cheesest:is_instance(item) then return settings.flags.food elseif df.item_globst:is_instance(item) then From 8495bddc2d6a9693ab2f8d21a0a1000041ba3686 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 23 Aug 2014 17:46:35 -0600 Subject: [PATCH 2/3] Removing an obsolete workaround --- plugins/lua/stockflow.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 6e5876c2d..d2cfcef46 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1042,9 +1042,7 @@ function check_pile(sp, verbose) local empty = 0 for y = sp.y1, sp.y2 do for x = sp.x1, sp.x2 do - -- Sadly, the obvious check currently fails when y == sp.y2 - if dfhack.buildings.containsTile(sp, x, y) or - (y == sp.y2 and dfhack.buildings.findAtTile(x, y, sp.z) == sp) then + if dfhack.buildings.containsTile(sp, x, y) then numspaces = numspaces + 1 local designation, occupancy = dfhack.maps.getTileFlags(x, y, sp.z) if not designation.liquid_type then From 632b0b85bda99d61193b9e7de057f868e8501504 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 23 Aug 2014 17:49:03 -0600 Subject: [PATCH 3/3] Speeding up the stockpile item count. kr0pper reports two orders of magnitude speed improvement for check_pile() by using the map tile item cache. --- plugins/lua/stockflow.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index d2cfcef46..2f564cec1 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -978,10 +978,10 @@ end function findItemsAtTile(x, y, z) -- There should be a faster and easier way to do this... local found = {} - for _, item in ipairs(df.global.world.items.all) do - -- local ix, iy, iz = dfhack.items.getPosition(item) - if item.pos.x == x and item.pos.y == y and - item.pos.z == z and item.flags.on_ground then + local items = dfhack.maps.getTileBlock(x, y, z).items + for _, item_id in ipairs(items) do + local item = df.item.find(item_id) + if item.pos.x == x and item.pos.y == y and item.flags.on_ground then found[#found+1] = item end end