Merge remote-tracking branch 'suokko/fix_stocks_to_filter_military_items_1288' into develop

develop
lethosor 2018-06-21 00:04:06 -04:00
commit 46b6bfd3f7
2 changed files with 14 additions and 1 deletions

@ -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``) - `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 - `revflood`: stopped revealing tiles adjacent to tiles above open space inappropriately
- `stockpiles`: ``loadstock`` sets usable and unusable weapon and armor settings - `stockpiles`: ``loadstock`` sets usable and unusable weapon and armor settings
- `stocks`: Remove carried items from stockpile where they were picked up
## Misc Improvements ## Misc Improvements
- Added script name to messages produced by ``qerror()`` in Lua scripts - Added script name to messages produced by ``qerror()`` in Lua scripts

@ -348,10 +348,22 @@ public:
bool inStockpile(df::item *i) 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) if (container)
return inStockpile(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.z != z) return false;
if (i->pos.x < x1 || i->pos.x >= x2 || if (i->pos.x < x1 || i->pos.x >= x2 ||
i->pos.y < y1 || i->pos.y >= y2) return false; i->pos.y < y1 || i->pos.y >= y2) return false;