0x0042D8FF
| 1118 | |
| 1119 | // 0x0042D8FF |
| 1120 | void removeBuildingElement(BuildingElement& elBuilding, const World::Pos2& pos) |
| 1121 | { |
| 1122 | if (!elBuilding.isGhost() && !elBuilding.isAiAllocated()) |
| 1123 | { |
| 1124 | if (GameCommands::getUpdatingCompanyId() != CompanyId::neutral) |
| 1125 | { |
| 1126 | createDestructExplosion(World::Pos3(pos.x + 16, pos.y + 16, elBuilding.baseHeight())); |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | if (elBuilding.sequenceIndex() == 0) |
| 1131 | { |
| 1132 | if (!elBuilding.isGhost()) |
| 1133 | { |
| 1134 | auto* buildingObj = elBuilding.getObject(); |
| 1135 | if (buildingObj != nullptr) |
| 1136 | { |
| 1137 | if (!buildingObj->hasFlags(BuildingObjectFlags::miscBuilding)) |
| 1138 | { |
| 1139 | auto buildingCapacity = -buildingObj->producedQuantity[0]; |
| 1140 | auto removedPopulation = buildingCapacity; |
| 1141 | if (!elBuilding.isConstructed()) |
| 1142 | { |
| 1143 | removedPopulation = 0; |
| 1144 | } |
| 1145 | auto ratingReduction = buildingObj->demolishRatingReduction; |
| 1146 | auto* town = TownManager::updateTownInfo(pos, removedPopulation, buildingCapacity, ratingReduction, -1); |
| 1147 | if (town != nullptr) |
| 1148 | { |
| 1149 | if (buildingObj->townAmenityCategory != TownAmenityCategory::none) |
| 1150 | { |
| 1151 | town->amenityCounts[enumValue(buildingObj->townAmenityCategory)] -= 1; |
| 1152 | } |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | } |
| 1157 | } |
| 1158 | Ui::ViewportManager::invalidate(pos, elBuilding.baseHeight(), elBuilding.clearHeight(), ZoomLevel::eighth); |
| 1159 | TileManager::removeElement(*reinterpret_cast<TileElement*>(&elBuilding)); |
| 1160 | } |
| 1161 | |
| 1162 | // 0x004C482B |
| 1163 | void removeAllWallsOnTileAbove(const World::TilePos2& pos, SmallZ baseZ) |
no test coverage detected