Convenience method to collect a vector from StockpileIterator.

develop
Eric Wald 2014-09-07 14:10:27 -06:00
parent 3c58bd3948
commit 8631da7e4e
2 changed files with 18 additions and 0 deletions

@ -284,5 +284,10 @@ public:
} }
}; };
/**
* Collects items stored on a stockpile into a vector.
*/
DFHACK_EXPORT void getStockpileContents(df::building_stockpilest *stockpile, std::vector<df::item*> *items);
} }
} }

@ -1163,3 +1163,16 @@ void Buildings::updateBuildings(color_ostream& out, void* ptr)
corner2.erase(id); corner2.erase(id);
} }
} }
void Buildings::getStockpileContents(df::building_stockpilest *stockpile, std::vector<df::item*> *items)
{
CHECK_NULL_POINTER(stockpile);
items->clear();
Buildings::StockpileIterator stored;
for (stored.begin(stockpile); !stored.done(); ++stored) {
df::item *item = *stored;
items->push_back(item);
}
}