| 1305 | } |
| 1306 | |
| 1307 | bool Buildings::deconstruct(df::building *bld) |
| 1308 | { |
| 1309 | using df::global::game; |
| 1310 | using df::global::ui_look_list; |
| 1311 | |
| 1312 | CHECK_NULL_POINTER(bld); |
| 1313 | |
| 1314 | if (bld->isActual() && bld->getBuildStage() > 0) { |
| 1315 | if (markedForRemoval(bld)) { |
| 1316 | // already queued for destruction |
| 1317 | return false; |
| 1318 | } |
| 1319 | bld->queueDestroy(); |
| 1320 | return false; |
| 1321 | } |
| 1322 | |
| 1323 | // Immediate destruction code path. |
| 1324 | // Should only happen for abstract and unconstructed buildings. |
| 1325 | |
| 1326 | if (bld->flags.bits.almost_deleted) |
| 1327 | return true; |
| 1328 | bld->flags.bits.almost_deleted = true; |
| 1329 | |
| 1330 | if (bld->isSettingOccupancy()) { |
| 1331 | markBuildingTiles(bld, true); |
| 1332 | bld->cleanupMap(); |
| 1333 | } |
| 1334 | |
| 1335 | bool destitem = bld->isFarmPlot(); |
| 1336 | bool insanify = false; |
| 1337 | bool is_from_damage = false; |
| 1338 | |
| 1339 | bld->removeUses(destitem, insanify); |
| 1340 | |
| 1341 | const df::building_type btype = bld->getType(); |
| 1342 | if (btype == df::building_type::Civzone) { |
| 1343 | if (auto zone = strict_virtual_cast<df::building_civzonest>(bld)) |
| 1344 | on_civzone_delete(zone); |
| 1345 | } else { |
| 1346 | while (bld->relations.size()) |
| 1347 | remove_building_from_zone(bld, bld->relations[bld->relations.size() - 1]); |
| 1348 | } |
| 1349 | |
| 1350 | for (auto unit : world->units.active) { |
| 1351 | if (unit->job.destroy_target == bld) |
| 1352 | unit->job.destroy_target = NULL; |
| 1353 | } |
| 1354 | |
| 1355 | const int id = bld->id; |
| 1356 | erase_from_vector(plotinfo->tax_collection.rooms, id); |
| 1357 | |
| 1358 | for (auto punishment : plotinfo->punishments) { |
| 1359 | if (punishment->chain == id) |
| 1360 | punishment->chain = -1; |
| 1361 | } |
| 1362 | |
| 1363 | const bool interrupt_rest = |
| 1364 | btype == df::building_type::TractionBench || |
nothing calls this directly
no test coverage detected