diff --git a/docs/changelog.txt b/docs/changelog.txt index f23d9d4e1..1ea571df2 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -53,6 +53,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `remove-stress`: fixed an error when running on soul-less units (e.g. with ``-all``) - `revflood`: stopped revealing tiles adjacent to tiles above open space inappropriately - `stockpiles`: ``loadstock`` sets usable and unusable weapon and armor settings +- `stocks`: Remove carried items from stockpile where they were picked up ## Misc Improvements - Added script name to messages produced by ``qerror()`` in Lua scripts diff --git a/plugins/uicommon.h b/plugins/uicommon.h index 17fcd18bd..d8624786c 100644 --- a/plugins/uicommon.h +++ b/plugins/uicommon.h @@ -348,10 +348,22 @@ public: bool inStockpile(df::item *i) { - df::item *container = Items::getContainer(i); + // Check if the item is assigned to a stockpile + if (i->isAssignedToStockpile()) + return i->isAssignedToThisStockpile(sp->id); + + // If this is in a container check where the container item is + df::item* container = Items::getContainer(i); if (container) return inStockpile(container); + // Inventory items seems to have stale position information. We can + // assume that they are not in the stockpile. + if (i->flags.bits.in_inventory) + return false; + + // Only containers are assigned to a stockpile. We need a coordinate + // check for free items. if (i->pos.z != z) return false; if (i->pos.x < x1 || i->pos.x >= x2 || i->pos.y < y1 || i->pos.y >= y2) return false;