MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / removeBuildingElement

Function removeBuildingElement

src/OpenLoco/src/Map/TileManager.cpp:1120–1160  ·  view source on GitHub ↗

0x0042D8FF

Source from the content-addressed store, hash-verified

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)

Callers 1

removeBuildingFunction · 0.85

Calls 14

getUpdatingCompanyIdFunction · 0.85
createDestructExplosionFunction · 0.85
updateTownInfoFunction · 0.85
enumValueFunction · 0.85
isAiAllocatedMethod · 0.80
baseHeightMethod · 0.80
clearHeightMethod · 0.80
removeElementFunction · 0.70
invalidateFunction · 0.50
isGhostMethod · 0.45
sequenceIndexMethod · 0.45
getObjectMethod · 0.45

Tested by

no test coverage detected