Merge pull request #1026 from ab9rf/labormanager-0.43.05-r1

labormanager: fix deconstruction of buildings containing items
develop
Lethosor 2016-12-01 18:41:10 -05:00 committed by GitHub
commit eaf9b75a18
1 changed files with 9 additions and 1 deletions

@ -677,10 +677,18 @@ static df::unit_labor construction_build_labor (df::building_actual* b)
{
if (b->getType() == df::building_type::RoadPaved)
return df::unit_labor::BUILD_ROAD;
// Find last item in building with use mode appropriate to the building's constructions state
// For screw pumps contained_items[0] = pipe, 1 corkscrew, 2 block
// For wells 0 mechanism, 1 rope, 2 bucket, 3 block
// Trade depots and bridges use the last one too
df::item* i = b->contained_items.back()->item;
// Must check use mode b/c buildings may have items in them that are not part of the building
df::item* i = 0;
for (auto p = b->contained_items.begin(); p != b->contained_items.end(); p++)
if (b->construction_stage > 0 && (*p)->use_mode == 2 ||
b->construction_stage == 0 && (*p)->use_mode == 0)
i = (*p)->item;
MaterialInfo matinfo;
if (i && matinfo.decode(i))
{